Giter Club home page Giter Club logo

Comments (9)

PeterGarner avatar PeterGarner commented on July 18, 2024 1

I think what’s confusing is the term ‘matched’. If input == (matches) output then fee = 0. Do you mean ‘reached’?

Don’t get me wrong, cs works great in my app. No issues with it.

from coinselect.

PeterGarner avatar PeterGarner commented on July 18, 2024 1

I'm confusing myself. Of course, 'matched' is the correct term for Blackjack (like the game), not reached.

What I should have focussed on was the term 'target value'. This refers to the output + pre-calculated fee, is that right?

var fee = feeRate * (bytesAccum + inputBytes)

Whereas I was reading 'target value' == THE output value, as in

let targets = [{ address: payToAddr, value: amount }]

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

From the inputs?

fee = input - output, where input >= output.

If you have 3 unspents (90 + 50 + 25), and 1 output (100), and you do a basic accumulative strategy, you'll probably end up with 2 inputs (90 + 50) and 1 output (100), with fee (40).

I'll update the README example to be copy-pastable.

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

Yes, reached.

PR accepted.

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

It does say reached
https://github.com/bitcoinjs/coinselect/blame/11e0e925ccc939c2b0889b43020a590e89a66b20/README.md#L15

If you are referring to blackjack:

`require('coinselect/blackjack')` | Blackjack - accumulates inputs until the target value is matched, does not accumulate inputs that go over the target value (within a threshold) | -

Then, it is matched.

coinselect/blackjack.js

Lines 22 to 33 in 11e0e92

if ((inAccum + inputValue) > (outAccum + fee + threshold)) continue
bytesAccum += inputBytes
inAccum += inputValue
inputs.push(input)
// go again?
if (inAccum < outAccum + fee) continue
return utils.finalize(inputs, outputs, feeRate)
}

Where target value is outAccum + fee.

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

What I should have focussed on was the term 'target value'. This refers to the output + pre-calculated fee, is that right?

Yes, the "target value" refers to outAccum + fee, and is variable in that it increases as the fee increases (as inputs are added).

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

Do you have another suggestion for the term?

You are right in that it is ambiguous and could be better.

from coinselect.

PeterGarner avatar PeterGarner commented on July 18, 2024

I think 'target value' is fine if referring to the actual amount you want the target address to receive and fits with the terms already used when constructing the 'targets' array. I would only add '+ fees' and leave it for people to read the code to see how the fees are dynamically determined and included.

from coinselect.

dcousens avatar dcousens commented on July 18, 2024

See #35

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.