storage upgrade as part of the wizard. fix storage upgrade on kivy.
This commit is contained in:
@@ -503,7 +503,7 @@ class ElectrumWindow(App):
|
|||||||
self.load_wallet(wallet)
|
self.load_wallet(wallet)
|
||||||
else:
|
else:
|
||||||
Logger.debug('Electrum: Wallet not found. Launching install wizard')
|
Logger.debug('Electrum: Wallet not found. Launching install wizard')
|
||||||
storage = WalletStorage(path)
|
storage = WalletStorage(path, manual_upgrades=True)
|
||||||
wizard = Factory.InstallWizard(self.electrum_config, storage)
|
wizard = Factory.InstallWizard(self.electrum_config, storage)
|
||||||
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
||||||
action = wizard.storage.get_action()
|
action = wizard.storage.get_action()
|
||||||
|
|||||||
@@ -744,7 +744,7 @@ class InstallWizard(BaseWizard, Widget):
|
|||||||
"""overriden by main_window"""
|
"""overriden by main_window"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def waiting_dialog(self, task, msg):
|
def waiting_dialog(self, task, msg, on_finished=None):
|
||||||
'''Perform a blocking task in the background by running the passed
|
'''Perform a blocking task in the background by running the passed
|
||||||
method in a thread.
|
method in a thread.
|
||||||
'''
|
'''
|
||||||
@@ -756,6 +756,8 @@ class InstallWizard(BaseWizard, Widget):
|
|||||||
self.show_error(str(err))
|
self.show_error(str(err))
|
||||||
# on completion hide message
|
# on completion hide message
|
||||||
Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1)
|
Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1)
|
||||||
|
if on_finished:
|
||||||
|
Clock.schedule_once(lambda dt: on_finished(), -1)
|
||||||
|
|
||||||
app = App.get_running_app()
|
app = App.get_running_app()
|
||||||
app.show_info_bubble(
|
app.show_info_bubble(
|
||||||
|
|||||||
@@ -284,13 +284,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
self.show_warning(_('The file was removed'))
|
self.show_warning(_('The file was removed'))
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.storage.requires_upgrade():
|
|
||||||
self.storage.upgrade()
|
|
||||||
self.wallet = Wallet(self.storage)
|
|
||||||
return self.wallet
|
|
||||||
|
|
||||||
action = self.storage.get_action()
|
action = self.storage.get_action()
|
||||||
if action and action != 'new':
|
if action and action not in ('new', 'upgrade_storage'):
|
||||||
self.hide()
|
self.hide()
|
||||||
msg = _("The file '{}' contains an incompletely created wallet.\n"
|
msg = _("The file '{}' contains an incompletely created wallet.\n"
|
||||||
"Do you want to complete its creation now?").format(path)
|
"Do you want to complete its creation now?").format(path)
|
||||||
@@ -473,12 +468,26 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
def terminate(self):
|
def terminate(self):
|
||||||
self.accept_signal.emit()
|
self.accept_signal.emit()
|
||||||
|
|
||||||
def waiting_dialog(self, task, msg):
|
def waiting_dialog(self, task, msg, on_finished=None):
|
||||||
self.please_wait.setText(msg)
|
label = WWLabel(msg)
|
||||||
self.refresh_gui()
|
vbox = QVBoxLayout()
|
||||||
t = threading.Thread(target = task)
|
vbox.addSpacing(100)
|
||||||
|
label.setMinimumWidth(300)
|
||||||
|
label.setAlignment(Qt.AlignCenter)
|
||||||
|
vbox.addWidget(label)
|
||||||
|
self.set_layout(vbox, next_enabled=False)
|
||||||
|
self.back_button.setEnabled(False)
|
||||||
|
|
||||||
|
t = threading.Thread(target=task)
|
||||||
t.start()
|
t.start()
|
||||||
t.join()
|
while True:
|
||||||
|
t.join(1.0/60)
|
||||||
|
if t.is_alive():
|
||||||
|
self.refresh_gui()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
if on_finished:
|
||||||
|
on_finished()
|
||||||
|
|
||||||
@wizard_dialog
|
@wizard_dialog
|
||||||
def choice_dialog(self, title, message, choices, run_next):
|
def choice_dialog(self, title, message, choices, run_next):
|
||||||
|
|||||||
@@ -26,11 +26,12 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from . import keystore
|
from . import keystore
|
||||||
from .keystore import bip44_derivation
|
from .keystore import bip44_derivation
|
||||||
from .wallet import Imported_Wallet, Standard_Wallet, Multisig_Wallet, wallet_types
|
from .wallet import Imported_Wallet, Standard_Wallet, Multisig_Wallet, wallet_types, Wallet
|
||||||
from .storage import STO_EV_USER_PW, STO_EV_XPUB_PW, get_derivation_used_for_hw_device_encryption
|
from .storage import STO_EV_USER_PW, STO_EV_XPUB_PW, get_derivation_used_for_hw_device_encryption
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .util import UserCancelled, InvalidPassword
|
from .util import UserCancelled, InvalidPassword
|
||||||
@@ -100,6 +101,12 @@ class BaseWizard(object):
|
|||||||
choices = [pair for pair in wallet_kinds if pair[0] in wallet_types]
|
choices = [pair for pair in wallet_kinds if pair[0] in wallet_types]
|
||||||
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.on_wallet_type)
|
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.on_wallet_type)
|
||||||
|
|
||||||
|
def upgrade_storage(self):
|
||||||
|
def on_finished():
|
||||||
|
self.wallet = Wallet(self.storage)
|
||||||
|
self.terminate()
|
||||||
|
self.waiting_dialog(partial(self.storage.upgrade), _('Upgrading wallet format...'), on_finished=on_finished)
|
||||||
|
|
||||||
def load_2fa(self):
|
def load_2fa(self):
|
||||||
self.storage.put('wallet_type', '2fa')
|
self.storage.put('wallet_type', '2fa')
|
||||||
self.storage.put('use_trustedcoin', True)
|
self.storage.put('use_trustedcoin', True)
|
||||||
|
|||||||
@@ -238,8 +238,6 @@ class Daemon(DaemonThread):
|
|||||||
storage.decrypt(password)
|
storage.decrypt(password)
|
||||||
if storage.requires_split():
|
if storage.requires_split():
|
||||||
return
|
return
|
||||||
if storage.requires_upgrade():
|
|
||||||
return
|
|
||||||
if storage.get_action():
|
if storage.get_action():
|
||||||
return
|
return
|
||||||
wallet = Wallet(storage)
|
wallet = Wallet(storage)
|
||||||
|
|||||||
@@ -578,10 +578,17 @@ class WalletStorage(PrintError):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_action(self):
|
def get_action(self):
|
||||||
action = run_hook('get_action', self)
|
if self.file_exists():
|
||||||
if action:
|
action = run_hook('get_action', self)
|
||||||
return action
|
if action and self.requires_upgrade():
|
||||||
if not self.file_exists():
|
raise WalletFileException(_('Incomplete wallet files cannot be upgraded.'))
|
||||||
|
elif self.requires_upgrade():
|
||||||
|
return 'upgrade_storage'
|
||||||
|
elif action:
|
||||||
|
return action
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
return 'new'
|
return 'new'
|
||||||
|
|
||||||
def get_seed_version(self):
|
def get_seed_version(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user