Page MenuHomePhabricator

[Cashtab] Airdrop OP_RETURN patch
ClosedPublic

Authored by emack on Jun 21 2022, 04:17.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC081894925993: [Cashtab] Airdrop OP_RETURN patch
Summary
  • As per T2512, this diff embeds the airdrop token id into the message portion of the OP_RETURN output, rather than being its own hex'ed portion of the OP_RETURN script array.
  • sendXec() OP_RETURN script logic now appends the token id to the message string
  • parsedTxHistory() extracts the token id from the message substring and the remainder becomes the message content itself
  • Adjusted mockTxDataWithPassthrough and mockParsedTx to reflect this updated OP_RETURN parsing logic
Test Plan
  • npm start
  • send airdrop with a message and observe only the message is displayed and verify full output hex in explorer is correct
  • ensure message is displayed correctly from an airdrop recipient wallet
  • send airdrop with no message and ensure no message is displayed and verify full output hex in explorer is correct
  • regression test the Msg button to copy the message content to clipboard
  • regression test an OP_RETURN message from electrumABC and ensure it's rendered as an external message
  • regression test a non-airdrop one to one XEC tx
  • regression test a non-airdrop one to many XEC tx
  • regression test an encrypted XEC message and verify correct output hex
  • regression test an eToken tx

Diff Detail

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

Event Timeline

emack requested review of this revision.Jun 21 2022, 04:17

Here's an example tx of what we are trying to model: https://blockchair.com/ecash/transaction/841975c2e144fc3b13e71100872fb0966690b7b171933bfee3dab3b457ea7d48

This is from a blockchain notary service that saved the hash of a file to the blockchain. You can see this tx described in this article: https://news.bitcoin.com/anchor-a-document-or-file-to-the-bch-chain-with-notary-bitcoin-com/

Here's the tx on a block explorer:
https://blockchair.com/ecash/transaction/841975c2e144fc3b13e71100872fb0966690b7b171933bfee3dab3b457ea7d48

Here's the op_return output of this tx:
https://rest.kingbch.com/v4/electrumx/tx/data/841975c2e144fc3b13e71100872fb0966690b7b171933bfee3dab3b457ea7d48

You can see that the document hash is readable directly in the OP_RETURN output, and not hex encoded.

Document hash: 3dcf300280f02d2f6daf715910d4dbe1644829c2d40644110c86bec3957a2fc1

tx data:

{"success":true,"details":{"blockhash":"000000000000000001dd7bf636a9b54d898ae6db2d77a5ee7e0f43c6a51f7a6c","blocktime":1558201722,"confirmations":161845,"hash":"841975c2e144fc3b13e71100872fb0966690b7b171933bfee3dab3b457ea7d48","hex":"0200000001aaa062980d0342e2fdf7ea3bd251d0389a23601ad3d1dbdf4255f7ee23f47aed000000006a47304402206e322854de25c336f68b558ec5fbbecadd23de97e9f0a9fca7dd63a1f1157a0402203e1a8d2c2d8780c39f3beb059da47c9e6d7374e7500fede6d8c3d2ac9c2b7daf412102e1c90f90a2a5a04a3b8fd8ed2702bce7ea0d4fd08c82492b428959ef524e3c37ffffffff020000000000000000286a264e6f746172793dcf300280f02d2f6daf715910d4dbe1644829c2d40644110c86bec3957a2fc1d80e0000000000001976a9148e23590d7c783ec659ddc9f8facf72994f4a327688ac00000000","locktime":0,"size":240,"time":1558201722,"txid":"841975c2e144fc3b13e71100872fb0966690b7b171933bfee3dab3b457ea7d48","version":2,"vin":[{"scriptSig":{"asm":"304402206e322854de25c336f68b558ec5fbbecadd23de97e9f0a9fca7dd63a1f1157a0402203e1a8d2c2d8780c39f3beb059da47c9e6d7374e7500fede6d8c3d2ac9c2b7daf[ALL|FORKID] 02e1c90f90a2a5a04a3b8fd8ed2702bce7ea0d4fd08c82492b428959ef524e3c37","hex":"47304402206e322854de25c336f68b558ec5fbbecadd23de97e9f0a9fca7dd63a1f1157a0402203e1a8d2c2d8780c39f3beb059da47c9e6d7374e7500fede6d8c3d2ac9c2b7daf412102e1c90f90a2a5a04a3b8fd8ed2702bce7ea0d4fd08c82492b428959ef524e3c37"},"sequence":4294967295,"txid":"ed7af423eef75542dfdbd1d31a60239a38d051d23beaf7fde242030d9862a0aa","vout":0}],"vout":[{"n":0,"scriptPubKey":{"asm":"OP_RETURN 4e6f746172793dcf300280f02d2f6daf715910d4dbe1644829c2d40644110c86bec3957a2fc1","hex":"6a264e6f746172793dcf300280f02d2f6daf715910d4dbe1644829c2d40644110c86bec3957a2fc1","type":"nulldata"},"value":0},{"n":1,"scriptPubKey":{"addresses":["bitcoincash:qz8zxkgd03ura3jemhyl37k0w2v57j3jwc37xj7cqc"],"asm":"OP_DUP OP_HASH160 8e23590d7c783ec659ddc9f8facf72994f4a3276 OP_EQUALVERIFY OP_CHECKSIG","hex":"76a9148e23590d7c783ec659ddc9f8facf72994f4a327688ac","reqSigs":1,"type":"pubkeyhash"},"value":0.000038}]}}

We want the same thing here -- the tokenId should be readable directly in the hex script, rather than encoded.

Please preserve the existing order -- i.e. airdrop prefix and then tokenId -- as this could be used by apps other than Cashtab.

image.png (251×1 px, 154 KB)

web/cashtab/src/hooks/__mocks__/mockParsedTxs.js
165 ↗(On Diff #34066)

This should be the tokenId, not the tokenId in hex

This revision now requires changes to proceed.Jun 21 2022, 14:17
emack marked an inline comment as done.

Airdrop token ID is now un-encoded in the output hex string. Script construction logic in sendXec() and parsing logic in parseTxData() updated to reflect feedback.

Sample OP_RETURN breakdown for an airdrop with message:

https://explorer.be.cash/tx/918494859b46ae2c9a587983504f9c42aba2fe48df1e09d4f9c77bee7a1aa0ee

6a (OP_RETURN)
04
64726f70 (airdrop prefix)
20
1c6c9c64d70b285befe733f175d0f384538576876bd280b10587df81279d3f5e (token id)
04
00746162 (cashtab message prefix)
09
61697264726f703434 (the message)

This revision is now accepted and ready to land.Jun 23 2022, 14:15
This revision was automatically updated to reflect the committed changes.