Page MenuHomePhabricator

[Cashtab] [Proof of Concept] Support OP_RETURN txs from param input
AbandonedPublic

Authored by bytesofman on Dec 21 2023, 21:13.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

T3369

Support OP_RETURN outputs in payment URIs

Test Plan

npm test

Test out query strings. Note validation errors. Confirm that, if amount is set and valid as a param, the amount input is disabled. Confirm that if opreturn is set and valid as a param, the Cashtab msg is disabled and not visible.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cashtab-support-opreturn-param
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26048
Build 51670: Build Diffcashtab-tests
Build 51669: arc lint + arc unit

Event Timeline

This "works" but ended up being a bigger change than I thought. Need to review for potentially splitting up.

It's probably okay to do it in one, since the helper functions required are easy enough to unit test and those tests are included here.

Still needs some UI work to make sure fields are disabled when params are active.

Improve UI to handle presence of params

opreturn param and no amount param

image.png (854×483 px, 56 KB)

opreturn param and amount param

image.png (854×483 px, 59 KB)

invalid opreturn param

image.png (854×483 px, 51 KB)

invalid param send amount

image.png (854×483 px, 59 KB)

valid param amount that fails other validation

image.png (854×483 px, 63 KB)

still needs more work on error handling and UI validation msgs

cashtab/src/components/Airdrop/__tests__/__snapshots__/Airdrop.test.js.snap
9 ↗(On Diff #43753)

all of these changes are because Atoms.js changed, which is widely imported.

...It is annoying that these always change, and it is almost never worth reviewing them.

I don't think answer is marking them @generated though -- should review Cashtab and determine if these snapshots can simply be dropped. I don't think we've caught anything about failing components outside of maybe the home screen.

cashtab/src/components/Send/Send.js
449 ↗(On Diff #43753)

this is a pretty complicated function with many logic gates.

Potentially it could be refactored. Complication here is inevitable given what we are trying to do with the UI: support a wide variety of inputs in one screen.

  • aliases
  • addresses
  • addresses with params (now, two posssible ones, opreturn and amount, or both)
  • single addresses can also send fiat amounts
  • params does not support fiat

I think it's worth the complexity here to avoid the user complexity of having to decide which screen to select for different tx types.

868 ↗(On Diff #43753)

disable user ability to change the amount input field if there is an amount set by params

979 ↗(On Diff #43753)

disable (and hide) cashtab msg option if there is an opreturn set by params

bytesofman planned changes to this revision.EditedDec 22 2023, 00:04

hard to evaluate this all in one diff, to be split up

  • Remove snapshots that aren't adding value D15034
  • Add isValidOpreturnParam function + unit tests D15035
  • Add getOpreturnParamTargetOutput function + unit tests D15082
  • Update parseAddressForParams function + unit tests D15075
  • Implement in Send.js D15139
bytesofman retitled this revision from [Cashtab] Support OP_RETURN txs from param input to [Cashtab] [Proof of Concept] Support OP_RETURN txs from param input.Dec 22 2023, 00:04