coinselect
Advanced tools
Comparing version 3.1.10 to 3.1.11
{ | ||
"name": "coinselect", | ||
"version": "3.1.10", | ||
"version": "3.1.11", | ||
"description": "A transaction input selection module for bitcoin.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,11 +8,5 @@ # coinselect | ||
A transaction input selection module for bitcoin. | ||
An unspent transaction output (UTXO) selection module for bitcoin. | ||
The code is stable. | ||
The module's interface is not. | ||
Please let me know if you are using this package. | ||
## Example | ||
@@ -24,16 +18,16 @@ | ||
let utxos = [ | ||
..., | ||
{ | ||
txId: '...', | ||
vout: 0, | ||
..., | ||
value: 10000 | ||
} | ||
..., | ||
{ | ||
txId: '...', | ||
vout: 0, | ||
..., | ||
value: 10000 | ||
} | ||
] | ||
let targets = [ | ||
..., | ||
{ | ||
address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm', | ||
value: 5000 | ||
} | ||
..., | ||
{ | ||
address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm', | ||
value: 5000 | ||
} | ||
] | ||
@@ -54,15 +48,13 @@ | ||
outputs.forEach(output => { | ||
// watch out, outputs may have been added that you need to provide | ||
// an output address/script for | ||
if (!output.address) { | ||
output.address = wallet.getChangeAddress() | ||
} | ||
// watch out, outputs may have been added that you need to provide | ||
// an output address/script for | ||
if (!output.address) { | ||
output.address = wallet.getChangeAddress() | ||
} | ||
txb.addOutput(output.address, output.value) | ||
txb.addOutput(output.address, output.value) | ||
}) | ||
``` | ||
Feedback welcome on the API, I'm not sure if I like it. | ||
## License [MIT](LICENSE) |
@@ -30,3 +30,4 @@ // baseline estimates, used to improve performance | ||
if (!isFinite(v)) return NaN | ||
if (v >>> 0 !== v) return NaN | ||
if (Math.floor(v) !== v) return NaN | ||
if (v < 0) return NaN | ||
return v | ||
@@ -36,3 +37,3 @@ } | ||
function sumForgiving (range) { | ||
return range.reduce(function (a, x) { return a + (x.value >>> 0) }, 0) | ||
return range.reduce(function (a, x) { return a + (isFinite(x.value) ? x.value : 0) }, 0) | ||
} | ||
@@ -39,0 +40,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191
10447
58