TransactionBuilder: flatten prepareInput P2SH detection

This commit is contained in:
Daniel Cousens 2016-10-12 12:13:02 +11:00 committed by Daniel Cousens
parent a58c959099
commit 1ff64d207e

View file

@ -182,16 +182,12 @@ function prepareInput (input, kpPubKey, redeemScript, hashType) {
var expanded = expandOutput(redeemScript, undefined, kpPubKey)
if (!expanded.pubKeys) throw new Error('RedeemScript not supported "' + bscript.toASM(redeemScript) + '"')
// if we don't have a prevOutScript, generate a P2SH script
if (!input.prevOutType) {
input.prevOutScript = bscript.scriptHashOutput(redeemScriptHash)
input.prevOutType = 'scripthash'
}
input.pubKeys = expanded.pubKeys
input.signatures = expanded.signatures
input.redeemScript = redeemScript
input.redeemScriptType = expanded.scriptType
input.signatures = expanded.signatures
input.prevOutScript = input.prevOutScript || bscript.scriptHashOutput(redeemScriptHash)
input.prevOutType = 'scripthash'
// maybe we have some prevOut knowledge
} else if (input.prevOutType) {