Timelock
A timelock is a Bitcoin script condition that prevents a transaction output from being spent until a specified time or block height has passed. Timelocks enable advanced security constructs like delayed withdrawals, inheritance planning, and the Lightning Network's payment channels.
How It Works
Bitcoin supports several types of timelocks. The nLockTime field in a transaction prevents it from being included in a block before a specified block height or Unix timestamp. CheckLockTimeVerify (CLTV, BIP65) is a script opcode that makes an output unspendable until a certain block height or time. CheckSequenceVerify (CSV, BIP112) creates relative timelocks that count from when the output was confirmed, rather than from an absolute point.
Timelocks are essential building blocks for the Lightning Network. Payment channels use CSV-based relative timelocks to enforce a dispute period during channel closures. If one party broadcasts an old channel state, the other has a window of time to claim all the channel funds as penalty. Without timelocks, this fraud prevention mechanism would not be possible.
For self-custody, timelocks enable creative security architectures. A vault construct can require a time delay between initiating and completing a withdrawal, giving you time to cancel if the withdrawal was unauthorized. Inheritance planning can use timelocks to allow family members to access funds after a defined period of inactivity. These constructs add meaningful security layers without requiring trusted third parties.
Key Points
- Prevent spending until a specified time or block height
- nLockTime, CLTV (BIP65), and CSV (BIP112) are the main mechanisms
- Essential for Lightning Network payment channel security
- Enable vault constructs with delayed withdrawals for theft protection
- Useful for inheritance planning and dead man's switch implementations