HomePhabricator

[Cashtab] Refactor script generating functions to use ecash-lib Script

Description

[Cashtab] Refactor script generating functions to use ecash-lib Script

Summary:
T3582

Stop using Buffer type and replace with ecash-lib's native Script

Background

Target outputs are currently created with script key as Buffer types, which utxo-lib used to build transactions.

ecash-lib uses its own Script class, which is much better.

  • Build OP_RETURN scripts using ecash-lib instead of utxo-lib script compiler
  • Build SLP1 OP_RETURN scripts with ecash-lib methods and not slp-mdm methods

While it would be nice to split out these cases, it is imo a better practice to keep one generalized tx building/signing/broadcasting function for Cashtab vs distinct functions for distinct use cases. This approach simplifies unit testing, makes it more clear what logic should move to ecash-lib, and helps in figuring out other tx types since it is clear what problem needs to be isolated (e.g. input selection, output script building).

Note
We still cannot (yet) deprecate slp-mdm or utxo-lib, as Cashtab uses BN from slp-mdm in other places (to be deprecated), and utxo-lib is still used to sign and verify msgs (to be replaced by ecash-lib).

This diff is necessary before we add new tx types to Cashtab, i.e. NFT trading with ecash-agora

Test Plan: npm test

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

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

Details

Provenance
bytesofmanAuthored on Thu, Jun 13, 23:17
teamcityPushed on Tue, Jun 18, 12:30
Parents
rSTAGING528dfe6ad359: [e.cash] Change from Bitgo utxo-lib to ecash-lib on Build page
Branches
Unknown
Tags
Unknown
References
tag: phabricator/base/48294, tag: phabricator/base/48292, tag: phabricator/base/48291

Event Timeline