electrum

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

commit ca6194e5634addf3c4b90454cb42f3ad1f7f6a4b
parent ad4449dc380d94f4fc79cdb7e25fc53c9f4663e2
Author: ThomasV <thomasv@gitorious>
Date:   Sun, 14 Sep 2014 11:48:30 +0200

trezor: check if device is connected before asking passphrase

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

diff --git a/plugins/trezor.py b/plugins/trezor.py @@ -79,16 +79,31 @@ class Plugin(BasePlugin): def enable(self): return BasePlugin.enable(self) + def trezor_is_connected(self): + try: + self.wallet.get_client().ping('t') + except: + return False + return True + + @hook + def init_qt(self, gui): + self.window = gui.main_window + @hook def close_wallet(self): print_error("trezor: clear session") - self.wallet.client.clear_session() + if self.wallet.client: + self.wallet.client.clear_session() @hook def load_wallet(self, wallet): self.wallet = wallet - if not self.wallet.check_proper_device(): - QMessageBox.information(None, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) + if self.trezor_is_connected(): + if not self.wallet.check_proper_device(): + QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) + else: + QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK')) @hook def installwizard_restore(self, wizard, storage):