Page MenuHomePhabricator

[Cashtab] Remove legacy prefix validation functions
ClosedPublic

Authored by bytesofman on Dec 30 2021, 13:24.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC577915a3bbee: [Cashtab] Remove legacy prefix validation functions
Summary

T2099

Cashtab address validation developed incrementally supporting use cases specific to the migration from bitcoincash: address formats to ecash: address formats.

After improved address validation was added in D10687, some legacy validation functions that worked by checking prefixes were no longer relevant.

This diff removes these functions.

In ScanQR.js, these functions are replaced by their successor functions that validate the full address, prefix or not.

QRCode.js should have never used these functions. It has been refactored to accept address type as a prop. The switch in Wallet.js has also been refactored to work as a boolean instead of different string types.

Test Plan

npm start

  1. Scan a valid XEC address and see that it populates the address field
  2. Scan a valid eToken address and see that it populates the address field
  3. Scan a valid prefixless XEC address and see that it populates the address field
  4. Scan a valid prefixless eToken address and see that it populates the address field
  5. Scan any QR code that is not a valid address and note that form is not populated
  6. Toggle quickly between 'XEC' and 'eToken' switch below QR code on main page. Test that it switches. Test copy pasting is functional.

Diff Detail

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

Event Timeline

emack requested changes to this revision.Dec 31 2021, 05:06
emack added a subscriber: emack.

Tested all ok across iOS and Android devices with the exception of an edge but reproducible issue.

If you scan a QR code of an invalid address, the scanner will no longer scan any other valid addresses afterwards until you close the scanner and open it again. This is also reproducible in prod so it is a legacy issue but would be annoying for users since there is no prompt indicating an invalid scan, leading the user to keep trying to move their camera in and out to scan.

I've hosted this patch on 1287.netlify.app for mobile testing.

web/cashtab/src/components/Common/ScanQRCode.js
103 ↗(On Diff #31589)

may need an else block if parseContent returned an undefined value when scanning invalid QR codes. Not sure if the lack of return teardownCodeReader() when invalid QR code is read contributes to the edge case mentioned above.

This revision now requires changes to proceed.Dec 31 2021, 05:06

Change scanning logic to

(1) Continually scan even when invalid values are found
(2) Error notification including invalid scanned value so user knows what is going on

This revision is now accepted and ready to land.Jan 4 2022, 07:25