Created mkSendToOutputs method
This commit is contained in:
parent
b3e7caada7
commit
4abcdbd7af
2 changed files with 14 additions and 1 deletions
2
bitcoinjs-min.js
vendored
2
bitcoinjs-min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -140,6 +140,19 @@ var Wallet = function (seed) {
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.mkSendToOutputs = function(outputs, changeIndex, fee) {
|
||||||
|
var value = outputs.reduce(function(t,o) { return t + o.value },0),
|
||||||
|
utxo = this.getUtxoToPay(value + fee),
|
||||||
|
sum = utxo.reduce(function(t,p) { return t + o.value },0);
|
||||||
|
utxo[changeIndex].value += sum - value - fee;
|
||||||
|
var tx = new Bitcoin.Transaction({
|
||||||
|
ins: utxo.map(function(x) { return x.output }),
|
||||||
|
outs: outputs
|
||||||
|
})
|
||||||
|
this.sign(tx)
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
|
||||||
this.sign = function(tx) {
|
this.sign = function(tx) {
|
||||||
tx.ins.map(function(inp,i) {
|
tx.ins.map(function(inp,i) {
|
||||||
var inp = inp.outpoint.hash+':'+inp.outpoint.index;
|
var inp = inp.outpoint.hash+':'+inp.outpoint.index;
|
||||||
|
|
Loading…
Add table
Reference in a new issue