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

Murch
  • 75,206
  • 34
  • 186
  • 622
Peter
  • 115
  • 5
  • 2
    Related question: https://bitcoin.stackexchange.com/questions/100413/for-a-redeem-script-to-satisfy-the-conditions-of-a-script-what-must-it-leave-on – Michael Folkson Feb 08 '23 at 08:25

1 Answers1

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.

Murch
  • 75,206
  • 34
  • 186
  • 622
  • 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 08 '23 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 09 '23 at 02:03