coinselect
A fee-saving bitcoin input selection module.
The code is stable.
The module's interface/existence is not.
Please let me know if you are using this package.
Example
var coinSelect = require('coinselect')
var feePerKb = 1000
var unspents = [
...,
{
...,
value: 10000
}
]
var outputs = [
...,
{
address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm',
value: 5000
}
]
var result = coinselect(unspents, outputs, feePerKb)
console.log(result.fee)
if (!result.inputs) return
var txb = new bitcoin.TransactionBuilder()
if (result.remainder > 5460) {
txb.addOutput(changeAddress, result.remainder)
}
Feedback welcome on the API, I'm not sure if I like it.
License MIT