HomePhabricator

[electrum] fix handling of unsupported p2sh scripts in the TransactionDialog

Description

[electrum] fix handling of unsupported p2sh scripts in the TransactionDialog

Summary:
Fix support for "unsupported" p2sh schemes. This codebase claims to not make any particular effort to support parsing of p2sh scripts besides standard multisig, but we still don't want the application to crash or show an error message when users paste an externally generated valid hex transaction.

This was likeky broken in the recent major Transaction refactoring. The problem is that TxInput.type can be undefined (None) in some cases, and the TxInput.to_coin_dict function expects it to be always defined.

Cleanup the TxInput.to_coin_dict function slightly: parse_scriptsig function no longer raises (at least intentionnaly, if it does it is a bug that needs to be fixed), so those few lines of code were unreachable. Now that we set txin.type = ScriptType.unknown in parse_scriptsig, we can use this to detect the case of unsupported p2sh.

Test Plan:

python test_runner.py

Menu Tools > Load Transaction > From text
Check that there is no error message when pasting the transactions from the new tests, and the transaction dialog shows useful data and allows broadcasting the tx (it will fail with a "Transaction already in block chain" message for these particular transactions).

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
PiRKAuthored on Mon, Jul 1, 08:42
PiRKPushed on Tue, Jul 2, 11:03
Reviewer
Restricted Project
Differential Revision
D16391: [electrum] fix handling of unsupported p2sh scripts in the TransactionDialog
Parents
rABC767729f0bef1: [rpc] return effective-includes in testmempoolaccept and submitpackage
Branches
Unknown
Tags
Unknown