Page MenuHomePhabricator

[Cashtab] Do not disable amount if value from params is undefined
ClosedPublic

Authored by bytesofman on Jan 22 2024, 20:27.

Details

Summary

Cashtab can parse a tx from URL params address and value. We will deprecate this so that Cashtab parses txs from bip21 strings in the URL.

For now, some PayButton txs pass value=undefined. In this case, the amount input will be disabled.

Do not disable the amount input for this case.

Test Plan

npm test

Diff Detail

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

Event Timeline

bytesofman added inline comments.
cashtab/src/components/Send/fixtures/mocks.js
2 ↗(On Diff #44457)

need this in the mock to get into the useEffect loop being tested here

For now, some PayButton txs pass value=undefined. In this case, the amount input will be disabled.

What is the intent behind this value ? With no explanation it's hard to know if this diff is doing the right thing and what is the expected behavior.

Fabien requested changes to this revision.Jan 23 2024, 08:40
This revision now requires changes to proceed.Jan 23 2024, 08:40

For now, some PayButton txs pass value=undefined. In this case, the amount input will be disabled.

What is the intent behind this value ? With no explanation it's hard to know if this diff is doing the right thing and what is the expected behavior.

In this case, PayButton wants to open a tx with address prepopulated but amount up to the user to enter, e.g. for a donation. So, opening this tx with amount input disabled is preventing this.

Background
This address and value as URL params is how Cashtab extension (and web app) receives txs from webapps.

e.g. if you open Cashtab's send page with ?address=ecash:qp33mh3a7qq7p8yulhnvwty2uq5ynukqcvuxmvzfhm&value=500 at the end, it will load with a tx populated to send 500 XEC to that address.

Now that PayButton actually uses this feature, we are seeing real world cases which were not previously tested that are causing unexpected behavior (such as value is undefined or vallue is null).

Plan is to deprecate the value key entirely (the key is confusing, since it sets amount) and support bip21 queries, which SendXec is now set up to handle (including updates to amount and op_return_raw). However, important not to break PayButton in the meantime. I've informed their dev of the plan going forward.

This revision is now accepted and ready to land.Jan 23 2024, 15:33