HomePhabricator

[Cashtab] [OP_RETURN msg upgrade] - Pt1 - Use bytecount for unencrypted messages

Description

[Cashtab] [OP_RETURN msg upgrade] - Pt1 - Use bytecount for unencrypted messages

Summary:
T3100

This diff updates the Send.js screen to enforce the unencrypted OP_RETURN message limit via byte size rather than char size. This utilizes the maximum OP_RETURN limit (OP_RETURN uses bytesize) and increases unencrypted message length to 215 bytes.

Fee calculation logic is also updated in this diff to take into account OP_RETURN bytesize. This could not be split into a separate diff otherwise the new bytesize parsed OP_RETURN txs will be rejected by bitcoind on account of incorrect tx fee.

The fee calc logic for token creation will be addressed in the next diff to avoid bloating this diff. It is expected to not work in this particular diff given changes to calcFee.

Updated Unit tests for getMessageByteSize, calcFee and generateTxInput.

Note: Subsequent diffs planned in this stack:

  • [Cashtab] [OP_RETURN msg upgrade] - Pt2 - Use bytecount for unencrypted airdrop messages
  • [Cashtab] [OP_RETURN msg upgrade] - Pt3 - Use bytecount for encrypted messages

Test Plan:

  • npm start and navigate to the Send screen
  • Fill in valid address, amount and attempt to send an unencrypted message more than 215 bytes and ensure the Message byte size can not exceed 215 bytes error is displayed, with the Send button disabled
  • Delete the msg from above, leaving the address and amount intact, and ensure the Send button is enabled again. Send it, and note the reduced tx fee via explorer.
  • Fill in valid address, amount and attempt to send an unencrypted message less than or equal to 215 bytes. Ensure no byte size validation errors and successful broadcast of Send XEC tx. Sanity check fee on explorer, ensure the tx fee reflects the bytesize (i.e. txs with larger messages will have larger tx fees compared to txs with smaller messages).
  • Test unencrypted message with a mixture of emoji+chars, all emojis, special chars and ensure successful broadcast and tx on explorer checks out.
  • Test a one to many XEC tx with no message and ensure successful broadcast
  • Test unencrypted message on a one to many XEC tx and ensure successful broadcast

Reviewers: bytesofman, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D13729

Details

Provenance
emackAuthored on Apr 16 2023, 02:26
emackPushed on May 2 2023, 03:51
Reviewer
Restricted Project
Differential Revision
D13729: [Cashtab] [OP_RETURN msg upgrade] - Pt1 - Use bytecount for unencrypted messages
Parents
rABC8841ff3a40d4: [e.cash] Stealth theme video speed
Branches
Unknown
Tags
Unknown