bitcoindevkit / coin-select

Tool to help you select inputs for making bitcoin transactions.
Other
12 stars 6 forks source link

No more base weight #21

Closed LLFourn closed 5 months ago

LLFourn commented 7 months ago

Fixes #1

On top of #19

This wasn't what the issue had in mind but it was easier to take the base_weight out of CoinSelector and put it in Target rather than put Target in CoinSelector. Getting rid of base_weight is a more crucial change than expected because rust bitcoin changed what Transaction::weight returns for empty output transactions recently so using it to determine base_weight will get different answers between versions (this breaks our weight tests but this PR will fix it I think if we uprade dev deps). We only need to know the total weight of the outputs and how many there are now to get the right answers for weight.

murchandamus commented 7 months ago

Yeah, the waste metric is only used as a tiebreaker rather than something to optimize for because it would happily consolidate all your UTXOs at low feerates. What did you end up using instead?

Sorry, I only discovered this codebase recently per the Optech Newsletter, I’ll take a bit of a look around. :)

LLFourn commented 7 months ago

Hey @murchandamus! We've been keeping this code base low profile because it's still in science experiment stage. FWIW we gathered a long time ago that the waste metric was not something that you should use to actually optimize for -- it was just a good one to use to start the experiment. I'm interested in your work here: https://delvingbitcoin.org/t/gutterguard-and-coingrinder-simulation-results/279. It would be cool to try and replicate it.

We're just using what we call LowestFee metric: Tries to minimize the fee cost of the selection while taking into account the cost of spending the change (using the "long term feerate").

murchandamus commented 7 months ago

Ah that sounds similar to what I’m trying to do with CoinGrinder, where I am trying to always find the input set with the lowest input weight. The PR should hopefully be very readable: I organized the pullrequest to start with a simple implementation of the algorithm and then each improvement or optimization a separate commit. I still have a little hope that it might make the release, even if I did miss the really big feerates. In combination with BnB, and the waste metric, I guess I’d get something similar as the outcome of your LowestFee metric.