THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin BIP65 Explained: CHECKLOCKTIMEVERIFY and Historical Activation

permalink THAMER
#bip65#block-version#cltv#consensus#timelock

BIP65 introduced OP_CHECKLOCKTIMEVERIFY (CLTV), a Script operation that lets an output require a transaction's nLockTime to reach a specified threshold before the output can be spent. It is a consensus-level constraint on spending, not an automated payment scheduler.

Why a script-level lock matters

Transaction-level nLockTime can delay when a transaction becomes final, but the party constructing a later transaction may choose its own nLockTime. A CLTV condition in the spent output's script forces the spender to provide a transaction whose nLockTime satisfies the script's requirement. The restriction follows the output until it is spent under the active consensus rules.

Conditions checked by CLTV

The operand is interpreted as a Script number. A negative operand is invalid. The operand and transaction nLockTime must use the same category: heights below 500,000,000, or Unix-time-based values at or above that threshold. The transaction's nLockTime must be at least the script operand. The spending input's nSequence must not be final (0xffffffff), or the CLTV check fails.

CLTV checks conditions but does not remove its operand from the stack; scripts typically follow it with OP_DROP before evaluating other spending conditions. CLTV also does not prove the wall-clock time a user sees on their device: Bitcoin locktime evaluation follows chain and transaction rules.

Historical soft-fork activation

BIP65 repurposed the previously reserved OP_NOP2 opcode and was activated through a version-4 block deployment in December 2015 on mainnet. Nodes that enforce the activated rule reject spends violating CLTV; older software could interpret that opcode differently, which is why this was a soft-fork tightening of acceptable spends.

CLTV versus CSV

BIP65 CLTV is an absolute locktime condition tied to nLockTime. BIP112 CHECKSEQUENCEVERIFY (CSV) supports relative locktime semantics based on an input's sequence and the age of its spent output. They solve different scheduling problems and must not be treated as interchangeable.

Example design pattern

A recovery branch might allow a designated recovery key to spend after a specified block height while another branch allows immediate spending under different authorization conditions. The script still needs correct branch logic and signatures; a timelock by itself is not authorization.

Common errors

A script operand with a timestamp-style value cannot be satisfied by a height-style nLockTime. Setting nSequence to final disables the nLockTime requirement needed for CLTV. A locktime condition also does not force a miner to include a transaction immediately once it becomes eligible.

Primary references

BIP65 — OP_CHECKLOCKTIMEVERIFY: https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki
BIP112 — CHECKSEQUENCEVERIFY: https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects