commit a799a00dc52d475c1a849eda4522a752a50f2d61
parent 579d48cf0cca3038961814f83dfc9028a410dd69
Author: SomberNight <somber.night@protonmail.com>
Date: Tue, 24 Jul 2018 18:57:49 +0200
fix #4577
Diffstat:
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py
@@ -34,7 +34,7 @@ from .keystore import bip44_derivation, purpose48_derivation
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 .i18n import _
-from .util import UserCancelled, InvalidPassword
+from .util import UserCancelled, InvalidPassword, WalletFileException
# hardware device setup purpose
HWD_SETUP_NEW_WALLET, HWD_SETUP_DECRYPT_WALLET = range(0, 2)
@@ -106,10 +106,20 @@ class BaseWizard(object):
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.on_wallet_type)
def upgrade_storage(self):
+ exc = None
def on_finished():
- self.wallet = Wallet(self.storage)
- self.terminate()
- self.waiting_dialog(partial(self.storage.upgrade), _('Upgrading wallet format...'), on_finished=on_finished)
+ if exc is None:
+ self.wallet = Wallet(self.storage)
+ self.terminate()
+ else:
+ raise exc
+ def do_upgrade():
+ nonlocal exc
+ try:
+ self.storage.upgrade()
+ except Exception as e:
+ exc = e
+ self.waiting_dialog(do_upgrade, _('Upgrading wallet format...'), on_finished=on_finished)
def load_2fa(self):
self.storage.put('wallet_type', '2fa')
diff --git a/electrum/gui/kivy/uix/dialogs/installwizard.py b/electrum/gui/kivy/uix/dialogs/installwizard.py
@@ -957,7 +957,12 @@ class InstallWizard(BaseWizard, Widget):
# on completion hide message
Clock.schedule_once(lambda dt: app.info_bubble.hide(now=True), -1)
if on_finished:
- Clock.schedule_once(lambda dt: on_finished(), -1)
+ def protected_on_finished():
+ try:
+ on_finished()
+ except Exception as e:
+ self.show_error(str(e))
+ Clock.schedule_once(lambda dt: protected_on_finished(), -1)
app = App.get_running_app()
app.show_info_bubble(
diff --git a/electrum/wallet.py b/electrum/wallet.py
@@ -1661,4 +1661,4 @@ class Wallet(object):
return Multisig_Wallet
if wallet_type in wallet_constructors:
return wallet_constructors[wallet_type]
- raise RuntimeError("Unknown wallet type: " + str(wallet_type))
+ raise WalletFileException("Unknown wallet type: " + str(wallet_type))