HomePhabricator

[Cashtab] Commence refactor of transaction building

Description

[Cashtab] Commence refactor of transaction building

Summary:
Cashtab transaction functions are overloaded and complex. They are all in the utils/ directory, with all of the other Cashtab functions.

Cashtab should have better organized functions and unit tests.

This diff starts improving Cashtab's transaction building functions by creating a new function sendXecToOneAddress. This is currently handled by sendXec, which also sends xec to many addresses, sends OP_RETURN msgs, sends encrypted msgs, and sends those to many addresses as well if it comes to that.

This function implements the new coinSelect function from ecash-coinselect to bring transaction fees down to 1 satoshi per byte (or ~1.01 satoshis/byte for txs sent to P2SH addresses).

A new supporting function signInputs is also introduced, as the existing signUtxosByAddress function returns TransactionBuilder. This is not necessary as TransactionBuilder is an object. However, it is done this way in existing transaction functions, many unit tests are there for it, and it would be a lot of makework to remove it from the existing transaction building functions that I would like to deprecate anyway. So -- new function.

Note: this diff does not implement the function anywhere in Cashtab. user-facing behavior is not impacted by this diff.

Test Plan: npm test

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien, emack

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

Details

Provenance
bytesofmanAuthored on Sep 22 2023, 22:36
bytesofmanPushed on Sep 29 2023, 16:45
Reviewer
Restricted Project
Differential Revision
D14527: [Cashtab] Commence refactor of transaction building
Parents
rABC487e77ca0ae5: [avalanche] Don't ban for polling cooldown not elapsed
Branches
Unknown
Tags
Unknown