1
0

trezor: single passphrase entry

Only require the user to input the passphrase once, unless creating
a wallet.
Should they mis-enter the passphrase, they will be warned Electrum
couldn't pair the device, and when they actually need to use it
they will be prompted again.
Fixes #1672
This commit is contained in:
Neil Booth
2016-02-11 19:51:56 +09:00
parent 2bbe829f32
commit 535956149a
6 changed files with 45 additions and 17 deletions

View File

@@ -25,7 +25,6 @@ from electrum_gui.qt.util import *
from electrum.i18n import _
from electrum.util import PrintError
from electrum.wallet import BIP44_Wallet
# The trickiest thing about this handler was getting windows properly
# parented on MacOSX.
@@ -80,17 +79,29 @@ class QtHandlerBase(QObject, PrintError):
self.done.wait()
return self.word
def get_passphrase(self, msg):
def get_passphrase(self, msg, confirm):
self.done.clear()
self.win.emit(SIGNAL('passphrase_dialog'), msg)
self.win.emit(SIGNAL('passphrase_dialog'), msg, confirm)
self.done.wait()
return self.passphrase
def passphrase_dialog(self, msg):
d = PasswordDialog(self.top_level_window(), None, msg, PW_PASSPHRASE)
confirmed, p, passphrase = d.run()
if confirmed:
passphrase = BIP44_Wallet.normalize_passphrase(passphrase)
def passphrase_dialog(self, msg, confirm):
# If confirm is true, require the user to enter the passphrase twice
parent = self.top_level_window()
if confirm:
d = PasswordDialog(parent, None, msg, PW_PASSPHRASE)
confirmed, p, passphrase = d.run()
else:
d = WindowModalDialog(parent, _("Enter Passphrase"))
pw = QLineEdit()
pw.setEchoMode(2)
pw.setMinimumWidth(200)
vbox = QVBoxLayout()
vbox.addWidget(WWLabel(msg))
vbox.addWidget(pw)
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
d.setLayout(vbox)
passphrase = unicode(pw.text()) if d.exec_() else None
self.passphrase = passphrase
self.done.set()