transaction_builder: expandInput - check p2sh early, can avoid redundant assignments
This commit is contained in:
parent
a32cc5b3be
commit
c5541c8f96
1 changed files with 1 additions and 9 deletions
|
@ -90,8 +90,6 @@ function expandInput (scriptSig, witnessStack) {
|
||||||
if (!redeemScript.equals(witnessProgram)) {
|
if (!redeemScript.equals(witnessProgram)) {
|
||||||
throw new Error('Redeem script didn\'t match witnessScript')
|
throw new Error('Redeem script didn\'t match witnessScript')
|
||||||
}
|
}
|
||||||
prevOutScript = bscript.scriptHash.output.encode(bcrypto.hash160(witnessProgram))
|
|
||||||
prevOutType = scriptTypes.P2SH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SIGNABLE.indexOf(bscript.classifyOutput(witnessScript)) === -1) {
|
if (SIGNABLE.indexOf(bscript.classifyOutput(witnessScript)) === -1) {
|
||||||
|
@ -117,26 +115,20 @@ function expandInput (scriptSig, witnessStack) {
|
||||||
if (!redeemScript.equals(witnessProgram)) {
|
if (!redeemScript.equals(witnessProgram)) {
|
||||||
throw new Error('Redeem script did not have the right witness program')
|
throw new Error('Redeem script did not have the right witness program')
|
||||||
}
|
}
|
||||||
prevOutScript = bscript.scriptHash.output.encode(bcrypto.hash160(witnessProgram))
|
|
||||||
prevOutType = scriptTypes.P2SH
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptType = scriptTypes.P2PKH
|
scriptType = scriptTypes.P2PKH
|
||||||
chunks = witnessStack
|
chunks = witnessStack
|
||||||
} else if (redeemScript) {
|
} else if (redeemScript) {
|
||||||
redeemScriptType = bscript.classifyOutput(redeemScript)
|
|
||||||
if (P2SH.indexOf(redeemScriptType) === -1) {
|
if (P2SH.indexOf(redeemScriptType) === -1) {
|
||||||
throw new Error('Bad redeemscript!')
|
throw new Error('Bad redeemscript!')
|
||||||
}
|
}
|
||||||
|
|
||||||
script = redeemScript
|
script = redeemScript
|
||||||
scriptType = redeemScriptType
|
scriptType = redeemScriptType
|
||||||
prevOutType = scriptTypes.P2SH
|
|
||||||
prevOutScript = bscript.scriptHash.output.encode(bcrypto.hash160(redeemScript))
|
|
||||||
chunks = scriptSigChunks.slice(0, -1)
|
chunks = scriptSigChunks.slice(0, -1)
|
||||||
} else {
|
} else {
|
||||||
var bareType = bscript.classifyInput(scriptSig)
|
prevOutType = scriptType = bscript.classifyInput(scriptSig)
|
||||||
prevOutType = scriptType = bareType
|
|
||||||
chunks = scriptSigChunks
|
chunks = scriptSigChunks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue