Should be able to deal with incomplete P2SH/P2WSH inputs when allowIncomplete is set
This commit is contained in:
parent
bc3aef5a92
commit
0b1c3bfbd9
2 changed files with 37 additions and 9 deletions
|
@ -406,7 +406,7 @@ function buildInput (input, allowIncomplete) {
|
|||
if (scriptType === bscript.types.P2SH) {
|
||||
// We can remove this error later when we have a guarantee prepareInput
|
||||
// rejects unsignable scripts - it MUST be signable at this point.
|
||||
if (P2SH.indexOf(input.redeemScriptType) === -1) {
|
||||
if (P2SH.indexOf(input.redeemScriptType) === -1 && !allowIncomplete) {
|
||||
throw new Error('Impossible to sign this type')
|
||||
}
|
||||
p2sh = true
|
||||
|
@ -422,16 +422,13 @@ function buildInput (input, allowIncomplete) {
|
|||
witness = buildStack(bscript.types.P2PKH, input.signatures, input.pubKeys, allowIncomplete)
|
||||
} else if (scriptType === bscript.types.P2WSH) {
|
||||
// We can remove this check later
|
||||
if (SIGNABLE.indexOf(input.witnessScriptType) !== -1) {
|
||||
if (SIGNABLE.indexOf(input.witnessScriptType) === -1 && !allowIncomplete) {
|
||||
throw new Error('Impossible to sign this type')
|
||||
} else if (SIGNABLE.indexOf(input.witnessScriptType) !== -1) {
|
||||
witness = buildStack(input.witnessScriptType, input.signatures, input.pubKeys, allowIncomplete)
|
||||
witness.push(input.witnessScript)
|
||||
} else {
|
||||
// We can remove this error later when we have a guarantee prepareInput
|
||||
// rejects unsignble scripts - it MUST be signable at this point.
|
||||
throw new Error()
|
||||
scriptType = input.witnessScriptType
|
||||
}
|
||||
|
||||
scriptType = input.witnessScriptType
|
||||
}
|
||||
|
||||
// append redeemScript if necessary
|
||||
|
@ -578,7 +575,6 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
|
|||
var vin = this.tx.addInput(txHash, vout, options.sequence, options.scriptSig)
|
||||
this.inputs[vin] = input
|
||||
this.prevTxMap[prevTxOut] = vin
|
||||
|
||||
return vin
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue