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 Jun 13 2024, 23:17
bytesofmanPushed on Jun 18 2024, 12:27
Reviewer
Restricted Project
Differential Revision
D16332: [Cashtab] Refactor script generating functions to use ecash-lib Script
Parents
rABC528dfe6ad359: [e.cash] Change from Bitgo utxo-lib to ecash-lib on Build page
Branches
Unknown
Tags
Unknown