Page MenuHomePhabricator

[Cashtab] Suppport a custom bip21 implementation in Cashtab to enable FIRMA-USDT redemptions
ClosedPublic

Authored by bytesofman on May 13 2025, 23:50.

Details

Summary

Introduce new Cashtab-specific temporary spec allowing an additional empp push to be specified in bip21 token sends (ALP only). Implement and test in Cashtab.

The use case we are solving for here is including arbitrary message data in a token transaction. This is important in cryptocurrency for onchain annotation of payments, or allowing a token payment to interact with an app.

The Cashtab use case is quite niche, supporting only one data push. In the future, we will create a more generic spec. However in order to do this properly, we should first iron out the communication interface being worked on in D17822

This implementation covers an MVP use case: including a Solana address in a FIRMA payment to allow onchain redemption of Firma for USDT on the SOL network.

In this diff,

  • We modify the Send screen in Cashtab to support empp_raw in bip21 codes, either by entering a bip21 string into the "Address" field or by including a bip21 query string in the URL
  • We modify Cashtab-specific ALP output construction to optionally support a single additional user-specified output
  • We modify tx parsing to parse for this in ALP txs
  • We define a spec for encoding a SOL address in an EMPP push, and implement parsing this app action in Cashtab
Test Plan

npm test

Can check it out at the test site: https://cashtab-local-dev.netlify.app/

e.g. go to https://cashtab-local-dev.netlify.app/#/send?bip21=ecash:qr8hdk8rxjc5nj6f450eth3nnslxa8k4gysrtyfxc5?token_id=0387947fd575db4fb19a3e322f635dec37fd192b5941625b66bc4b2c3008cbf0&token_decimalized_qty=1&empp_raw=534f4c304ebabba2b443691c1a9180426004d5fd3419e9f9c64e5839b853cecdaacbf745 and see this

image.png (445×1 px, 49 KB)

Parsed tx in history:

image.png (299×1 px, 29 KB)

Diff Detail

Repository
rABC Bitcoin ABC
Branch
spec-empp-bip21-msg
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33411
Build 66301: Build Diffcashtab-tests
Build 66300: arc lint + arc unit

Event Timeline

update b58-ts deps, comment cleanup

bytesofman edited the summary of this revision. (Show Details)

Failed tests logs:

====== CashTab Unit Tests: <SendXec /> rendered with params in URL bip21 - ALP token send with empp_raw ======
Error: expect(element).toBeInTheDocument()

element could not be found in the document
    at Object.toBeInTheDocument (/work/cashtab/src/components/Send/__tests__/SendByUrlParams.test.js:1006:57)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at processTimers (node:internal/timers:519:7)
====== CashTab Unit Tests: <SendXec /> rendered with params in URL bip21 - valid FIRMA-USDT redeem tx ======
Error: expect(element).toBeInTheDocument()

element could not be found in the document
    at Object.toBeInTheDocument (/work/cashtab/src/components/Send/__tests__/SendByUrlParams.test.js:1110:57)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at processTimers (node:internal/timers:519:7)
====== CashTab Unit Tests: <SendXec /> We can parse a valid FIRMA-USDT redeem tx from bip21 and broadcast the tx ======
Error: expect(element).toBeInTheDocument()

element could not be found in the document
    at Object.toBeInTheDocument (/work/cashtab/src/components/Send/__tests__/SendXec.test.js:1885:57)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at processTimers (node:internal/timers:519:7)

Each failure log is accessible here:
CashTab Unit Tests: <SendXec /> rendered with params in URL bip21 - ALP token send with empp_raw
CashTab Unit Tests: <SendXec /> rendered with params in URL bip21 - valid FIRMA-USDT redeem tx
CashTab Unit Tests: <SendXec /> We can parse a valid FIRMA-USDT redeem tx from bip21 and broadcast the tx

update tests for header rebase

back out bip21 spec changes

bytesofman retitled this revision from [Cashtab, doc] Suppport empp raw push addition for bip21 and ALP sends to [Cashtab] Suppport a custom bip21 implementation in Cashtab to enable FIRMA-USDT redemptions.May 22 2025, 18:04
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)

Cool use case, this way ALP can also carry a shorter message like sending xec, we can emphasize this point in the etoken creation instructions. Not related to this diff.

cashtab/src/opreturn/index.ts
214 ↗(On Diff #54121)

Cool use case, this way ALP can also carry a shorter message like sending xec, we can emphasize this point in the etoken creation page. Not related to this diff.

Fabien added inline comments.
cashtab/src/validation/index.ts
551 ↗(On Diff #54121)

Nothing wrong but did really need a constant for how many hex chars there is in a byte ? I mean it's unlikely to change anytime soon and I expect people that can read code to know that and guess what the 2 is here

Fabien requested changes to this revision.May 23 2025, 12:58

I don't think empp_raw is a good name for this.
This diff adds a very custom protocol extension that is FIRMA specific, and will very likely be updated soon. The name should convey the idea that it is a custom protocol and should not be relied upon by any third party, I simply suggest using &firma= here.

This revision now requires changes to proceed.May 23 2025, 12:58

use app-specific "firma" as param rather than generic empp_raw

parse firma redeem fee in tx builder window

Fabien requested changes to this revision.May 23 2025, 13:38
Fabien added inline comments.
cashtab/src/components/Send/SendXec.tsx
41 ↗(On Diff #54140)
271 ↗(On Diff #54140)
707–720 ↗(On Diff #54140)
1023 ↗(On Diff #54140)
1579–1580 ↗(On Diff #54140)
1583 ↗(On Diff #54140)
1613–1615 ↗(On Diff #54140)
cashtab/src/constants/tokens.ts
28 ↗(On Diff #54140)

This one is actually still OK

cashtab/src/opreturn/__tests__/index.test.js
11 ↗(On Diff #54140)
131–141 ↗(On Diff #54140)
cashtab/src/opreturn/fixtures/vectors.js
427 ↗(On Diff #54140)
431 ↗(On Diff #54140)
441 ↗(On Diff #54140)
461 ↗(On Diff #54140)
470 ↗(On Diff #54140)
cashtab/src/opreturn/index.ts
211–250 ↗(On Diff #54140)
cashtab/src/token-protocols/alp/__tests__/index.test.ts
76–85 ↗(On Diff #54140)
cashtab/src/token-protocols/alp/fixtures/vectors.ts
72 ↗(On Diff #54140)
344 ↗(On Diff #54140)
386 ↗(On Diff #54140)
429 ↗(On Diff #54140)
cashtab/src/token-protocols/alp/index.ts
108–131 ↗(On Diff #54140)
cashtab/src/validation/__tests__/index.test.js
484–492 ↗(On Diff #54140)
cashtab/src/validation/fixtures/vectors.js
31 ↗(On Diff #54140)

remove

cashtab/src/validation/index.ts
539 ↗(On Diff #54140)
748–763 ↗(On Diff #54140)
This revision now requires changes to proceed.May 23 2025, 13:38
bytesofman marked 26 inline comments as done.

more naming, lint

This revision is now accepted and ready to land.May 23 2025, 14:12