electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 2996ec927f9313bc4a603b50cf38b6fb53998718
parent 2ffd419e66ac4d2cedae1dd5e91d11203101f4ec
Author: ThomasV <thomasv@gitorious>
Date:   Wed, 19 Aug 2015 10:15:36 +0200

fix #862: ask passphrase only once

Diffstat:
Mplugins/trezor.py | 30++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/plugins/trezor.py b/plugins/trezor.py @@ -23,6 +23,7 @@ from electrum.wallet import pw_decode, bip32_private_derivation, bip32_root from electrum_gui.qt.util import * from electrum_gui.qt.main_window import StatusBarButton, ElectrumWindow +from electrum_gui.qt.installwizard import InstallWizard try: from trezorlib.client import types @@ -133,7 +134,7 @@ class Plugin(BasePlugin): if type(window) is ElectrumWindow: self.window.statusBar().addPermanentWidget(self.trezor_button) if self.handler is None: - self.handler = TrezorQtHandler(self.window.app) + self.handler = TrezorQtHandler(self.window) try: self.get_client().ping('t') except BaseException as e: @@ -625,18 +626,23 @@ class TrezorQtHandler: self.done.set() def passphrase_dialog(self): - from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog - d = QDialog() - d.setModal(1) - d.setLayout(make_password_dialog(d, None, self.message, False)) - confirmed, p, passphrase = run_password_dialog(d, None, None) - if not confirmed: - QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) - self.passphrase = None - else: - if passphrase is None: - passphrase = '' # Even blank string is valid Trezor passphrase + if type(self.win) is ElectrumWindow: + passphrase = self.win.password_dialog(_("Please enter your Trezor passphrase")) self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) + else: + assert type(self.win) is InstallWizard + from electrum_gui.qt.password_dialog import make_password_dialog, run_password_dialog + d = QDialog() + d.setModal(1) + d.setLayout(make_password_dialog(d, None, self.message, False)) + confirmed, p, passphrase = run_password_dialog(d, None, None) + if not confirmed: + QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) + self.passphrase = None + else: + if passphrase is None: + passphrase = '' # Even blank string is valid Trezor passphrase + self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) self.done.set() def message_dialog(self):