Bitcoin timelocks: CLTV, CSV and nLockTime on the blockchain
Bitcoin timelocks: how nLockTime, CLTV and CSV differ, where they are used and what goes wrong. Nov 22, 2026 example: block 977,082, 65,535-block cap.

Contents
- What a bitcoin timelock is and why it exists
- nLockTime: a postdated transaction that locks nothing
- CLTV: an absolute lock until a block or a date
- CSV: a relative lock that starts at confirmation
- A worked example from November 22, 2026: block 977,082
- Where timelocks are used in practice
- How to choose a timelock: step by step
- Common mistakes
- FAQ
Bitcoin timelocks are rules that stop a transaction from confirming, or coins from being spent, before a set moment. There are four of them: nLockTime and nSequence live in the transaction itself, while the opcodes CLTV (OP_CHECKLOCKTIMEVERIFY) and CSV (OP_CHECKSEQUENCEVERIFY) live in the script that guards the coins. CLTV sets an absolute deadline ("not before block N"); CSV sets a relative one ("not until N blocks after confirmation"). Lightning channels, inheritance wallets and delayed-withdrawal vaults are all built on them.
What a bitcoin timelock is and why it exists
A normal bitcoin payment can be spent the moment the recipient can sign for it. A timelock adds a second condition next to the signature: time. The network enforces it directly, because nodes reject any block that spends the coins too early. No exchange, notary or service has to be trusted.
Bitcoin Optech defines timelocks as encumbrances that prevent a transaction, or the spend of an output, from confirming before a maturity time or block height. They differ along two axes:
- where the rule is written: in the transaction's fields, or in the script of the output (the UTXO; see our guide to transaction confirmations for how outputs work);
- what the clock counts from: the start of the chain (absolute) or the moment the coin was mined into a block (relative).
That gives four combinations.
| Mechanism | Where it lives | Type | Units | Limit | Live since |
|---|---|---|---|---|---|
| nLockTime | transaction field | absolute | block height or Unix time | none | network launch |
| nSequence (BIP 68) | field on each input | relative | blocks or 512-second steps | 65,535 blocks | block 419,328, July 2016 |
| CLTV (BIP 65) | output script | absolute | block height or Unix time | none | block 388,381, December 2015 |
| CSV (BIP 112) | output script | relative | blocks or 512-second steps | 65,535 blocks | block 419,328, July 2016 |
Activation heights come from BIP 90 and the Bitcoin Core announcement. Both changes arrived as soft forks, which we cover in Bitcoin soft fork upgrades.
nLockTime: a postdated transaction that locks nothing
nLockTime is a four-byte field at the end of every transaction. According to the Bitcoin developer guide, a value below 500 million is read as a block height, and 500 million or more is read as Unix time in seconds. Until that point arrives, miners cannot include the transaction in a block.
Two details matter. First, nLockTime only applies if at least one input has an nSequence below the maximum, 0xffffffff; otherwise the field is ignored. Second, and more important, nLockTime restricts the transaction, not the coins. The key holder can sign a different transaction with no lock at any time and spend the same coins sooner, which invalidates the postdated one. The developer guide describes exactly this way of changing your mind.
So a pre-signed nLockTime transaction is a promise its author can take back. For an agreement between two parties, that is not enough.
CLTV: an absolute lock until a block or a date
OP_CHECKLOCKTIMEVERIFY moves the rule from the transaction into the output itself. BIP 65, written by Peter Todd, redefined the unused NOP2 opcode. A script looks roughly like this:
<height or time> OP_CHECKLOCKTIMEVERIFY OP_DROP <pubkey> OP_CHECKSIG
When the output is spent, a node compares the number in the script with the nLockTime of the spending transaction. The script fails if:
- the stack is empty or the number is negative;
- the types differ, for example a height in the script and a timestamp in nLockTime;
- the number in the script is greater than the transaction's nLockTime;
- the input's nSequence is 0xffffffff.
A transaction carrying that nLockTime cannot itself be mined before the deadline, so the check closes the loop: no signature can move the coins before the chosen height. Not even the key holder can undo the lock.
The uses named in BIP 65 include escrow with a refund after expiry and payment channels. In Lightning, HTLCs rely on CLTV: if the recipient has not revealed the secret by a given block, the money goes back to the sender.
CSV: a relative lock that starts at confirmation
An absolute deadline is awkward when nobody knows in advance when a coin will land on chain. In July 2016 a single soft fork activated three proposals to fix that: BIP 68 (a meaning for the nSequence field), BIP 112 (the OP_CHECKSEQUENCEVERIFY opcode, replacing NOP3) and BIP 113 (how time is measured).
Under BIP 68, in transactions with version 2 or higher, each input's nSequence is read as the required age of the coin it spends:
- bit 31 switches the rule off entirely;
- bit 22 picks the unit: set means 512-second steps, unset means blocks;
- the value itself sits in the low 16 bits, so it cannot exceed 65,535.
That creates a ceiling: 65,535 blocks (BIP 68 calls it 1.25 years) or 33,554,431 seconds (1.06 years). You cannot lock a coin for five years with a relative timelock.
CSV checks that the input's nSequence is at least the number in the script. The clock starts when the output is mined, not when the script is written. BIP 112 lists escrow with a timeout, HTLCs, bidirectional payment channels and Lightning among its uses.
A worked example from November 22, 2026: block 977,082
Here is what this looks like with live numbers. Block 977,082 was mined on November 22, 2026 at 12:29 PM ET, per mempool.space.
Absolute deadline. The halving was 72,918 blocks away. It lands at height 1,050,000, which our network data estimated at around April 12, 2028. An output locked with 1050000 OP_CHECKLOCKTIMEVERIFY cannot be spent before that height, and the calendar date depends only on how fast blocks arrive.
Relative delay. A 144-block CSV is about one day: a coin confirmed in block 977,082 opens around block 977,226. The 65,535-block ceiling equals 455 days at the 10-minute target. Blocks were running faster than that, though. The average block time in the current difficulty period was about 9.2 minutes according to mempool.space, and at that pace the same 65,535 blocks would take roughly 418 days. That is a gap of more than a month.
Network time runs behind. Under BIP 113, time-based locks are compared with the median timestamp of the previous 11 blocks (median time past), not with a wall clock. For block 977,082 that median was 12:02 PM ET, 27 minutes behind the block's own timestamp. BIP 113 says such transactions take approximately an hour longer to confirm than under the old rules.
Timelocks in everyday payments. We checked the first 99 transactions in that block, excluding the coinbase. In 83 of them nLockTime was zero, in 8 it was 977,081 (the previous height), and in 8 more it was slightly lower. Those are not postdated payments. They are protection against fee sniping: the wallet sets the current height so that a miner gains nothing by re-mining an old block for its fees. BIP 326 also describes existing wallet behavior: with 10% probability, a random number from 0 to 99 is subtracted from the height.
Fees that evening were low, at 1–4 sat/vB on mempool.space, so moving coins to refresh a timelock would have cost little. Bitcoin's price over the previous 30 days ranged from $55,130 to $81,971 (our BTC data). The price can move a long way during a long lock, and there is no changing your mind.
Where timelocks are used in practice
Lightning. A channel uses both kinds. CSV protects against cheating in a unilateral close: per BOLT 2, to_self_delay sets how many blocks a node's own payout is delayed, which gives the counterparty time to contest an outdated state. CLTV caps the life of each payment in flight: the same document calls a cltv_expiry_delta of at least 34 blocks reasonable and gives 18 as the minimum for the final recipient. Channels are covered in our Lightning Network guide.
Inheritance and recovery. The Liana wallet describes two spending paths: a primary one that is always available, and a recovery path that opens after a period of inactivity. Its example gives a spouse and children access after one year and a third party after one year and three months, right at the CSV ceiling. The broader plan is in our piece on crypto inheritance planning.
Multisig with a fallback. A "2-of-3 now, 1-of-3 after a year" setup insures against a lost key. The base design is explained in Bitcoin multisig wallet.
Escrow and refunds. Buyer and seller lock coins under two signatures, and a timelock returns the money to the buyer if the deal stalls.
How to choose a timelock: step by step
- Decide what the clock counts from. A known date or height calls for an absolute lock (CLTV). An "inactivity timer" calls for a relative one (CSV).
- Decide who can cancel. If the author should be able to back out, nLockTime is enough. If not, the rule has to be in the script.
- Pick the unit. Blocks are predictable for the network but not for the calendar; time follows the median, not the clock.
- Check the limits: CSV tops out at 65,535 blocks.
- Store the script description (the descriptor) with your backup. Without it, coins under a non-standard condition cannot be found even with the seed phrase.
- Test the setup with a small amount or on a test network first, from funding to spending down every path.
Common mistakes
- Treating nLockTime as a lock. It delays one transaction and does nothing to stop another from spending the coins.
- Mixing heights and timestamps. Blockstream's post Don't Mix Your Timelocks (September 11, 2020) shows that two inputs with different timelock types cannot be spent in one transaction, and recommends that wallet developers avoid timestamp-based timelocks altogether.
- Forgetting to refresh. A relative timer runs separately for each coin. If the owner does not move the coins to themselves before it expires, the recovery path opens, possibly sooner than they wanted.
- Converting blocks to days with no margin. Block pace changes; in the example above the drift over a long lock exceeds a month.
- Locking with no fallback. CLTV cannot be undone. If a key is lost or the money is needed urgently before the deadline, the network makes no exceptions.
- Pre-signing with a fixed fee. A year later that fee may be too low; the ways to add more are in our guide to RBF and CPFP.
FAQ
What is the difference between CLTV and CSV? CLTV sets an absolute moment, a block or a date that is the same for everyone. CSV counts from the confirmation of a specific coin, so every coin has its own deadline.
Can a timelock be removed early? A script-level lock cannot, unless the script includes another spending path, such as a joint signature from all parties. An nLockTime transaction can be overtaken by a different transaction.
What is the longest you can lock bitcoin for? A relative timelock is capped at 65,535 blocks, about 1.25 years per BIP 68. An absolute lock has no such cap: the script names a block height or a date.
Are timelocks visible on the blockchain? nLockTime and nSequence are visible in every transaction. A script condition is revealed when it is spent; in Taproot, unused branches stay hidden.
This is not investment advice.



Comments