HomePhabricator

[Cashtab] Add function to create alias op_return outputScript

Description

[Cashtab] Add function to create alias op_return outputScript

Summary:
T3060

Per the updated alias spec, alias registration txs will have the following format

6a - OP_RETURN
04 - 4 bytes pushdata
2e786563 - alias protocol identifier (".xec")
00 - alias protocol version number pushed with OP_0
** - 1 byte pushdata, alias.length, in hex, e.g. '04' for a 4-byte alias registration, a value between 0x01 and 0x15
******** - n bytes, alias in hex
15 - 21 bytes of pushdata for address and address version byte
00 or 08 - marks address as p2pkh or p2sh
<hash> - address payload

A new function generateAliasOpReturnScript is added to create an OP_RETURN script matching this spec. Unit tests are added for sample registrations to p2pkh and p2sh addresses.

Test Plan:

  • Review the planned stack and comment on any improvements, errors, observations
  • Review the new function and unit tests
  • npm test

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
bytesofmanAuthored on Apr 28 2023, 22:25
bytesofmanPushed on May 2 2023, 16:42
Reviewer
Restricted Project
Differential Revision
D13826: [Cashtab] Add function to create alias op_return outputScript
Parents
rABCa2b104d4d8eb: [linter] Avoid unreachable code in shell scripts
Branches
Unknown
Tags
Unknown