HomePhabricator

[Cashtab] Implement standardized eCash prefixes in OP_RETURN transactions

Description

[Cashtab] Implement standardized eCash prefixes in OP_RETURN transactions

Summary:

  • As per T1967, this diff upgrades the OP_RETURN message logic to propose a Cashtab prefix for messages sent from Cashtab, in addition to the existing prefix which differentiates message transactions from eToken transactions.
  • The parsing logic is also updated to delineate between a Cashtab generated message vs an externally generated message (e.g. electrum) in transaction history.

When sending OP_RETURN messages from within Cashtab, the following script is proposed (see useBCH.js)

OP_RETURN opcode
[Protocol ID] + [Transaction Type]
[Message] - the message content

The following prefix hex codes are proposed in this diff and will be added to an eCash specific prefix standard separately:

opReturn: {
    opReturnPrefixHex: '6a',
    opReturnPushDataHex: '04',
    opReturnAppPrefixLengthHex: '04',
    appPrefixesHex: {
        eToken: '534c5000',
        cashtab: '00746162',
    },
},

When parsing OP_RETURN messages, the parseTxData() logic in useBCH.js is now updated as follows:

  • checks whether an output contains addresses, if not, assume its either a message or eToken tx
  • if the output's hex property contains the eToken prefix, then apply eToken logic
  • if the output's hex property contains the cashtab message prefix, then apply cashtab message rendering logic
  • else, assume it is an external message e.g. from electrum and apply external message rendering logic

image.png (463×495 px, 35 KB)

Test Plan:

  • npm start
  • send message from within Cashtab and ensure it is reflected with props.theme.primary styling in tx history across both receiving and sending wallets
  • send message from within Electrum and ensure it is reflected with props.theme.secondary styling in tx history across both receiving and sending wallets
  • test cross browser compatibility in firefox
  • npm run extension
  • verify display in extension mode

Reviewers: bytesofman, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

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

Details

Provenance
emackAuthored on Nov 20 2021, 01:07
emackPushed on Nov 28 2021, 22:15
Reviewer
Restricted Project
Differential Revision
D10494: [Cashtab] Implement standardized eCash prefixes in OP_RETURN transactions
Parents
rABC924e2afc6c2e: Support NODE_NETWORK_LIMITED filtering by default
Branches
Unknown
Tags
Unknown