Beefed up TransactionIn constructor

This commit is contained in:
vub 2013-10-21 14:07:38 -04:00
parent f53a4e3ffa
commit 274112005f
2 changed files with 24 additions and 17 deletions

2
bitcoinjs-min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -52,20 +52,27 @@ Transaction.objectify = function (txs) {
/** /**
* Create a new txin. * Create a new txin.
* *
* Can be called with an existing TransactionIn object to add it to the * Can be called with any of:
* transaction. Or it can be called with a Transaction object and an integer *
* output index, in which case a new TransactionIn object pointing to the * - An existing TransactionOut object
* referenced output will be created. * - A transaction and an index
* - A transaction hash and an index
* - A single string argument of the form txhash:index
* *
* Note that this method does not sign the created input. * Note that this method does not sign the created input.
*/ */
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]);
} else { }
else if (arguments[0].length > 65) {
var args = arguments[0].split(':');
return this.addInput(args[0], args[1]);
}
else {
this.ins.push(new TransactionIn({ this.ins.push(new TransactionIn({
outpoint: { outpoint: {
hash: tx.hash, hash: tx.hash || tx,
index: outIndex index: outIndex
}, },
script: new Script(), script: new Script(),