Page MenuHomePhabricator

[ecash-wallet] Add method to get fuel utxos, i.e. utxos used to send eCash or fuel token txs
Needs ReviewPublic

Authored by bytesofman on Tue, Mar 11, 18:08.

Details

Reviewers
tobias_ruck
Group Reviewers
Restricted Project
Summary

There are several groupings of utxos that are useful in eCash. For example, utxos of a certain tokenId, mint batons, and non-token utxos.

In this diff we add a getter method to get "fuel utxos", i.e. eCash-only utxos. These are utxos we would use to send eCash or to "fuel" a token tx. They are consumable utxos in a way that is distinct from token utxos.

Since coinbase utxos are consumable in the same way but have a confirmation restriction, we also add a method to get spendable coinbase utxos.

We are currently building up what we need to send an XEC tx.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
ecash-wallet-next-step
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 32719
Build 64926: Build Diffecash-wallet-tests
Build 64925: arc lint + arc unit

Event Timeline

do not assume coinbase utxos cannot be tokens, add token utxos to tests to show we do not get them as fuel utxos

tobias_ruck added a subscriber: tobias_ruck.

Some initial comments

modules/ecash-wallet/index.ts
18 ↗(On Diff #53022)

the technical term for this is COINBASE_MATURITY, but if you want to optimize for random JS devs a longer name might also make sense

102 ↗(On Diff #53022)
106–107 ↗(On Diff #53022)
112 ↗(On Diff #53022)
127 ↗(On Diff #53022)

this is misleading, in fact every coinbase could be a token if people really wanted it

134 ↗(On Diff #53022)
This revision now requires changes to proceed.Tue, Mar 11, 20:15

no arrow syntax, stop testing files that do not yet exist, use correct COINBASE_MATURITY term, clean up comments

tobias_ruck added inline comments.
modules/ecash-wallet/index.ts
112 ↗(On Diff #53025)

Is it an issue if we just use this? It’s a bit longer but not that much and doesn’t introduce new terms.

Arguably I use fuelUtxos in Agora, but the meaning is slightly different; there it’s to fuel a specific tx that otherwise would lack sats.

Here, I suppose it also includes just ordinary XEC that people send to each other eg to play for PayButton. So fuel is a bit misleading imo.

But we can use fuel utxos here too if you insist

134 ↗(On Diff #53025)

Is this function useful for the outside? I never had to use any such utxos in isolation. Otherwise probably better to make it private so we don’t commit to too many APIs

This revision now requires changes to proceed.Thu, Mar 13, 04:34
bytesofman added inline comments.
modules/ecash-wallet/index.ts
112 ↗(On Diff #53025)

yes this is probably better. As you will see in the next diff, I went with this term bc I first built up the class to send tokens, then needed a function similar to agora to addFuelUtxos, so then needed a method to get them ... then later figured "well I can use this same function for sending XEC..."

being more specific here is an improvement.

134 ↗(On Diff #53025)

I can think of some reasons to use this outside the class, but they are quite niche ... for example if you want to "send all" staking rewards or mining rewards from a wallet (but not other utxos). Ofc, if you want to do that, you could just get the spendableSats utxos and then filter for isCoinbase

so probably is best to keep this private. it's not something that someone looking to "just use a wallet" would want off the bat.

bytesofman marked 2 inline comments as done.

use spendablesatsonlyutxos instead of fuelutxos, make getSpendableCoinbaseUtxos private

rebase, correct indefinite article in test name