From bd97f20f1c851f9eabf7f042e6b735b659600703 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Wed, 4 Feb 2015 12:10:47 -0300 Subject: [PATCH] Use addInput in _fromNonP2SH --- lib/transaction/transaction.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 45ed523..158627c 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -353,8 +353,14 @@ Transaction.prototype.from = function(utxo, pubkeys, threshold) { }; Transaction.prototype._fromNonP2SH = function(utxo) { + var clazz; utxo = new UnspentOutput(utxo); - this.inputs.push(new PublicKeyHashInput({ + if (utxo.script.isPublicKeyHashOut()) { + clazz = PublicKeyHashInput; + } else { + clazz = Input; + } + this.addInput(new clazz({ output: new Output({ script: utxo.script, satoshis: utxo.satoshis @@ -364,7 +370,6 @@ Transaction.prototype._fromNonP2SH = function(utxo) { sequenceNumber: DEFAULT_SEQNUMBER, script: Script.empty() })); - this._inputAmount += utxo.satoshis; }; Transaction.prototype._fromMultisigUtxo = function(utxo, pubkeys, threshold) {