TxBuilder: avoid unnecessary recalculation of prevOutScript data
This commit is contained in:
parent
e2357c09ce
commit
aa80bde815
1 changed files with 7 additions and 2 deletions
|
@ -231,13 +231,18 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
prevOutScript = prevOutScript || privKey.pub.getAddress().toOutputScript()
|
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)
|
hash = this.tx.hashForSignature(index, prevOutScript, hashType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.prevOutScripts[index] = prevOutScript
|
||||||
|
this.prevOutTypes[index] = prevOutType
|
||||||
|
|
||||||
if (!(index in this.signatures)) {
|
if (!(index in this.signatures)) {
|
||||||
this.signatures[index] = {
|
this.signatures[index] = {
|
||||||
hashType: hashType,
|
hashType: hashType,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue