From aa80bde815eaf1b669e16013171759e1b80076de Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Sat, 30 Aug 2014 12:22:55 +1000 Subject: [PATCH] TxBuilder: avoid unnecessary recalculation of prevOutScript data --- src/transaction_builder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/transaction_builder.js b/src/transaction_builder.js index c4f18da..42a77bf 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -231,13 +231,18 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT } else { prevOutScript = prevOutScript || privKey.pub.getAddress().toOutputScript() - scriptType = prevOutType || 'pubkeyhash' + prevOutType = prevOutType || 'pubkeyhash' - assert.notEqual(scriptType, 'scripthash', 'PrevOutScript requires redeemScript') + assert.notEqual(prevOutType, 'scripthash', 'PrevOutScript is P2SH, missing redeemScript') + + scriptType = prevOutType hash = this.tx.hashForSignature(index, prevOutScript, hashType) } + this.prevOutScripts[index] = prevOutScript + this.prevOutTypes[index] = prevOutType + if (!(index in this.signatures)) { this.signatures[index] = { hashType: hashType,