2

I completed a round trip transaction with the redeem script hash: 31vFvEkyAb2iusbPip36H9rVt6pxExuaVR, whose redeem script is OP_3 (0x53) (yes I know not secure).

I can understand OP_1 redeem script unlocking its P2SH UTXO as 1 is left on the stack after redeem script execution, but with OP_3, 3 is left on the stack. So how does this successfully execute?

Tx: 36ca5aede94112009621bda42b3e84f49f7aa45886837d1d51c6590a04fcb8e7

1

1 Answer 1

4

A script execution is successful if it ends with a non-empty stack whose top element is not 0. Therefore, a script consisting of only OP_3 will be successful.

You may also be interested in the topic “For a redeem script to satisfy the conditions of a script what must it leave on the stack post execution?” which describes the criteria for successful scripts in more detail (H/T Michael Folkson). I would recommend using testnet or signet for experimental transactions.

2
  • Yes this is very helpful, thanks. However a P2SH redeem script of say, 3 OP_3s (535353) fails with error "Stack size must be exactly one after execution" because it is valid, but non-standard, and hence would have to be submitted to miner directly. Is that correct?
    – Peter
    Feb 8 at 23:36
  • 1
    Yes, stacks with more than one remaining element are non-standard for P2SH, and consensus invalid for segwit outputs.
    – Murch
    Feb 9 at 2:03

Your Answer

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

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