From 1601d58819cf1af4ecbc6392db0dac75804d4bad Mon Sep 17 00:00:00 2001 From: m0mchil Date: Sun, 8 Feb 2015 13:28:10 +0200 Subject: [PATCH] Confirm address on TREZOR --- plugins/trezor.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/trezor.py b/plugins/trezor.py index 1048b6e02..94fe892ca 100644 --- a/plugins/trezor.py +++ b/plugins/trezor.py @@ -131,6 +131,10 @@ class Plugin(BasePlugin): self.wallet.trezor_sign(tx) except Exception as e: tx.error = str(e) + @hook + def receive_menu(self, menu, addrs): + if not self.wallet.is_watching_only() and len(addrs) == 1: + menu.addAction(_("Show on TREZOR"), lambda: self.wallet.show_address(addrs[0])) def settings_widget(self, window): return EnterButton(_('Settings'), self.settings_dialog) @@ -277,6 +281,21 @@ class TrezorWallet(BIP32_HD_Wallet): # twd.emit(SIGNAL('trezor_done')) #return str(decrypted_msg) + def show_address(self, address): + if not self.check_proper_device(): + give_error('Wrong device or password') + try: + address_path = self.address_id(address) + address_n = self.get_client().expand_path(address_path) + except Exception, e: + give_error(e) + try: + self.get_client().get_address('Bitcoin', address_n, True) + except Exception, e: + give_error(e) + finally: + twd.emit(SIGNAL('trezor_done')) + def sign_message(self, address, message, password): if not self.check_proper_device(): give_error('Wrong device or password') @@ -426,6 +445,8 @@ class TrezorQtGuiMixin(object): message = "Confirm transaction fee on Trezor device to continue" elif msg.code == 7: message = "Confirm message to sign on Trezor device to continue" + elif msg.code == 10: + message = "Confirm address on Trezor device to continue" else: message = "Check Trezor device to continue" twd.start(message)