Page MenuHomePhabricator

[electrum] move Transaction.serialize_input to TxInput.serialize
ClosedPublic

Authored by PiRK on Sep 19 2023, 06:48.

Details

Summary

This change lets us remove 3 Transaction methods that operate purely on inputs, and simplify Transaction.serialize.

There is a small difference in logic/design between the legacy coin dict and the TxInput class, regarding how to determine if the amount is to be appended to the serialized transaction for offline signing.
In the legacy coin dict, the scriptsig entry was deleted from the dict if the input is not complete (see d.pop("scriptSig", None) in TxInput.to_coin_dict)), whereas in the TxInput object the scriptsig may still defined if the object is constructed via TxInput.from_scriptsig, so we check for self.is_complete() instead of self.scriptsig is not None.

Depends on D14500

Test Plan

python test_runner.py

Diff Detail

Event Timeline

PiRK requested review of this revision.Sep 19 2023, 06:48
Fabien added a subscriber: Fabien.
Fabien added inline comments.
electrum/electrumabc/transaction.py
604 ↗(On Diff #42255)

misplaced

This revision is now accepted and ready to land.Sep 19 2023, 07:30

remove misplaced comment, make the related code more readable (and twice as fast) with int.to_bytes