From 377b815417011d4839381ff7967cb1cf3e416b55 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 16 Jul 2014 22:37:28 +1000 Subject: [PATCH] TxBuilder: transform all signatures once --- src/transaction_builder.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/transaction_builder.js b/src/transaction_builder.js index 6611bca..07fce4b 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -127,24 +127,26 @@ TransactionBuilder.prototype.build = function(allowIncomplete) { this.signatures.forEach(function(input, index) { var scriptSig + var signatures = input.signatures.map(function(signature) { + return signature.toScriptSignature(input.hashType) + }) + if (input.scriptType === 'pubkeyhash') { - var signature = input.signatures[0].toScriptSignature(input.hashType) + var signature = signatures[0] var publicKey = input.pubKeys[0] scriptSig = scripts.pubKeyHashInput(signature, publicKey) } else if (input.scriptType === 'multisig') { var redeemScript = allowIncomplete ? undefined : input.redeemScript - var signatures = input.signatures.map(function(signature) { - return signature.toScriptSignature(input.hashType) - }) scriptSig = scripts.multisigInput(signatures, redeemScript) } else if (input.scriptType === 'pubkey') { - var signature = input.signatures[0] + var signature = signatures[0] scriptSig = scripts.pubKeyInput(signature) } else { assert(false, input.scriptType + ' not supported') + } if (input.redeemScript) {