Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show address on trezor for multisig #3823

Merged

Conversation

farmerwampum
Copy link
Contributor

@farmerwampum farmerwampum commented Feb 2, 2018

show address on trezor for multisig

@coveralls
Copy link

coveralls commented Feb 2, 2018

Coverage Status

Coverage remained the same at 42.851% when pulling f315cb9 on farmerwampum:showmultisigaddressontrezor into 52acb7a on spesmilo:master.

@SomberNight
Copy link
Member

Why does Trezor need to be the first cosigner?

@farmerwampum
Copy link
Contributor Author

Not sure why it won't show the option.

@@ -188,8 +188,6 @@ def create_handler(self, window):

@hook
def receive_menu(self, menu, addrs, wallet):
if type(wallet) is not Standard_Wallet:
return
keystore = wallet.get_keystore()
if type(keystore) == self.keystore_class and len(addrs) == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet.get_keystore() returns the first keystore in the wallet, that is why it only works if Trezor is first

@SomberNight
Copy link
Member

You should do something like this:

diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py
index 9bdf7903..1f45e2f3 100644
--- a/plugins/trezor/plugin.py
+++ b/plugins/trezor/plugin.py
@@ -246,16 +246,16 @@ class TrezorCompatiblePlugin(HW_PluginBase):
         raw = bh2u(signed_tx)
         tx.update_signatures(raw)
 
-    def show_address(self, wallet, address):
-        client = self.get_client(wallet.keystore)
+    def show_address(self, wallet, keystore, address):
+        client = self.get_client(keystore)
         if not client.atleast_version(1, 3):
-            wallet.keystore.handler.show_error(_("Your device firmware is too old"))
+            keystore.handler.show_error(_("Your device firmware is too old"))
             return
         change, index = wallet.get_address_index(address)
-        derivation = wallet.keystore.derivation
+        derivation = keystore.derivation
         address_path = "%s/%d/%d"%(derivation, change, index)
         address_n = client.expand_path(address_path)
-        script_gen = wallet.keystore.get_script_gen()
+        script_gen = keystore.get_script_gen()
         if script_gen == SCRIPT_GEN_NATIVE_SEGWIT:
             script_type = self.types.InputScriptType.SPENDWITNESS
         elif script_gen == SCRIPT_GEN_P2SH_SEGWIT:
diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py
index 0fff2019..a4b9c07c 100644
--- a/plugins/trezor/qt_generic.py
+++ b/plugins/trezor/qt_generic.py
@@ -188,11 +188,14 @@ class QtPlugin(QtPluginBase):
 
     @hook
     def receive_menu(self, menu, addrs, wallet):
-        keystore = wallet.get_keystore()
-        if type(keystore) == self.keystore_class and len(addrs) == 1:
-            def show_address():
-                keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
-            menu.addAction(_("Show on %s") % self.device, show_address)
+        if len(addrs) != 1:
+            return
+        for keystore in wallet.get_keystores():
+            if type(keystore) == self.keystore_class:
+                def show_address():
+                    keystore.thread.add(partial(self.show_address, wallet, keystore, addrs[0]))
+                menu.addAction(_("Show on %s") % self.device, show_address)
+                break
 
     def show_settings_dialog(self, window, keystore):
         device_id = self.choose_device(window, keystore)

Feel free to do it another way though.

@@ -188,13 +188,15 @@ def create_handler(self, window):

@hook
def receive_menu(self, menu, addrs, wallet):
if type(wallet) is not Standard_Wallet:
return
keystore = wallet.get_keystore()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is no longer needed as the loop below overwrites the value of keystore.

@SomberNight
Copy link
Member

Thank you.

@SomberNight SomberNight merged commit 37904bc into spesmilo:master Feb 4, 2018
@farmerwampum farmerwampum deleted the showmultisigaddressontrezor branch December 13, 2018 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants