From 4e6cc937464cf7936571eee4f3de0c85bd350023 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 12 Sep 2019 16:33:17 +0200 Subject: [PATCH] coldcard: do link_wallet in load_wallet hook instead make_unsigned_transaction might not run in some code paths (e.g. when user uses "Load transaction" UI function) --- electrum/plugins/coldcard/coldcard.py | 12 +++++++++--- electrum/plugins/coldcard/qt.py | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/electrum/plugins/coldcard/coldcard.py b/electrum/plugins/coldcard/coldcard.py index 203f88f4c..8f08a4d14 100644 --- a/electrum/plugins/coldcard/coldcard.py +++ b/electrum/plugins/coldcard/coldcard.py @@ -251,7 +251,7 @@ class Coldcard_KeyStore(Hardware_KeyStore): self.ux_busy = False # for multisig I need to know what wallet this keystore is part of - # this is captured by hooling make_unsigned_transaction + # will be set by link_wallet self.my_wallet = None # Seems like only the derivation path and resulting **derived** xpub is stored in @@ -660,14 +660,20 @@ class ColdcardPlugin(HW_PluginBase): def link_wallet(cls, wallet): # PROBLEM: wallet.sign_transaction() does not pass in the wallet to the individual # keystores, and we need to know about our co-signers at that time. + # FIXME the keystore needs a reference to the wallet object because + # it constructs a PSBT from an electrum tx object inside keystore.sign_transaction. + # instead keystore.sign_transaction's API should be changed such that its input + # *is* a PSBT and not an electrum tx object for ks in wallet.get_keystores(): if type(ks) == Coldcard_KeyStore: if not ks.my_wallet: ks.my_wallet = wallet @hook - def make_unsigned_transaction(self, wallet, tx): - # - capture wallet containing each keystore early in the process + def load_wallet(self, wallet, window): + # make sure hook in superclass also runs: + if hasattr(super(), 'load_wallet'): + super().load_wallet(wallet, window) self.link_wallet(wallet) # EOF diff --git a/electrum/plugins/coldcard/qt.py b/electrum/plugins/coldcard/qt.py index 294c89f5b..a29d23122 100644 --- a/electrum/plugins/coldcard/qt.py +++ b/electrum/plugins/coldcard/qt.py @@ -214,9 +214,6 @@ class Plugin(ColdcardPlugin, QtPluginBase): else: desc = _("Combined from %d PSBT files") % len(psbts) - # need to associated our pluging to this wallet - ColdcardPlugin.link_wallet(wallet) - window.show_transaction(tx, desc) class Coldcard_Handler(QtHandlerBase):