Transaction: fix incorrect outIndex type

This commit is contained in:
Daniel Cousens 2014-05-08 08:48:09 +10:00
parent bd2a6db260
commit 9a7e291d70

View file

@ -58,24 +58,28 @@ var Transaction = function (doc) {
Transaction.prototype.addInput = function (tx, outIndex) { Transaction.prototype.addInput = function (tx, outIndex) {
if (arguments[0] instanceof TransactionIn) { if (arguments[0] instanceof TransactionIn) {
this.ins.push(arguments[0]) this.ins.push(arguments[0])
return
} }
else if (arguments[0].length > 65) {
var args = arguments[0].split(':')
return this.addInput(args[0], args[1])
}
else {
var hash = typeof tx === "string" ? tx : tx.hash
hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash
this.ins.push(new TransactionIn({ var hash
outpoint: { if (arguments[0].length > 65) {
hash: hash, var args = arguments[0].split(':')
index: outIndex hash = args[0]
}, outIndex = parseInt(args[1])
script: new Script(),
sequence: this.defaultSequence } else {
})) hash = typeof tx === "string" ? tx : tx.hash
hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash
} }
this.ins.push(new TransactionIn({
outpoint: {
hash: hash,
index: outIndex
},
script: new Script(),
sequence: this.defaultSequence
}))
} }
/** /**