From Chapter 4: “A rule like that is called a timelock.”
A rule about when coins can move
A timelock is a rule written into a coin: not before this block. Until that block arrives, every node refuses the payment, even with the right key.
The idea
Normally, whoever holds the key can move the coins at any time. A timelock adds one more condition: not before a certain point. Until then, every node on the network refuses the payment, even if the signature is perfect. The rule lives on the ledger, so no company, judge or owner can change it.
A timelock locks the coins, not the price. The bitcoin still goes up and down in dollars while it waits.
Two kinds
Absolute: “not before block X” (or a date). The coins cannot move until the chain reaches a certain block height, or a certain date and time.
Relative: “not until N blocks after this coin arrived.” The clock starts when the coin is confirmed. The longest relative lock is 65,535 blocks, about 15 months, or about 388 days if it is counted in time instead of blocks.
| Absolute | Relative | |
|---|---|---|
| The rule | Not before block X (or date X) | Not until N blocks after confirmation |
| Inside the coin’s lock | OP_CHECKLOCKTIMEVERIFY (BIP 65, 2015) | OP_CHECKSEQUENCEVERIFY (BIP 112, 2016) |
| On the payment itself | the transaction’s lock time | the input’s sequence number (BIP 68, 2016) |
| Typical use | A future payment, a deadline | Lightning channels, backup keys, vaults |
A detail you may see: the same lock-time field holds either a block height or a date. A number below 500 million means a block height. A number at or above it means a date, counted in seconds since January 1, 1970.
Why block height and not a date?
Blocks arrive about every ten minutes on average, but not exactly. A height is a rule every node can check the same way.
Where timelocks show up
- Lightning. Each channel uses relative timelocks so that a cheating partner can be caught and punished before the money leaves.
- Inheritance and backup keys. A wallet can say: “My key works anytime. My family’s key works only if the coins have not moved for a year.” If you are alive, you move the coins once a year and the clock resets.
Two things the lock does not do. It does not make the key optional: if the key is lost, the coins stay locked forever. And it does not hide anything: the address and the amount are public.
How many days until block 1,000,000? Find today’s block height on mempool.space. Subtract it from 1,000,000. Divide by 144, the number of blocks in an average day.
New to mempool.space? Start with the guide at YourBitcoinBasics.com/mempool
Words on this page
- Address
- The number on the mailbox, the thing you hand to someone who wants to pay you.
- Bitcoin Improvement Proposal (BIP)
- A written proposal to change how Bitcoin works.
- Block
- A page of the ledger, a batch of transactions added about every 10 minutes.
- Block height
- A block’s number in the chain, counted from the first block in 2009.
- Confirmation
- One more block stacked on top of the one your transaction is in.
- Ledger
- A list of who owns how much.
- Mempool
- The queue of checked, unconfirmed transactions, waiting for a miner to put them in a block.
- Money
- What people widely accept as payment, use to save, and use to count what things are worth. Chapter 3 shows where the dollar comes from.
- Node
- A computer with a full copy of the ledger that checks everything for itself.
- Timelock
- A rule that says these coins cannot move until a set time has passed.
- Wallet
- The app or device you use to hold and send bitcoin.
Sources
- BIP 65, “OP_CHECKLOCKTIMEVERIFY,” github.com/bitcoin/bips/blob/master/bip-0065.mediawiki.
- BIP 68, “Relative lock-time using consensus-enforced sequence numbers,” github.com/bitcoin/bips/blob/master/bip-0068.mediawiki.
- BIP 112, “CHECKSEQUENCEVERIFY,” github.com/bitcoin/bips/blob/master/bip-0112.mediawiki.
- Lock-time values below and above 500,000,000: Bitcoin Developer Documentation, “Transactions: Locktime and Sequence Number,” developer.bitcoin.org.
- Output script descriptors and Miniscript: Bitcoin Core, doc/descriptors.md; bitcoin.sipa.be/miniscript.
- Lightning’s use of timelocks: BOLT 3, “Bitcoin Transaction and Script Formats,” github.com/lightning/bolts.