Coder Social home page Coder Social logo

Comments (4)

Overtorment avatar Overtorment commented on July 30, 2024

single UTXO provided

whats the purpose of using coinselect then?

from coinselect.

sondreb avatar sondreb commented on July 30, 2024

single UTXO provided

whats the purpose of using coinselect then?

For fee calculation and output preparation for Psbt. Did another test with another wallet that had two UTXOs, this time it continued on the "waste" check and hit this:

if (inAccum < outAccum + fee) continue

And hit "waste" the second time, which it returns the fee only.

from coinselect.

Overtorment avatar Overtorment commented on July 30, 2024

so i would suggest that solution was indeed not found, to satisfy the requested feerate.

provide a test vector so we can check this hypothesis

from coinselect.

sondreb avatar sondreb commented on July 30, 2024

I was attempting to use blackjack and based upon writing tests for it, is it correct that blackjack will only be successful if there fee available within a certain threshold (upper and lower bounds)?

That's what it sounds like from the documentation, but it was not very clear to me that it will always fail if not within this threshold, maybe a clearer instruction that using blackjack should only be done if one already knows what the threshold beforehand?

Blackjack - accumulates inputs until the target value (+fees) is matched, does not accumulate inputs that go over the target value (within a threshold)

The require('coinselect') will attempt to do blackjack first, it will not happen very often (in a normal wallet user scenario) where an input is found that is very close match to output (+ fee threshold), so the optimization you get from blackjack, which I presume is to attempt to find an UTXOs that is within the range of the output, is most often wasted resources?

Using blackjack:

var feeRate = 10

// Works (return fee and inputs/outputs):
coinSelectBlackjack([{ vout: 0, value: 303400 }], [{ value: 300000 }], feeRate)
coinSelectBlackjack([{ vout: 0, value: 301920 }], [{ value: 300000 }], feeRate)

// "Fails" and returns only { fee: 1920 } (which is required for it to work)
coinSelectBlackjack([{ vout: 0, value: 301919 }], [{ value: 300000 }], feeRate)

// "Fails" and returns only { fee: 440 }. This is the "problematic" scenario that I've been debugging.
// Consequence is that `blackjack` cannot be used as the sole method of coinselect.
coinSelectBlackjack([{ vout: 0, value: 303401 }], [{ value: 300000 }], feeRate)

Using accumulative:

// Works (return fee and inputs/outputs):
coinSelectAccumulative([{ vout: 0, value: 303400 }], [{ value: 300000 }], feeRate)
coinSelectAccumulative([{ vout: 0, value: 301920 }], [{ value: 300000 }], feeRate)

// "Fails" and returns only { fee: 1920 } (which is required for it to work)
coinSelectAccumulative([{ vout: 0, value: 301919 }], [{ value: 300000 }], feeRate)

// Works and returns { fee: 3401 } + input/output
coinSelectAccumulative([{ vout: 0, value: 303401 }], [{ value: 300000 }], feeRate)

// Works and returns { fee: 3740 } and single output
coinSelectAccumulative([{ vout: 0, value: 303740 }], [{ value: 300000 }], feeRate)

// Works and returns { fee: 2260 } and double output (change address is above dust threshold)
coinSelectAccumulative([{ vout: 0, value: 303741 }], [{ value: 300000 }], feeRate)

So is the advice to avoid duplicate runs of coin select to always prefer using the require('coinselect/accumulative') method?

And do the main one if you want sort order + a potential lucky (hence the name?) optimization that blackjack does?

from coinselect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.