Post
Topic
Board Development & Technical Discussion
Merits 3 from 2 users
Re: opcodeexplained.com - A website which explain Bitcoin Opcodes
by
Coding Enthusiast
on 25/11/2023, 12:16:23 UTC
⭐ Merited by ETFbitcoin (2) ,vjudeu (1)
Quote
It is a synonym for OP_RETURN.
This part is wrong. A better approximation is OP_RESERVED. If you have OP_RETURN, then the Script is invalid immediately. But in case of OP_RESERVED, it can be wrapped in some unexecuted OP_IF, and it will still remain valid.
This is one of those little details in Bitcoin that not that many people know.
The only OP codes that would invalidate a script by just existing are these (like OP_CAT). However, OP codes like OP_RETURN need to be executed to invalidate a script, otherwise they can exist in an unexecuted branch for example and the script would still be valid.

Example:
https://blockstream.info/testnet/tx/95b3bccdd66d139f7f87a6c85bb704cb7278bfb8f8ff1859e3c9f99223c3bcc4?expand
The redeem script here is:
Code:
OP_IF
  <push public key> OP_CheckSig
OP_ELSE
  OP_RETURN
OP_ENDIF
The output was spent using the IF branch
Code:
<push signature>
OP_TRUE
Since the OP_RETURN is never reached or executed, it does no invalidate the script or the transaction. As you can see this transaction was included in testnet block #2540377