Skip to content

Commit ca0c1bf

Browse files
committed
Make VerifyScript() P2SH restore stack from stackCopy
1 parent d8f8686 commit ca0c1bf

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

bitcoin/core/scripteval.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,19 +754,22 @@ def VerifyScript(scriptSig, scriptPubKey, txTo, inIdx, flags=()):
754754
if not scriptSig.is_push_only():
755755
raise VerifyScriptError("P2SH scriptSig not is_push_only()")
756756

757-
# stackCopy cannot be empty here, because if it was the
757+
# restore stack
758+
stack = stackCopy
759+
760+
# stack cannot be empty here, because if it was the
758761
# P2SH HASH <> EQUAL scriptPubKey would be evaluated with
759762
# an empty stack and the EvalScript above would return false.
760-
assert len(stackCopy)
763+
assert len(stack)
761764

762-
pubKey2 = CScript(stackCopy.pop())
765+
pubKey2 = CScript(stack.pop())
763766

764-
EvalScript(stackCopy, pubKey2, txTo, inIdx, flags=flags)
767+
EvalScript(stack, pubKey2, txTo, inIdx, flags=flags)
765768

766-
if not len(stackCopy):
769+
if not len(stack):
767770
raise VerifyScriptError("P2SH inner scriptPubKey left an empty stack")
768771

769-
if not _CastToBool(stackCopy[-1]):
772+
if not _CastToBool(stack[-1]):
770773
raise VerifyScriptError("P2SH inner scriptPubKey returned false")
771774

772775

0 commit comments

Comments
 (0)