HomePhabricator

[Cashtab] Implement ecash-lib for tx building

Description

[Cashtab] Implement ecash-lib for tx building

Summary:
T3582

Implement ecash-lib for building txs in Cashtab.

This diff uses ecash-lib instead of utxo-lib + ecash-coinselect to build raw txs with schnorr signatures (previously all Cashtab txs were ECDSA).

Because ecash-coinselect is calibrated for ECDSA, it does not provide accurate fee estimation for Schnorr txs (hence, it also does not provide accurate estimation of the maximum amount of satoshis a wallet can send, or a useful utxo selection algorithm).

The key feature of ecash-coinselect --- determining whether or not a tx needs a change output, and what the value of that output should be given the desired tx fee --- is handled by ecash-lib. Going forward, we may wish to add utxo selection algorithms to ecash-lib. For now, since Cashtab only uses a simple accumulative algorithm and this was all that ecash-coinselect provided -- simply deprecate ecash-coinselect.

Since ecash-lib already does most of what ecash-coinselect used to do (but better and for schnorr), ecash-coinselect should go through a deprecation cycle. No point in adding new features to the lib.

There is still more work to be done to fully implement ecash-lib in Cashtab. ecash-lib covers features where Cashtab is currently still using utxo-lib or slp-mdm. These will be deprecated in subseqent diffs (see T3582).

Test Plan:
npm test

Select 2 or 3 of the changed txs from the tests at random. Import the old tx into Electrum and compare to the new tx.

Confirm the inputs and outputs are the same. Differences should be

  • txid is different
  • size is different
  • fee is lower in absolute terms

Reviewers: #bitcoin_abc, Fabien, tobias_ruck

Reviewed By: #bitcoin_abc, Fabien, tobias_ruck

Subscribers: tobias_ruck, Fabien

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

Details

Provenance
bytesofmanAuthored on May 21 2024, 13:07
bytesofmanPushed on May 30 2024, 21:15
Reviewer
Restricted Project
Differential Revision
D16190: [Cashtab] Implement ecash-lib for tx building
Parents
rABC1af2ca22959f: refactor: Run type check against RPCArgs (1/2)
Branches
Unknown
Tags
Unknown