qml wizard: fix restoring from old mpk (watchonly for "old" seeds)
fixes https://github.com/spesmilo/electrum/issues/8356
This commit is contained in:
@@ -107,28 +107,27 @@ class QEBitcoin(QObject):
|
|||||||
|
|
||||||
@pyqtSlot(str, str, result=bool)
|
@pyqtSlot(str, str, result=bool)
|
||||||
def verifyMasterKey(self, key, wallet_type='standard'):
|
def verifyMasterKey(self, key, wallet_type='standard'):
|
||||||
|
# FIXME exceptions raised in here are not well-behaved...
|
||||||
self.validationMessage = ''
|
self.validationMessage = ''
|
||||||
if not keystore.is_master_key(key):
|
if not keystore.is_master_key(key):
|
||||||
self.validationMessage = _('Not a master key')
|
self.validationMessage = _('Not a master key')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
k = keystore.from_master_key(key)
|
k = keystore.from_master_key(key)
|
||||||
has_xpub = isinstance(k, keystore.Xpub)
|
if isinstance(k, keystore.Xpub): # has xpub # TODO are these checks useful?
|
||||||
assert has_xpub
|
t1 = xpub_type(k.xpub)
|
||||||
t1 = xpub_type(k.xpub)
|
if wallet_type == 'standard':
|
||||||
|
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
|
||||||
if wallet_type == 'standard':
|
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
|
||||||
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
|
return False
|
||||||
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
|
return True
|
||||||
return False
|
elif wallet_type == 'multisig':
|
||||||
return True
|
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
|
||||||
elif wallet_type == 'multisig':
|
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
|
||||||
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
|
return False
|
||||||
self.validationMessage = '%s: %s' % (_('Wrong key type'), t1)
|
return True
|
||||||
return False
|
raise Exception(f'Unsupported wallet type: {wallet_type}')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
raise Exception(f'Unsupported wallet type: {wallet_type}')
|
|
||||||
|
|
||||||
@pyqtSlot(str, result=bool)
|
@pyqtSlot(str, result=bool)
|
||||||
def verifyDerivationPath(self, path):
|
def verifyDerivationPath(self, path):
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard):
|
|||||||
|
|
||||||
self.createSuccess.emit()
|
self.createSuccess.emit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(repr(e))
|
self._logger.error(f"createStorage errored: {e!r}")
|
||||||
self.createError.emit(str(e))
|
self.createError.emit(str(e))
|
||||||
|
|
||||||
class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||||
|
|||||||
@@ -381,15 +381,18 @@ class NewWalletWizard(AbstractWizard):
|
|||||||
raise Exception('unsupported/unknown seed_type %s' % data['seed_type'])
|
raise Exception('unsupported/unknown seed_type %s' % data['seed_type'])
|
||||||
elif data['keystore_type'] == 'masterkey':
|
elif data['keystore_type'] == 'masterkey':
|
||||||
k = keystore.from_master_key(data['master_key'])
|
k = keystore.from_master_key(data['master_key'])
|
||||||
has_xpub = isinstance(k, keystore.Xpub)
|
if isinstance(k, keystore.Xpub): # has xpub
|
||||||
assert has_xpub
|
t1 = xpub_type(k.xpub)
|
||||||
t1 = xpub_type(k.xpub)
|
if data['wallet_type'] == 'multisig':
|
||||||
if data['wallet_type'] == 'multisig':
|
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
|
||||||
if t1 not in ['standard', 'p2wsh', 'p2wsh-p2sh']:
|
raise Exception('wrong key type %s' % t1)
|
||||||
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:
|
else:
|
||||||
if t1 not in ['standard', 'p2wpkh', 'p2wpkh-p2sh']:
|
raise Exception(f"unexpected keystore type: {type(keystore)}")
|
||||||
raise Exception('wrong key type %s' % t1)
|
|
||||||
else:
|
else:
|
||||||
raise Exception('unsupported/unknown keystore_type %s' % data['keystore_type'])
|
raise Exception('unsupported/unknown keystore_type %s' % data['keystore_type'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user