The 500 Million Threshold
The 500 Million Threshold
A unique feature of the nLockTime field is that it can represent two completely different types of measurements: Block Heights or Unix Timestamps. The protocol distinguishes between them using a fixed threshold.
1. The Magic Number: 500,000,000
Bitcoin uses the number 500 million as the separator.
Case A: Block Height
If nLockTime is less than 500,000,000, it is interpreted as a Block Height.
-
Example:
nLockTime = 800000 -
Meaning: The transaction is valid once the blockchain reaches height 800,000.
Case B: Unix Timestamp
If nLockTime is greater than or equal to 500,000,000, it is interpreted as a Unix Timestamp (seconds since Jan 1, 1970).
-
Example:
nLockTime = 1625097600 -
Meaning: The transaction is valid after June 30, 2021.
2. Why this Threshold?
When Bitcoin was created, the current Unix time was already over 1.2 billion. Satoshi knew that the block height would not reach 500 million for thousands of years (at 10 minutes per block, 500 million blocks takes ~9,500 years). This allowed the protocol to "overload" a single 4-byte field with two different functions without risk of collision.
3. Comparison of Locks
| nLockTime Value | Interpretation | Valid Date (Approx) |
|---|---|---|
| 0 | Immediate | Now |
| 750,000 | Block Height | ~2022 |
| 499,999,999 | Block Height | ~Year 11500 |
| 500,000,000 | Unix Timestamp | Jan 1985 (Retroactive) |
| 1,600,000,000 | Unix Timestamp | Sept 2020 |
4. Median Time Past (MTP)
To prevent miners from manipulating their system clocks to "unlock" time-locked transactions early, Bitcoin uses Median Time Past (MTP). A timestamp-based lock is only considered reached if the median of the last 11 blocks is greater than the nLockTime.
In the next section, we will explore the mandatory Interaction with nSequence.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: