Permit empty passphrases when creating HW wallet
They used to be confused as a user cancel. Fixes #1788 Also fix Cancel pressed in passphrase dialog when *restoring* a hardware wallet in install wizard; it used to be taken as an empty passphrase. Like the password dialog it now cancels the wizard.
This commit is contained in:
parent
18b7337aea
commit
db1aa13015
|
@ -208,13 +208,15 @@ class InstallWizard(QDialog, MessageBoxMixin, WizardBase):
|
||||||
self.set_main_layout(playout.layout())
|
self.set_main_layout(playout.layout())
|
||||||
return playout.new_password()
|
return playout.new_password()
|
||||||
|
|
||||||
def request_passphrase(self, device_text, restore=True):
|
def request_passphrase(self, device_text):
|
||||||
"""Request a passphrase for a wallet from the given device and
|
"""When restoring a wallet, request the passphrase that was used for
|
||||||
confirm it. restore is True if restoring a wallet. Should return
|
the wallet on the given device and confirm it. Should return
|
||||||
a unicode string."""
|
a unicode string."""
|
||||||
if restore:
|
phrase = self.pw_layout(MSG_RESTORE_PASSPHRASE % device_text,
|
||||||
msg = MSG_RESTORE_PASSPHRASE % device_text
|
PW_PASSPHRASE)
|
||||||
return unicode(self.pw_layout(msg, PW_PASSPHRASE) or '')
|
if phrase is None:
|
||||||
|
raise UserCancelled
|
||||||
|
return phrase
|
||||||
|
|
||||||
def request_password(self, msg=None):
|
def request_password(self, msg=None):
|
||||||
"""Request the user enter a new password and confirm it. Return
|
"""Request the user enter a new password and confirm it. Return
|
||||||
|
|
|
@ -146,7 +146,11 @@ class PasswordLayout(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def new_password(self):
|
def new_password(self):
|
||||||
return unicode(self.new_pw.text()) or None
|
pw = unicode(self.new_pw.text())
|
||||||
|
# Empty passphrases are fine and returned empty.
|
||||||
|
if pw == "" and self.kind != PW_PASSPHRASE:
|
||||||
|
pw = None
|
||||||
|
return pw
|
||||||
|
|
||||||
|
|
||||||
class PasswordDialog(WindowModalDialog):
|
class PasswordDialog(WindowModalDialog):
|
||||||
|
|
|
@ -98,9 +98,9 @@ class WizardBase(PrintError):
|
||||||
True on success."""
|
True on success."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def request_passphrase(self, device_text, restore=True):
|
def request_passphrase(self, device_text):
|
||||||
"""Request a passphrase for a wallet from the given device and
|
"""When restoring a wallet, request the passphrase that was used for
|
||||||
confirm it. restore is True if restoring a wallet. Should return
|
the wallet on the given device and confirm it. Should return
|
||||||
a unicode string."""
|
a unicode string."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class HW_PluginBase(BasePlugin):
|
||||||
wallet.storage.put('wallet_type', wallet_class.wallet_type)
|
wallet.storage.put('wallet_type', wallet_class.wallet_type)
|
||||||
wallet = wallet_class(wallet.storage)
|
wallet = wallet_class(wallet.storage)
|
||||||
|
|
||||||
passphrase = wizard.request_passphrase(self.device, restore=True)
|
passphrase = wizard.request_passphrase(self.device)
|
||||||
password = wizard.request_password()
|
password = wizard.request_password()
|
||||||
wallet.add_seed(seed, password)
|
wallet.add_seed(seed, password)
|
||||||
wallet.add_xprv_from_seed(seed, 'x/', password, passphrase)
|
wallet.add_xprv_from_seed(seed, 'x/', password, passphrase)
|
||||||
|
|
Loading…
Reference in New Issue