fix and add tests for addInput

This commit is contained in:
Wei Lu 2014-03-17 17:49:37 +08:00
parent a5ee07f7f6
commit 2e6ef6cb85
2 changed files with 52 additions and 2 deletions

View file

@ -61,7 +61,7 @@ Transaction.objectify = function (txs) {
*
* Can be called with any of:
*
* - An existing TransactionOut object
* - An existing TransactionIn object
* - A transaction and an index
* - A transaction hash and an index
* - A single string argument of the form txhash:index
@ -77,9 +77,11 @@ Transaction.prototype.addInput = function (tx, outIndex) {
return this.addInput(args[0], args[1]);
}
else {
var hash = typeof tx === "string" ? tx : tx.hash
var hash = Array.isArray(hash) ? convert.bytesToHex(hash) : hash
this.ins.push(new TransactionIn({
outpoint: {
hash: tx.hash || tx,
hash: hash,
index: outIndex
},
script: new Script(),