Page MenuHomePhabricator

[ecash-coinselect] Support specified input utxos
ClosedPublic

Authored by bytesofman on Feb 23 2024, 00:13.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCa3c580ec4238: [ecash-coinselect] Support specified input utxos
Summary

SLP v1 send txs require token utxos as inputs (they can be in any order).

ecash-coinselect can accept targetOutputs, which makes it flexible and robust for many use cases. However it cannot accept specified inputs.

Add an optional param to specify inputs. While this could have more use cases in the future, for now it extends ecash-coinselect applicability to constructing slpv1 send txs in Cashtab.

Because the input tokens required for an slp send tx depend on how targetOutputs are calculated, I think it is the best API to leave determination of these inputs outside the scope of ecash-coinselect. We could include very simple helper functions in ecash-coinselect to get these, but an app developer would still need to call other functions outside of ecash-coinselect to build the tx. imo there is not a great need for an optimal lib algorithm to accept these inputs. (1) it is very simple and (2) It is hard to make assumptions about the kind of token send txs an app dev would want to make.

Test Plan

npm test, review D15519 which has this version of ecash-coinselect installed

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

remove unrelated line break

bytesofman added inline comments.
modules/ecash-coinselect/src/coinSelect.js
59 ↗(On Diff #45500)

This follows the pattern of what ecash-coinselect currently does for xec utxos from chronik-client

Note: when in-node chronik-client becomes standard, this can be dropped, as in-node chronik-client returns utxo.value as a number.

This revision is now accepted and ready to land.Feb 23 2024, 19:14