Browse Source

Transaction: fix incorrect outIndex type

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
9a7e291d70
  1. 16
      src/transaction.js

16
src/transaction.js

@ -58,14 +58,19 @@ 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 hash
if (arguments[0].length > 65) {
var args = arguments[0].split(':') var args = arguments[0].split(':')
return this.addInput(args[0], args[1]) hash = args[0]
} outIndex = parseInt(args[1])
else {
var hash = typeof tx === "string" ? tx : tx.hash } else {
hash = typeof tx === "string" ? tx : tx.hash
hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash
}
this.ins.push(new TransactionIn({ this.ins.push(new TransactionIn({
outpoint: { outpoint: {
@ -76,7 +81,6 @@ Transaction.prototype.addInput = function (tx, outIndex) {
sequence: this.defaultSequence sequence: this.defaultSequence
})) }))
} }
}
/** /**
* Create a new txout. * Create a new txout.

Loading…
Cancel
Save