Page MenuHomePhabricator

[electrum] don't open a blocking popup when an invalid URI is pasted in the Pay To field
ClosedPublic

Authored by PiRK on Feb 5 2024, 12:30.

Details

Summary

Use a temporary (5 seconds) non-blocking popup label instead, the same one used to signal that an update is available or that the CashFusion server is not responding
This allows the user to keep editing the URI in the dialog without having to close a blocking popup dialog at each keystroke.

Depends on D15384

Test Plan

Paste a bad URI, check that there is an more discrete error popup (in the cases that previously raised a blocking popup dialog) and that you can keep editing the URI.

Test URIs:

  • duplicate parameter: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?amount=40.00&label=test&amount=30.00
  • ignored parameter: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?spam=foo
  • Bad parameter:
    • incorrect checksum in address: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymma
    • non-numeric amount: `ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?amount=deadbeef
    • non-hex op_retrun_raw: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?op_return_raw=deadbeefzz

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Feb 5 2024, 12:30
electrum/electrumabc_gui/qt/main_window.py
2902 ↗(On Diff #44961)

This name is not displayed, it is used as an ID to store a reference to the label widget. Using the same name for all popups here ensure that we don't have multiple ones showing at the same time while editing a URI.

2908 ↗(On Diff #44961)

The target is the widget next to which the label is shown.

bytesofman added a subscriber: bytesofman.

ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?amount=40.00&label=test&amount=30.00

Steps

  1. Copy paste ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?amount=40.00&label=test&amount=30.00 into the Pay to field
  2. Error pop-up shows as expected, I can keep editing
  3. If I delete &amount=30.00 -> the Pay to field rerenders to qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme (leaving "test" in the Description field and 40 in the Amount field)

Also happens if I backspace, as soon as I backspace the last t in the 2nd amount.

So -- still better behavior than what we were seeing before. But not ideal that, if the user follows the advice of the error msg here, the URI string is nuked (though its encoded tx persists in other UI elements)

ignored parameter: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?spam=foo

As soon as I copy paste ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?spam=foo into the Pay to: field, it is instantly rewritten as qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme -- I do get the error, but now I'm not really sure what it's referring to.

incorrect checksum in address: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymma

behavior for this one is great, I can keep editing it

non-numeric amount: `ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?amount=deadbeef

I can keep editing it. However, like before, I can't erase "deadbeef" and replace it with something valid like "30". If I backspace "deadbeef" and try to type "30" -- as soon as the 3 is entered, the URI is deleted, and the 3 is added to the "Amount" field. If i keep typing though, I am typing at the beginnign of the "Pay to" field.

non-hex op_retrun_raw: ecash:qrh3ethkfms79tlcw7m736t38hp9kg5f7gycxeymme?op_return_raw=deadbeefzz

Same general problem as others. If I edit the Pay to field to fix the problem, the URI disappears

In general this seems much better than current behavior even with the issues. But it is confusing in practice to actually edit the URI, and the user has no way of knowing what was copy pasted if the amount is valid.

This revision is now accepted and ready to land.Feb 5 2024, 20:58