HomePhabricator

[eCash library][ecash-coinselect] Initial npm module for basic utxo selection

Description

[eCash library][ecash-coinselect] Initial npm module for basic utxo selection

Summary:
T3225

A UTXO selection module to address some of the feedback from D14198 that interactions with the eCash network should be simplified for app devs.

There are numerous technical nuances when interacting with the XEC chain via the Chronik indexer.
This includes Chronik's:

  • .script().utxos() api returning both XEC and eToken utxos, which requires separation
  • .script().utxos() api's response returning an array of one single object (with utxo array embedded), which requires trimming
  • method of differentiation of eToken utxos via the existance of the utxo.slpToken param, which differs from other SLP indexers
  • output for utxo.value is a string which needs convert to Number

... amongst others.

This module abstracts away the above nuances by providing app developers a higher level API to interact with the network. It hides the underlying implementation details when devs want to carry out simple operations such as sending an XEC transaction.

Included in this initial version:

  • parseChronikUtxos: parsing the utxo response returned from Chronik's .script().utxos() api and separate into XEC/eToken utxos
  • getInputUtxos: collecting enough XEC utxos to pay for a send amount and tx fee
  • calcByteCount: byte count calculation for p2pkh txs

Planned in future iterations:

  • collecting eToken utxos to pay for a send token amount and tx fees
  • collecting XEC/eToken utxos by finding the biggest utxos first
  • collecting XEC/eToken utxos by consolidating dust and using the smallest utxos first
  • collecting XEC/eToken utxos by finding the most appropriately sized for the given tx
  • utxo selection for OP_RETURN message txs
  • utxo selection for one to many txs
  • utxo selection for XEC airdrop txs
  • utxo selection for alias registrations
  • byte count calculation for p2sh, multisigs

Test Plan:
npm test
plonk README into https://stackedit.io/app
compare byte size calculations with the bitcoin tx size calculator

Reviewers: bytesofman, Fabien, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

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

Details

Provenance
emackAuthored on Jul 7 2023, 09:12
emackPushed on Aug 3 2023, 23:58
Reviewer
Restricted Project
Differential Revision
D14227: [eCash library][ecash-coinselect] Initial npm module for basic utxo selection
Parents
rABC3fe2e5ee9181: [e.cash] camel case hrefLang tag
Branches
Unknown
Tags
Unknown