1

In BIP62, it was proposed to make a script invalid if there was more than one element left in the stack after execution. This proposal was eventually withdrawn.

From what I read, some people have suggested that this rule could eventually be enforced in the future. But the problem is that I think this would make segwit outputs non-valid with legacy nodes?

Take a P2TR for example. To a legacy node, the locking script of a P2TR output is seen as two non-zero data pushes. Together with the unlocking script (an empty byte array), this would leave the stack with two non-zero data pushes after execution, so a P2TR transaction would be rejected by legacy nodes.

Am I missing something?

1 Answer 1

2

This is a consensus rule inside (P2SH-)P2WSH witness scripts, and P2TR script-path spends already.

See BIP141:

The script must not fail, and result in exactly a single TRUE on the stack.

And BIP342:

If the execution results in anything but exactly one element on the stack which evaluates to true with CastToBool(), fail.


It would be possible to do a soft fork to enforce this rule for bare scripts and P2SH scripts too, though as you note, doing this naively would interfere with segwit script matching. A potential solution would be to exclude these patterns from the rule, but that may still be undesirable as it would close the door to using similar script extension mecanisms in the future. This was not an issue at the time BIP62 was proposed, as it predated segwit, but still, in retrospect it is probably good that it didn't get adopted as consensus rule.

I think there is little reason to add this rule to bare scripts and even P2SH scripts, as they are effectively obsolete. Newer constructions are cheaper, more compact, more convenient, and offer more features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.