Browse Source

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)
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
parent
commit
4e6cc93746
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/plugins/coldcard/coldcard.py
  2. 3
      electrum/plugins/coldcard/qt.py

12
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

3
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):

Loading…
Cancel
Save