Page MenuHomePhabricator

[electrum] move get_preimage_script from Transaction to TxInput
ClosedPublic

Authored by PiRK on Sep 18 2023, 10:54.

Details

Summary

And improve support of p2pk inputs: a pubkey can be passed but is not available from a deserialized tx, an address is not applicable. This is required to test get_preimage_script.

So far get_preimage_script had only partial test coverage for p2pkh transaction. Add coverage for p2pk and multisig p2sh.

Drop the special case for transaction type "unknown", because nothing in this codebase uses or defines txin["scriptCode"]

Add a OutPoint.from_str helper which is just used in tests for now, but can be used later for parsing JSON wallet files.

Depends on D14496

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 18 2023, 10:54
electrum/electrumabc/bitcoin.py
570 ↗(On Diff #42243)

this function had only one callsite, which is now inlined in TxInput.get_preimage_script

Fabien added inline comments.
electrum/electrumabc/transaction.py
537 ↗(On Diff #42243)

This is maybe an issue if you want to emit an slp tx (is there a plugin for that ?)

electrum/electrumabc/transaction.py
537 ↗(On Diff #42243)

I'm not aware of existing BCH plugins that still work for Electrum ABC, and I'm not aware of any SLP related plugin. The SLP edition of Electron Cash was a complete fork, not a plugin.

This revision is now accepted and ready to land.Sep 18 2023, 13:38