Browse Source

Created mkSendToOutputs method

hk-custom-address
vub 11 years ago
parent
commit
4abcdbd7af
  1. 2
      bitcoinjs-min.js
  2. 13
      src/wallet.js

2
bitcoinjs-min.js

File diff suppressed because one or more lines are too long

13
src/wallet.js

@ -140,6 +140,19 @@ var Wallet = function (seed) {
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) {
tx.ins.map(function(inp,i) {
var inp = inp.outpoint.hash+':'+inp.outpoint.index;

Loading…
Cancel
Save