-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BigNumber #1
Conversation
|
||
// skip detrimental input | ||
if (utxoFee > utxo.value) { | ||
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) } | ||
var feeIsMoreThanValue = ext.gt(utxoFee, utxoValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
|
||
// would it waste value? | ||
if ((inAccum + inputValue) > (outAccum + fee + threshold)) continue | ||
var totalInputs = ext.add(inAccum, inputValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2
|
||
// did we bust? | ||
if (inAccum < (outAccum + fee + value)) { | ||
if (ext.lt(inAccum, ext.add(outAccum, fee, value))) { | ||
var isZero = ext.isZero(outAccum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3
if (outputs.length === 0) return { fee: fee } | ||
|
||
var inAccum = utils.sumOrNaN(utxos) | ||
var outAccum = utils.sumForgiving(outputs) | ||
var remaining = inAccum - outAccum - fee | ||
var remaining = ext.sub(inAccum, outAccum, fee) | ||
if (!isFinite(remaining) || remaining < 0) return { fee: fee } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be changed too
if (outputs.length === 0) return { fee: fee } | ||
|
||
var inAccum = utils.sumOrNaN(utxos) | ||
var outAccum = utils.sumForgiving(outputs) | ||
var remaining = inAccum - outAccum - fee | ||
var remaining = ext.sub(inAccum, outAccum, fee) | ||
if (!isFinite(remaining) || remaining < 0) return { fee: fee } | ||
|
||
var unspecified = outputs.reduce(function (a, x) { | ||
return a + !isFinite(x.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like they really just wanted to do outputs.filter(x => !isFinite(x.value)).length
but wanted to maintain compatibility with old js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it also uses .every
..so filter
should have been fine...
|
||
var splitOutputsCount = outputs.reduce(function (a, x) { | ||
// Counts the number of split outputs left | ||
var splitOutputsCount = new BN(outputs.reduce(function (a, x) { | ||
return a + !x.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this?
Why is this commit amended with BN changes: 339c1bf |
Moved to #2 |
Convert the library to use ‘bn.js’ instead of number formats.
What has changed