[electrum] implement scriptSig parsing for TxInput
Summary:
This should bring TxInput to feature-parity with the existing input dicts in the case of deserialized transactions.
A couple of functions and a constant are converted to bytes, to avoid unnecessary hex decoding in the new function. All exisiting callsites for these functions are adjusted to expect bytes.
Signatures and keys are stored as bytes (can be trivially converted to hex if necessary)
Coinbase inputs have an empty list of signatures and num_sig == 0, rather than not defining the attributes.
Redundant fields are not implemented:
- "num_sig" can be trivially deduced from the number of signature
- "redeemScript" is always the same as scriptSig, as far as I can tell
- p2pk inputs don't have a pubkey or an address
For now the TxInput.parse_scriptSig method duplicates the logic in the parse_scriptSig function. Same for TxInput.get_sorted_pubkeys and Transaction.get_sorted_pubkeys. This is done intentionally, to demonstrate that the results are the same (via the added test).
The next commit will remove the old function.
Depends on D14466
Test Plan: python test_runner.py
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien, bytesofman
Differential Revision: https://reviews.bitcoinabc.org/D14458