HomePhabricator

[electrum] fix BIP 21 URI handling

Description

[electrum] fix BIP 21 URI handling

Summary:
Commit https://github.com/Bitcoin-ABC/ElectrumABC/pull/31/commits/00cb0b018f6edbc6a4e6f2d22ddbd509e5c8681e broke the URI handling.

When the application is called with a URI as a first positional argument, it should start a GUI with the send tab pre-filled with the correct information. Unfortunately argparse does not provide a good way to default to a subparser when the provided command line argument is not one of the explicitely specified command. The previous fix was hacky because it relied on monkey-patching private variables in argparse, which could break in any new python release. So reverting the commit is not a good idea IMO.

Manually insert the gui command before the URI when the first argument is a URI.
Note that this is incompatible with using any global argument, but the scope of this diff is to fix mimetype association only, and in this case the URI will be the only argument.

More advanced use cases require to properly specify the gui command on the command line: ./electrum-abc --dir /path/to/data gui <URI>

Depends on D14382

Test Plan:
./test_runner.py

./electrum-abc "ecash:qz4eqgk9fqs3uxxt2xwx0jpfj704e2t6rs7357tn7e?amount=1337.06&label=Donation to toto&op_return=Thx for running this service!"

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien, bytesofman

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

Details

Provenance
PiRKAuthored on Aug 17 2023, 09:24
PiRKPushed on Aug 20 2023, 16:30
Reviewer
Restricted Project
Differential Revision
D14383: [electrum] fix BIP 21 URI handling
Parents
rABCb5a49c46dc7d: [chronik] Keep required Rust version in one place
Branches
Unknown
Tags
Unknown