@@ -718,15 +718,8 @@ sign_non_witness(script_code, i):
718
718
if IsMine(key) and IsAcceptable(sighash_type):
719
719
sign(non_witness_sighash(script_code, i, input))
720
720
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:
730
723
if redeemScript.exists:
731
724
assert(witness_utxo.scriptPubKey == P2SH(redeemScript))
732
725
script = redeemScript
@@ -737,6 +730,13 @@ for input,i in enumerate(psbt.inputs):
737
730
else if IsP2WSH(script):
738
731
assert(script == P2WSH(witnessScript))
739
732
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)
740
740
else:
741
741
assert False
742
742
</pre>
0 commit comments