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 CLTV vs CSV: Absolute and Relative Timelocks

permalink THAMER
#bip112#bip65#bip68#bitcoin-timelocks#cltv#csv#nlocktime#nsequence

Bitcoin supports both absolute and relative timelock constraints. They help construct spending conditions that depend on chain height or time. They are not automatic payments: the spender must still create and broadcast a valid transaction when the condition can be satisfied.

What does CLTV enforce?

OP_CHECKLOCKTIMEVERIFY (CLTV, BIP65) compares the top stack item with the spending transaction's nLockTime, subject to consensus checks. The locktime types must match: block heights and timestamps cannot be mixed. The input's nSequence must not be final, or CLTV fails. CLTV does not itself set nLockTime or sign the transaction.

What does CSV enforce?

OP_CHECKSEQUENCEVERIFY (CSV, BIP112) can enforce relative locktime using the spending input's nSequence and the BIP68 sequence-lock interpretation. Relative constraints are measured from the confirmation context of the output being spent, using blocks or 512-second time units. Transaction version and sequence flags matter; they cannot be ignored.

CLTV versus CSV

| Property | CLTV | CSV |
| --- | --- | --- |
| Constraint | Absolute | Relative |
| Relevant transaction field | nLockTime | Input nSequence |
| Typical use | Unlock after a specified height or time | Delay spending after a prior output confirms |
| Specification | BIP65 | BIP112 with BIP68 |

Example: absolute height lock

Conceptual locking script:

<block-height> OP_CHECKLOCKTIMEVERIFY OP_DROP <pubkey> OP_CHECKSIG

The spender must provide a compatible nLockTime, a non-final sequence, and a valid signature. The expression is illustrative; exact serialization, script version, and signing must be tested.

Example: relative delay

Conceptual locking script:

<relative-block-delay> OP_CHECKSEQUENCEVERIFY OP_DROP <pubkey> OP_CHECKSIG

This requires an appropriate transaction version and input sequence. CSV can be used in recovery and payment-channel designs, but it is not sufficient on its own to make a protocol secure.

Common developer mistakes

Confusing a transaction's nLockTime with a script's CLTV requirement; setting a final sequence; treating CSV as an absolute Unix timestamp; ignoring BIP68 flags; and assuming mempool acceptance guarantees eventual confirmation. Timelocks interact with both consensus validation and transaction relay policy.

Primary references

  • BIP65: OP_CHECKLOCKTIMEVERIFY: https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki
  • BIP68: Relative lock-time using consensus-enforced sequence numbers: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
  • BIP112: OP_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