Time-Locked Transactions
Lesson by Uvin Vindula
Bitcoin Script includes powerful time-locking capabilities that allow you to create transactions that cannot be spent until a specific time or block height. These mechanisms enable sophisticated financial arrangements — from simple savings vaults to complex payment channels like the Lightning Network.
Types of Time Locks
Bitcoin supports four distinct time-locking mechanisms, divided into two categories:
Transaction-Level Time Locks:
- nLocktime: A field in every Bitcoin transaction that prevents the transaction from being included in a block until a specified time or block height. If nLocktime is set to block 900,000, the transaction simply cannot be mined until that block.
- nSequence: A per-input field that enables relative time locks — the transaction cannot be mined until a certain number of blocks have passed since the input's previous transaction was confirmed.
Script-Level Time Locks (Opcodes):
- OP_CHECKLOCKTIMEVERIFY (CLTV): Added in BIP 65. Allows a script to make Bitcoin unspendable until a specific absolute time or block height. The Bitcoin is locked in the UTXO itself.
- OP_CHECKSEQUENCEVERIFY (CSV): Added in BIP 112. Like CLTV, but uses relative time — Bitcoin cannot be spent until N blocks after it was received.
Absolute vs. Relative Time Locks
| Feature | Absolute (CLTV/nLocktime) | Relative (CSV/nSequence) |
|---|---|---|
| Unlocks at | Specific time/block | N blocks after confirmation |
| Use case | Savings vaults, future payments | Payment channels, Lightning |
| Example | "Locked until Jan 1, 2028" | "Locked for 144 blocks (~1 day)" |
Practical Use Cases
Time locks enable many real-world applications:
- Bitcoin savings vault: Lock your Bitcoin so it cannot be spent for 1 year — even if your keys are compromised, the attacker cannot move the funds until the lock expires, giving you time to act.
- Inheritance deadman switch: Create a time-locked transaction that sends Bitcoin to your heirs. If you're still alive, you reset the timer periodically. If you stop resetting, the funds automatically transfer after the lock expires.
- Lightning Network: Payment channels rely heavily on CSV (relative time locks) to enforce penalty mechanisms — if one party tries to broadcast an old channel state, the other party has a time window to claim all the funds as punishment.
- Escrow services: Time locks can create trustless escrow — funds are locked until both parties are satisfied, with automatic refund after a deadline.
Time Locks for Sri Lankan Users
Consider a Sri Lankan family that wants to set aside Bitcoin for a child's university education. Using CLTV, they can lock the Bitcoin until the year 2035, when the child turns 18. No one — not even the parents — can spend those funds early. This is a self-enforcing savings plan secured by mathematics, not by the discipline of the saver or the trustworthiness of a bank. Given Sri Lanka's history of currency devaluation (the rupee lost over 80% against the dollar from 2019 to 2023), time-locked Bitcoin offers a compelling alternative to traditional fixed deposits.
Key Takeaways
- •Bitcoin supports four time-lock mechanisms: nLocktime, nSequence, CLTV, and CSV
- •Absolute time locks (CLTV) lock until a specific date; relative locks (CSV) lock for N blocks after confirmation
- •Time locks enable savings vaults, inheritance planning, and Lightning Network channels
- •OP_CHECKLOCKTIMEVERIFY (CLTV) was added in BIP 65; OP_CHECKSEQUENCEVERIFY (CSV) in BIP 112
- •Time-locked Bitcoin cannot be spent early even if keys are compromised
Quick Quiz
Question 1 of 3
0 correct so far
What is the difference between CLTV and CSV?