HomePhabricator

[ecash-coinselect] Export new function getMaxSendAmountSatoshis

Description

[ecash-coinselect] Export new function getMaxSendAmountSatoshis

Summary:
Export a new function to get the max amount of satoshis that can be sent from a given set of utxos at a given fee and including any miscellaneous target outputs.

Initially I was going to implement this function in Cashtab, but it requires bytecount methods in this lib and I believe it is a common enough thing for a utxo-chain dev to need that it should be in a lib. I considered modifying the coinSelect function to simply sendMax -- however this would make it difficult for Cashtab's needed use case (displaying the value before the user decides to send it) -- which is also a common one for app developers. An app developer can easily enough still use coinSelect when building the actual broadcasting function.

Test Plan:
npm test

See D15553 for how this will be implemented in Cashtab

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Subscribers: PiRK

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

Event Timeline