Overview
nLockTime is a 4-byte field present in every Bitcoin transaction that specifies the earliest time or block height at which the transaction can be included in a block. It is one of Bitcoin's original features, present since the very first version of the software, and serves as a fundamental building block for time-sensitive smart contracts and payment channels.
How nLockTime Works
nLockTime value interpretation:
0 → No lock (immediately valid)
1 to 499,999,999 → Block height lock
500,000,000 and above → Unix timestamp lock
Examples:
nLockTime = 800000 → Valid at block 800,000 or later
nLockTime = 1700000000 → Valid after Nov 14, 2023 (Unix time)
nLockTime = 0 → Valid immediately
Interaction with nSequence
For nLockTime to be enforced, at least one input in the transaction must have an nSequence value less than 0xFFFFFFFF. If all inputs have nSequence set to the maximum value, nLockTime is ignored and the transaction can be mined immediately. This interaction was part of Satoshi's original design for updatable transactions.
Use Cases
- Payment channels: Early versions of payment channels used nLockTime to create refund transactions that could only be broadcast after a timeout
- Inheritance planning: Creating time-locked transactions that transfer funds to heirs after a certain date
- Lightning Network: Used in combination with other timelocks for HTLC timeout paths
Common Misconceptions
nLockTime does not prevent a transaction from being created or signed — it only prevents it from being mined. A timelocked transaction can be constructed, signed, and shared at any time; it simply will not be accepted into a block until the specified condition is met. Also, nLockTime provides an absolute lock, while CSV (CheckSequenceVerify) provides a relative lock based on the age of the input being spent.