Page MenuHomePhabricator

[Cashtab] Add ability to send an OP return msg in a tx
AbandonedPublic

Authored by emack on Oct 17 2021, 03:48.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Summary

New functionality for T1848, however may need to wait till the rate limiting issue in T1920 is resolved.

  • Added a collapsible Advanced section on the Send UI that allows the user to input an optional OP_RETURN message as part of their Send transaction.
  • The OP_RETURN logic in useBCH.js only executes if the user has supplied a message, otherwise the transaction builder simply builds the standard send/change outputs.
  • If a message was supplied, it is added as Output #0 to the transaction prior to the send/change outputs.
  • Message validation via the use of maxLength attribute, limiting the input field to 150 characters. Technically the limit is 255 chars but there have been reports of bchjs errors well under that limit, hence the nominal limit of 150 for now.
  • handleOpReturnMsgChange added to Send.js as a placeholder for more advanced operations in the future
  • New AdvancedCollapse styling added to StyledCollapse.js
Test Plan
  • npmn start
  • send XEC with no message and verify no OP_RETURN output in explorer
  • send XEC with an empty string message and verify no OP_RETURN output in explorer
  • send XEC with a message and verify OP_RETURN output in explorer
  • send XEC via the MAX amount button with a message and verify OP_RETURN output in explorer
  • send XEC with a message with the Advanced section collapsed and verify OP_RETURN message in explorer
  • attempt to send XEC with a message greater than 150 characters and verify the 151st character and beyond are cut off within the input field
  • send XEC with a message containing symbols or spaces, and verify OP_RETURN output in explorer
  • attempt to send message with no XEC value input and verify the Send button is disabled
  • npm run extension
  • retest the above in browser extension mode

Diff Detail

Repository
rABC Bitcoin ABC
Branch
opreturnmsg
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 17151
Build 34133: Build Diffcashtab-tests
Build 34132: arc lint + arc unit

Event Timeline

emack requested review of this revision.Oct 17 2021, 03:48

Will probably have some more changes, need to patch tx parsing in general to fix case of erroring on received txs with blank string '' op_return msg

web/cashtab/src/hooks/useBCH.js
947 ↗(On Diff #30590)
  • Always use strict operators in Cashtab, i.e. !== and not !=
  • We should also check for the case of a user typing a msg and then deleting the string. For this case, we don't want to send an OP_RETURN msg with a blank string. So the condition check should be
if (typeof optionalOpReturnMsg !== 'undefined' && optionalOpReturnMsg !== '') {}
This revision now requires changes to proceed.Oct 18 2021, 21:16

Updated to check for blank string messages - tested ok on both normal op return string and empty strings. Empty strings no longer results in OP_RETURN outputs. Also changed to use strict operators.

Merge with formatting changes from prettier upgrade

Looking good. I'm not able to repeat the null error from before. OP_RETURN utxos are accepted and recognized as XEC utxos.

I think we should add OP_RETURN parsing to tx history before rolling this out, so users can see what it does and means.

Please prepare that in a separate diff (or stacked diff on this one), so we can put them into prod at the same-ish time.

This revision now requires changes to proceed.Oct 28 2021, 22:42

Updated to add 621 identifier for OP_RETURN message outputs and adjusted useBCH to ignore empty string OP_RETURN messages from the UI