TeachMeBitcoin

OP_RESERVED - The Undefined Opcode

From TeachMeBitcoin, the free encyclopedia Reading time: 3 min

13. OP_RESERVED — The Undefined Opcode

Overview

OP_RESERVED is opcode byte 0x50 and occupies the single position between OP_1NEGATE (0x4f) and OP_1 (0x51). Its name implies a reservation for future use, but its actual behavior is more nuanced: it is defined to cause a transaction to fail if it is ever executed — but it can appear in unexecuted branches of a script without causing failure. This property distinguishes it from truly "undefined" opcodes.

Opcode Definition

OP_RESERVED = 0x50

Bitcoin's consensus rules define OP_RESERVED as follows: if this opcode is encountered during active script execution (i.e., it is not in a skipped conditional branch), the entire transaction is immediately invalid. This is different from "undefined" or "disabled" opcodes in important ways.

Execution Behavior

Case 1: OP_RESERVED in the main execution path
  Script: OP_1 OP_RESERVED OP_2

Result: FAIL (OP_RESERVED is encountered during active execution)

Case 2: OP_RESERVED in a false branch (never executed)
  Script: OP_0 OP_IF OP_RESERVED OP_ENDIF

Result: SUCCESS (OP_RESERVED is never reached; the IF branch is skipped)

Case 3: OP_RESERVED in an always-false branch
  Script: OP_FALSE OP_IF OP_RESERVED OP_ENDIF OP_1
  Stack after: [0x01]

Result: SUCCESS (the OP_RESERVED-containing branch is never entered)

This conditional-branch behavior is important for understanding future upgrade paths and for understanding how scripts with complex conditional structures can contain otherwise-invalid opcodes safely.

Distinction from Disabled Opcodes

Disabled opcodes like OP_MUL, OP_2MUL, OP_CAT, etc., are rejected even if they appear in an unexecuted branch. This is because disabled opcodes are checked at script parsing/validation time, not execution time. OP_RESERVED by contrast is checked at execution time — it only fails if reached.

Disabled opcode behavior (always fails):
  Script: OP_0 OP_IF OP_MUL OP_ENDIF

Result: FAIL (OP_MUL is disabled, fails at parsing even in dead branch)

OP_RESERVED behavior (fails only if executed):
  Script: OP_0 OP_IF OP_RESERVED OP_ENDIF

Result: SUCCESS (not reached)

Historical and Upgrade Context

The name "reserved" suggests that 0x50 was held back from the regular opcode assignments for potential future use. However, because OP_RESERVED is defined to fail on execution rather than do nothing (like a NOP), it cannot easily be repurposed into a useful opcode via a soft fork without careful coordination. If a future soft fork wanted to give OP_RESERVED a new meaning, it would have to ensure that all scripts currently relying on its "fail if reached" behavior are not broken.

In practice, OP_RESERVED has never been given a new meaning and remains a defined-but-useless opcode in the Bitcoin Script specification.


☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!