diff --git a/contrib/requirements/requirements-hw.txt b/contrib/requirements/requirements-hw.txt index bf9c11f6e..78260336b 100644 --- a/contrib/requirements/requirements-hw.txt +++ b/contrib/requirements/requirements-hw.txt @@ -13,5 +13,5 @@ safet>=0.1.5 keepkey>=6.3.1 btchip-python>=0.1.26 ckcc-protocol>=0.7.7 -bitbox02>=2.0.2 +bitbox02>=3.0.0 hidapi diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py index 87089e4db..ce7c40119 100644 --- a/electrum/plugins/bitbox02/bitbox02.py +++ b/electrum/plugins/bitbox02/bitbox02.py @@ -364,6 +364,32 @@ class BitBox02Client(HardwareClientBase): "A wallet owned pubkey was not found in the transaction input to be signed" ) + prev_tx = wallet.db.get_transaction(txin.prevout.txid.hex()) + if prev_tx is None: + raise Exception( + "Could not find transaction {} in db".format(txin.prevout.txid.hex()), + ) + + + prev_inputs: List[bitbox02.BTCPrevTxInputType] = [] + prev_outputs: List[bitbox02.BTCPrevTxOutputType] = [] + for prev_txin in prev_tx.inputs(): + prev_inputs.append( + { + "prev_out_hash": prev_txin.prevout.txid[::-1], + "prev_out_index": prev_txin.prevout.out_idx, + "signature_script": prev_txin.script_sig, + "sequence": prev_txin.nsequence, + } + ) + for prev_txout in prev_tx.outputs(): + prev_outputs.append( + { + "value": prev_txout.value, + "pubkey_script": prev_txout.scriptpubkey, + } + ) + inputs.append( { "prev_out_hash": txin.prevout.txid[::-1], @@ -371,6 +397,12 @@ class BitBox02Client(HardwareClientBase): "prev_out_value": txin.value_sats(), "sequence": txin.nsequence, "keypath": full_path, + "prev_tx": { + "version": prev_tx.version, + "locktime": prev_tx.locktime, + "inputs": prev_inputs, + "outputs": prev_outputs, + }, } ) @@ -536,7 +568,7 @@ class BitBox02_KeyStore(Hardware_KeyStore): class BitBox02Plugin(HW_PluginBase): keystore_class = BitBox02_KeyStore - minimum_library = (2, 0, 2) + minimum_library = (3, 0, 0) DEVICE_IDS = [(0x03EB, 0x2403)] SUPPORTED_XTYPES = ("p2wpkh-p2sh", "p2wpkh", "p2wsh")