Page MenuHomePhabricator

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

Authored by emack on Nov 18 2021, 05:56.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC511c435ffa43: [Cashtab] Add ability to send an OP return msg in a tx
Summary
  • Added a collapsible 'Advanced' section on the Send UI above the Send button that allows the user to input an optional OP_RETURN message as part of their Send XEC transaction.
  • The OP_RETURN logic in useBCH.js only executes if the user has supplied a non-empty string 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.

This diff supersedes D10363 due to commit conflicts.

Test Plan
  • npm start
  • send XEC with no message and verify no OP_RETURN output in explorer and no regression to existing send XEC transaction
  • send XEC with an empty string message (bunch of spaces) 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
  • fill out the OP_Return message but collapse the Advanced section. Click send and verify OP_RETURN message is still sent 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
  • attempt to send message with less than 5.5 XEC value input and verify the Send button is disabled
  • verify cross browser compatibility in firefox
  • npm run extension
  • retest the above in browser extension mode

Diff Detail

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

Event Timeline

emack requested review of this revision.Nov 18 2021, 05:56

One issue

If you push "enter" after entering an OP_RETURN msg, it will force reload the page with /?your_msg_here. Need to disable this submit "feature" on the <Input> component.

This revision now requires changes to proceed.Nov 18 2021, 22:08

Added frontend logic to prevent enter key from submitting the OP_RETURN message when the focus is in the OP_RETURN message input field.

Tested ok across both Chrome and Firefox browsers.

This revision is now accepted and ready to land.Nov 18 2021, 23:18