What is Timelock/Locktime?

Back to Glossary

In cryptocurrency, timelock (or locktime) is a restriction mechanism built into crypto transactions that define an actual time or block height to confirm a transaction on the blockchain network. Think of this as functionality for scheduling transactions.

Simply put, timelocks are a kind of smart contract primitive which wholly or partially hinders miners from confirming a specific transaction until certain conditions are met.

Classification/Conditions of Timelock

Every Bitcoin transaction since the initial Bitcoin release originally designed by Satoshi Nakamoto – the creator of Bitcoin – contain at least one locktime field that exists in its default state [ 0x00000000 (0) or 0xFFFFFFFF (4294967295) ]. However, they mainly had remained unused until several Bitcoin Improvement Protocols (BIP) events later. Bitcoin transactions that use timelocks (expressed in UNIX time) have three attributes – location, target or orientation, and metric.

Location: Timelocks can be based on location, i.e. a timelock at the transaction level or the script level. Although they exist as restrictions, they serve different purposes. A timelock at the transaction level ensures the transaction continues to fail validation until a specific time, even if its digital signatures are correct. On the other hand, a script-level timelock ensures script evaluation of digital signatures remain invalid until the transaction is locked. In summary, the main difference between them is that transaction-level time locks dictate when a transaction can be executed, while a script-level time lock dictates what transactions can take place altogether on the network.

Target/Orientation: Absolute time locks and Relative time locks. To keep this simple, they are both time-based locks relative to a specific time. They simply differ in that absolute locktime requires a set time, and the transaction is invalid until the specified time (say 13:00) is passed. Alternatively, relative time locks require a countdown to the earliest time miners can validate a transaction (i.e. if the transaction is locked for 8 hours, a countdown begins for that period of time, and the transaction is only valid after the countdown is completed).

Metric: Time is expressed in two metrics on the bitcoin network – block number and block time stamps. You guessed it. This means that timelocks can exist by specifying a specific block number before which the transaction remains invalid or a specific timestamp for which the transaction becomes valid.

Bitcoin timelocks generally have four major smart contract primitive options – nLocktime, nSequence, OP_CHECKLOCKTIMEVERIFY (OP_CLTV), and OP_CHECKSEQUENCEVERIFY (OP_CSV). Two of which are script-level time locks and two transaction-level time locks.