Browse Source

qml wizard: fix restoring from old mpk (watchonly for "old" seeds)

fixes https://github.com/spesmilo/electrum/issues/8356
master
SomberNight 3 years ago
parent
commit
f5f177f7e8
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 31
      electrum/gui/qml/qebitcoin.py
  2. 2
      electrum/gui/qml/qewizard.py
  3. 19
      electrum/wizard.py

31
electrum/gui/qml/qebitcoin.py

@ -107,28 +107,27 @@ class QEBitcoin(QObject):
@pyqtSlot(str, str, result=bool)
def verifyMasterKey(self, key, wallet_type='standard'):
# FIXME exceptions raised in here are not well-behaved...
self.validationMessage = ''
if not keystore.is_master_key(key):
self.validationMessage = _('Not a master key')
return False
k = keystore.from_master_key(key)
has_xpub = isinstance(k, keystore.Xpub)
assert has_xpub
t1 = xpub_type(k.xpub)
if wallet_type == 'standard':
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
return False
return True
elif wallet_type == 'multisig':
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
return False
return True
raise Exception(f'Unsupported wallet type: {wallet_type}')
if isinstance(k, keystore.Xpub): # has xpub # TODO are these checks useful?
t1 = xpub_type(k.xpub)
if wallet_type == 'standard':
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
return False
return True
elif wallet_type == 'multisig':
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
return False
return True
raise Exception(f'Unsupported wallet type: {wallet_type}')
return True
@pyqtSlot(str, result=bool)
def verifyDerivationPath(self, path):

2
electrum/gui/qml/qewizard.py

@ -108,7 +108,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard):
self.createSuccess.emit()
except Exception as e:
self._logger.error(repr(e))
self._logger.error(f"createStorage errored: {e!r}")
self.createError.emit(str(e))
class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):

19
electrum/wizard.py

@ -381,15 +381,18 @@ class NewWalletWizard(AbstractWizard):
raise Exception('unsupported/unknown seed_type %s' % data['seed_type'])
elif data['keystore_type'] == 'masterkey':
k = keystore.from_master_key(data['master_key'])
has_xpub = isinstance(k, keystore.Xpub)
assert has_xpub
t1 = xpub_type(k.xpub)
if data['wallet_type'] == 'multisig':
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
raise Exception('wrong key type %s' % t1)
if isinstance(k, keystore.Xpub): # has xpub
t1 = xpub_type(k.xpub)
if data['wallet_type'] == 'multisig':
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
raise Exception('wrong key type %s' % t1)
else:
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
raise Exception('wrong key type %s' % t1)
elif isinstance(k, keystore.Old_KeyStore):
pass
else:
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
raise Exception('wrong key type %s' % t1)
raise Exception(f"unexpected keystore type: {type(keystore)}")
else:
raise Exception('unsupported/unknown keystore_type %s' % data['keystore_type'])

Loading…
Cancel
Save