Page MenuHomePhabricator

[electrum] add prev_tx to TxInput
ClosedPublic

Authored by PiRK on Sep 20 2023, 12:36.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC0f414650168d: [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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Sep 20 2023, 12:36

fix docstring for tests

no need to add the input value for complete transactions (this is only needed for signing)

PiRK planned changes to this revision.Sep 20 2023, 12:48
PiRK edited the summary of this revision. (Show Details)

don't add "value" when the input is complete, don't assert value is not None for incomplete TxInput (it can be constructed like this initially and the value can be added later by the wallet), add a test for the different behavior between complete transactions and incomplete transactions

fix the test name (the scope is larger than hardware wallets), no need to pop "value" if not specified

This revision is now accepted and ready to land.Sep 20 2023, 14:26
This revision was automatically updated to reflect the committed changes.