coinselect icon indicating copy to clipboard operation
coinselect copied to clipboard

Possible conditional error on line 22 in blackjack.js

Open miroosama opened this issue 7 years ago • 1 comments

I was running into an issue passing the conditional on line 22 of blackjack.js

if ((inAccum + inputValue) > (outAccum + fee + threshold)) continue

despite having a greater sum of inAccum + inputValue than outAccum + fee + threshold

I changed the conditional to

if ((inAccum + inputValue) > (outAccum + fee + threshold)){

and was able to generate the correct response of hitting

return utils.finalize(inputs, outputs, feeRate)

The original error would read cannot forEach on inputs value of Undefined because I was only being returned a fee from the else

return { fee: feeRate * bytesAccum }

miroosama avatar Sep 25 '18 20:09 miroosama

Blackjack attempts to hit the target value, but not exceed it by threshold. You probably want an accumulative strategy instead.

dcousens avatar Sep 25 '18 21:09 dcousens