coinselect
coinselect copied to clipboard
Possible conditional error on line 22 in blackjack.js
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 }
Blackjack attempts to hit the target value, but not exceed it by threshold.
You probably want an accumulative strategy instead.