@@ -718,15 +718,8 @@ sign_non_witness(script_code, i):
718718 if IsMine(key) and IsAcceptable(sighash_type):
719719 sign(non_witness_sighash(script_code, i, input))
720720
721- for input,i in enumerate(psbt.inputs):
722- if non_witness_utxo.exists:
723- assert(sha256d(non_witness_utxo) == psbt.tx.input[i].prevout.hash)
724- if redeemScript.exists:
725- assert(non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey == P2SH(redeemScript))
726- sign_non_witness(redeemScript, i)
727- else:
728- sign_non_witness(non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey, i)
729- else if witness_utxo.exists:
721+ for input, i in enumerate(psbt.inputs):
722+ if witness_utxo.exists:
730723 if redeemScript.exists:
731724 assert(witness_utxo.scriptPubKey == P2SH(redeemScript))
732725 script = redeemScript
@@ -737,6 +730,13 @@ for input,i in enumerate(psbt.inputs):
737730 else if IsP2WSH(script):
738731 assert(script == P2WSH(witnessScript))
739732 sign_witness(witnessScript, i)
733+ else if non_witness_utxo.exists:
734+ assert(sha256d(non_witness_utxo) == psbt.tx.input[i].prevout.hash)
735+ if redeemScript.exists:
736+ assert(non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey == P2SH(redeemScript))
737+ sign_non_witness(redeemScript, i)
738+ else:
739+ sign_non_witness(non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey, i)
740740 else:
741741 assert False
742742</pre>
0 commit comments