From ec0dbc78c2368650f9434ae57431dc51ff920fc6 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 15 Sep 2023 11:39:53 +0200 Subject: [PATCH] wizard: fix assumption 'keystore_type' is present in wizard_data, fix unexpected keystore type msg --- electrum/plugins/hw_wallet/plugin.py | 2 ++ electrum/wizard.py | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/electrum/plugins/hw_wallet/plugin.py b/electrum/plugins/hw_wallet/plugin.py index b17efcf6e..fe62cf164 100644 --- a/electrum/plugins/hw_wallet/plugin.py +++ b/electrum/plugins/hw_wallet/plugin.py @@ -364,4 +364,6 @@ class OutdatedHwFirmwareException(UserFacingException): class OperationCancelled(UserFacingException): + """Emitted when an operation is cancelled by user on a HW device + """ pass diff --git a/electrum/wizard.py b/electrum/wizard.py index 639965283..ee3b5e987 100644 --- a/electrum/wizard.py +++ b/electrum/wizard.py @@ -560,7 +560,7 @@ class NewWalletWizard(AbstractWizard): elif isinstance(k, keystore.Old_KeyStore): pass else: - raise Exception(f"unexpected keystore type: {type(keystore)}") + raise Exception(f"unexpected keystore type: {type(k)}") elif data['keystore_type'] == 'hardware': # TODO: prelim impl k = self.hw_keystore(data) if isinstance(k, keystore.Xpub): # has xpub @@ -571,10 +571,8 @@ class NewWalletWizard(AbstractWizard): else: if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']: raise Exception('wrong key type %s' % t1) - # elif isinstance(k, keystore.Old_KeyStore): - # pass else: - raise Exception(f"unexpected keystore type: {type(keystore)}") + raise Exception(f"unexpected keystore type: {type(k)}") else: raise Exception('unsupported/unknown keystore_type %s' % data['keystore_type']) @@ -582,7 +580,7 @@ class NewWalletWizard(AbstractWizard): if k and k.may_have_password(): k.update_password(None, data['password']) enc_version = StorageEncryptionVersion.USER_PASSWORD - if data['keystore_type'] == 'hardware': + if 'keystore_type' in data and data['keystore_type'] == 'hardware': enc_version = StorageEncryptionVersion.XPUB_PASSWORD storage.set_password(data['password'], enc_version=enc_version)