Page MenuHomePhabricator

[Cashtab] Allow user to receive specified amount of XEC or FIRMA on Receive page
Needs ReviewPublic

Authored by bytesofman on Wed, May 7, 14:00.

Details

Reviewers
Fabien
emack
Group Reviewers
Restricted Project
Summary

Cashtab send screen supports bip21 query strings. We should allow users to make their own to support point of sale use case.

This is a first pass, where we support custom XEC or FIRMA amounts.

It can be extended to support arbitary token quantities or other bip21.

new receive screen:

image.png (627×508 px, 27 KB)

Test Plan

npm test

deployed live at test site, check at https://cashtab-local-dev.netlify.app/#/receive

Diff Detail

Repository
rABC Bitcoin ABC
Branch
bip21-qr-codes
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33237
Build 65957: Build Diffcashtab-tests
Build 65956: arc lint + arc unit

Event Timeline

bytesofman published this revision for review.Wed, May 7, 17:19
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)
Fabien requested changes to this revision.Thu, May 8, 10:13
Fabien added a subscriber: Fabien.

@bot preview-cashtab

cashtab/src/components/Common/Buttons.tsx
162 ↗(On Diff #53895)

? why would you want a boolean to be nullable ?

cashtab/src/components/Receive/Receive.tsx
1 ↗(On Diff #53895)

Macro whatyearisit:

This revision now requires changes to proceed.Thu, May 8, 10:13

Can we have the unit in the amount input field ? IMO it avoids confusion better than the icon only, and 10 XEC is very different from 10 FIRMA

emack requested changes to this revision.Thu, May 8, 12:51
emack added a subscriber: emack.

If you input a large enough number Cashtab crashes with a WSOD and spits out a range error on console. Not a big issue but rather unsightly. The other send amount inputs throughout the app gracefully spits out a Unable to parse sendAmount as a number UI error instead of sharting.

image.png (413×640 px, 39 KB)

cashtab/src/components/Receive/QRCode.tsx
123 ↗(On Diff #53895)

what if address is neither bip21, nor token nor addressOnly types? Is the validation being done elsewhere?

bytesofman added inline comments.
cashtab/src/components/Common/Buttons.tsx
162 ↗(On Diff #53895)

it wouldn't really make sense for the user to specify false, tho they could. In this case it's because bool is the most effective type for the purpose of this param, but we want it to default to false. So in practice, the user --- in this case, a react dev on Cashtab -- either specifies showToast or does not. If it is unspecified, the component defaults to false below.

It's a common react convention. In this way, you can specify <CopyIconButton showToast/> and you will get this as true, no need for showToast={true}

cashtab/src/components/Receive/QRCode.tsx
123 ↗(On Diff #53895)

the only user-input field is quantity, which is validated (must be a number, only 1 decimal place, decimal place must be '.', etc)

The string itself is built programmatically in the component. So, right now, the only possible options are bip21 firma token + qty and bip21 xec address (optional qty).

It probably is possible to get isBip21 as true with bad input in the field. But in this case, it just means the user display would be bip21 query string copied to clipboard instead of the much longer actual string. imo it's ok to copy paste "bad" strings like this ... I guess we could disable it on validation error. But Cashtab and electrum already validate bip21 strings, so would see it there.

bytesofman marked 2 inline comments as done.

fix year in header for Receive