TERM_DEF // SCRIPT_AUTHORIZATION / OP_CHECKLOCKTIMEVERIFY_CLTV
OP_CHECKLOCKTIMEVERIFY
(CLTV)
(CLTV)
OP_CHECKLOCKTIMEVERIFY (CLTV). Compares stack value to tx locktime; fails if locktime is earlier — absolute timelock primitive (BIP65).
This page sits in the Script & Authorization section — The stack VM that decides whether a UTXO is spendable — opcodes, templates, and modern script trees. Read on for what it is, why it exists, how it works under the hood, and what to watch out for.
This page sits in the Script & Authorization section — The stack VM that decides whether a UTXO is spendable — opcodes, templates, and modern script trees. Read on for what it is, why it exists, how it works under the hood, and what to watch out for.
WHAT_OP_CHECKLOCKTIMEVERIFY_CLTV_IS
OP_CHECKLOCKTIMEVERIFY (CLTV) — at a glance
SCRIPT
Why it exists
DESIGN
OP_CHECKLOCKTIMEVERIFY exists because Coins can be locked until a specific time or after a relative delay — without these opcodes there is no on-chain "wait" primitive.
HOW_IT_WORKS
Mechanism
HOW IT WORKS
Every UTXO is locked by a scriptPubKey — the output's locking script. To spend it, you provide a scriptSig (or witness) containing data that satisfies the lock. The node concatenates them, runs the combined script on a stack machine, and accepts the spend if and only if execution finishes with a single truthy value on the stack. OP_CHECKLOCKTIMEVERIFY (CLTV) contributes a specific stack effect within that process — opcodes either push, pop, copy, hash, branch, or verify, and they do so left-to-right deterministically.
1. The script is parsed into a sequence of opcodes and push-data items.
2. Execution starts with an empty stack and an empty alt-stack.
3. Each opcode runs in order — push opcodes add to the stack, others consume the top items and may push results.
4. When OP_CHECKLOCKTIMEVERIFY (CLTV) is reached, it performs its specific stack effect (see below).
5. Final state: a single non-zero (truthy) value on top → the spend is authorised. Anything else (empty stack, false, error) → the script fails and the tx is rejected.
WORKED_EXAMPLE
OP_CHECKLOCKTIMEVERIFY — stack effect + canonical use
EXAMPLE
Opcode : OP_CHECKLOCKTIMEVERIFY
Family : LOCKTIME
Stack effect: n → (fail unless nLockTime ≥ n)
Added : BIP-65 (2015)
Behaviour : Absolute-time lock; opcode value formerly OP_NOP2.
Open /playground in another tab and search for OP_CHECKLOCKTIMEVERIFY.
Drag the opcode in, watch the stack visualisation step through it
against any combination of inputs you choose.
KEY_PROPERTIES
FAMILY
Belongs to the LOCKTIME family of Script opcodes — siblings share validation rules and historical evolution.
STACK EFFECT
Exactly n → (fail unless nLockTime ≥ n). Every full node enforces the same effect, byte-for-byte.
ACTIVE
Active on mainnet today; every spend that uses it is being validated by every full node.
COMMON_PITFALLS
Things that catch people out
PITFALLS
- Timelocks compare against the spending tx's nLockTime / sequence field, not "current time" — make sure the spending tx is built to satisfy them.
RELATED_CONCEPTS
Other terms from Script & Authorization — click any to read its page:
TERMINOLOGY_INDEX
TERMINOLOGY
OP_CHECKLOCKTIMEVERIFY (CLTV)
Compares stack value to tx locktime; fails if locktime is earlier — absolute timelock primitive (BIP65).
Script
Bitcoin's purpose-built stack language; every locking and unlocking script is a script program.
Stack
The single LIFO data structure all script execution operates on; no variables, no registers.
Locking Script
The scriptPubKey on an output; specifies the spending conditions.
Unlocking Script
The scriptSig/witness in an input; provides the data that satisfies the lock.
Redeem Script
Witness Script
In P2WSH, the script whose SHA256 is committed in the output; placed at the end of the witness stack.
Script Execution
Sequential stepping through opcodes, mutating the stack until either a valid truthy stack remains or the script fails.