diff --git a/electrum/plugins/coldcard/basic_psbt.py b/electrum/plugins/coldcard/basic_psbt.py index d220fad6b..c21f692e5 100644 --- a/electrum/plugins/coldcard/basic_psbt.py +++ b/electrum/plugins/coldcard/basic_psbt.py @@ -4,7 +4,8 @@ # - history: taken from coldcard-firmware/testing/psbt.py # - trying to minimize electrum code in here, and generally, dependancies. # -import io, struct +import io +import struct from base64 import b64decode from binascii import a2b_hex, b2a_hex from struct import pack, unpack diff --git a/electrum/plugins/coldcard/build_psbt.py b/electrum/plugins/coldcard/build_psbt.py index 2c03907ad..796f91e0f 100644 --- a/electrum/plugins/coldcard/build_psbt.py +++ b/electrum/plugins/coldcard/build_psbt.py @@ -1,20 +1,21 @@ # # build_psbt.py - create a PSBT from (unsigned) transaction and keystore data. # -import io, struct -from base64 import b64decode +import io +import struct from binascii import a2b_hex, b2a_hex from struct import pack, unpack from electrum.transaction import (Transaction, multisig_script, parse_redeemScript_multisig, - NotRecognizedRedeemScript) + NotRecognizedRedeemScript) from electrum.logging import get_logger -from electrum.wallet import Standard_Wallet, Multisig_Wallet, Wallet +from electrum.wallet import Standard_Wallet, Multisig_Wallet, Abstract_Wallet from electrum.keystore import xpubkey_to_pubkey, Xpub from electrum.util import bfh, bh2u from electrum.crypto import hash_160, sha256 from electrum.bitcoin import DecodeBase58Check +from electrum.i18n import _ from .basic_psbt import ( PSBT_GLOBAL_UNSIGNED_TX, PSBT_GLOBAL_XPUB, PSBT_IN_NON_WITNESS_UTXO, PSBT_IN_WITNESS_UTXO, @@ -23,12 +24,6 @@ from .basic_psbt import ( PSBT_OUT_REDEEM_SCRIPT, PSBT_OUT_WITNESS_SCRIPT) from .basic_psbt import BasicPSBT -from electrum.logging import get_logger -from electrum.wallet import Standard_Wallet, Multisig_Wallet, Wallet -from electrum.util import bfh, bh2u -from electrum.crypto import hash_160 -from electrum.bitcoin import DecodeBase58Check - _logger = get_logger(__name__) @@ -131,7 +126,7 @@ def my_var_int(l): else: return pack(" Transaction: +def recover_tx_from_psbt(first: BasicPSBT, wallet: Abstract_Wallet) -> Transaction: # Take a PSBT object and re-construct the Electrum transaction object. # - does not include signatures, see merge_sigs_from_psbt # - any PSBT in the group could be used for this purpose; all must share tx details diff --git a/electrum/plugins/coldcard/coldcard.py b/electrum/plugins/coldcard/coldcard.py index 4b37660ad..203f88f4c 100644 --- a/electrum/plugins/coldcard/coldcard.py +++ b/electrum/plugins/coldcard/coldcard.py @@ -11,12 +11,10 @@ from electrum.i18n import _ from electrum.plugin import Device, hook from electrum.keystore import Hardware_KeyStore from electrum.transaction import Transaction, multisig_script -from electrum.wallet import Standard_Wallet, Multisig_Wallet, Wallet -from electrum.crypto import hash_160 +from electrum.wallet import Standard_Wallet, Multisig_Wallet from electrum.util import bfh, bh2u, versiontuple, UserFacingException from electrum.base_wizard import ScriptTypeNotSupported from electrum.logging import get_logger -from electrum.bitcoin import DecodeBase58Check from ..hw_wallet import HW_PluginBase from ..hw_wallet.plugin import LibraryFoundButUnusable, only_hook_if_libraries_available @@ -34,10 +32,6 @@ try: from ckcc.protocol import CCProtoError, CCUserRefused, CCBusyError from ckcc.constants import (MAX_MSG_LEN, MAX_BLK_LEN, MSG_SIGNING_MAX_LENGTH, MAX_TXN_LEN, AF_CLASSIC, AF_P2SH, AF_P2WPKH, AF_P2WSH, AF_P2WPKH_P2SH, AF_P2WSH_P2SH) - #from ckcc.constants import ( - #PSBT_GLOBAL_UNSIGNED_TX, PSBT_GLOBAL_XPUB, PSBT_IN_NON_WITNESS_UTXO, PSBT_IN_WITNESS_UTXO, - #PSBT_IN_SIGHASH_TYPE, PSBT_IN_REDEEM_SCRIPT, PSBT_IN_WITNESS_SCRIPT, - #PSBT_IN_BIP32_DERIVATION, PSBT_OUT_BIP32_DERIVATION, PSBT_OUT_REDEEM_SCRIPT) from ckcc.client import ColdcardDevice, COINKITE_VID, CKCC_PID, CKCC_SIMULATOR_PATH @@ -388,12 +382,6 @@ class Coldcard_KeyStore(Hardware_KeyStore): client = self.get_client() - if 0: - from pprint import pprint - for n,i in enumerate(tx.inputs()): - print('[%d]: ' % n, end='') - pprint(i) - assert client.dev.master_fingerprint == self.ckcc_xfp # makes PSBT required diff --git a/electrum/plugins/hw_wallet/qt.py b/electrum/plugins/hw_wallet/qt.py index b348c7adc..44c8e41a1 100644 --- a/electrum/plugins/hw_wallet/qt.py +++ b/electrum/plugins/hw_wallet/qt.py @@ -265,4 +265,5 @@ class QtPluginBase(object): else: addr = uri.get('address') keystore.thread.add(partial(plugin.show_address, wallet, addr, keystore)) - receive_address_e.addButton("eye1.png", show_address, _("Show on {}").format(keystore.label)) + dev_name = f"{plugin.device} ({keystore.label})" + receive_address_e.addButton("eye1.png", show_address, _("Show on {}").format(dev_name))