HomePhabricator

[electrum] add prev_tx to TxInput

Description

[electrum] add prev_tx to TxInput

Summary:
The previous transaction is needed by hardware wallets to sign a transaction. This is a weirdness in the hardware wallet libraries, probably related to BTC support.

Electrum ABC adds a "prev_tx" field to coins before attempting to sign a transaction because it may be needed in two situations:

  • when the wallet is a hardware wallet (has at least one hardware keystore), via Wallet.add_hw_info
  • when the coin is exported by a watching-only wallet whose xpub or pubkey originates from a hardware wallet (the pubkey's origin cannot be deduced from the keystore type, so it is added all the time)

The value can be initially missing when constructing a incomplete transaction, and be added later by the wallet. So remove the related assertion in TxInput.to_coin_dict

Don't add the "value" field for already complete transactions. I'm not aware of any use case for this.

Test Plan: python test_runner.py

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14510

Details

Provenance
PiRKAuthored on Sep 20 2023, 12:27
PiRKPushed on Sep 20 2023, 15:26
Reviewer
Restricted Project
Differential Revision
D14510: [electrum] add prev_tx to TxInput
Parents
rABCa6316f3726f2: [electrum] convert var_int to return bytes
Branches
Unknown
Tags
Unknown