Merge pull request from bitcoinjs/transaction-tests

Transaction tests & fix addInput hash allowed formats
This commit is contained in:
Kyle Drake 2014-03-17 18:40:49 -07:00
commit 28517bed13
2 changed files with 117 additions and 4 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(),