Passer au contenu

Bitcoin accepté au paiement  |  Expédié depuis Laval, QC, Canada  |  Soutien expert depuis 2016

Locktime (nLockTime)

Network & Protocol

Definition

Locktime (the nLockTime field) is a 4-byte value at the end of every Bitcoin transaction that specifies the earliest point at which the transaction may be included in a block. It enables absolute timelocks: "this payment cannot confirm until X". Until that point arrives, the network treats the transaction as non-final and refuses to mine it.

Block height vs. timestamp

A single threshold — 500,000,000 — decides how the value is read. Below it, nLockTime is interpreted as a block height: the transaction is valid only in a block after that height. At or above it, the value is a Unix timestamp. Since BIP113, the timestamp is compared against the median-time-past (the median of the previous 11 block timestamps) rather than the current block's clock, which removes a miner-manipulation surface and only ever moves forward.

The nSequence dependency

Locktime is only enforced if at least one input has a sequence number below 0xFFFFFFFF. If every input uses the maximum sequence value, nLockTime is ignored entirely. This quirk is why wallets that want an active locktime deliberately set inputs to 0xFFFFFFFE.

Locktime underpins protocols that need a deadline — refund branches, time-delayed recovery, and the commitment transactions inside the Lightning Network. A related opcode, OP_CHECKLOCKTIMEVERIFY (BIP65), lets a script enforce a locktime on the coins themselves rather than trusting the spender to set the field. We find it helpful to think of locktime as a "not before" stamp baked into the transaction, complementing the relative timelocks that sequence numbers provide.

In Simple Terms

Locktime (the nLockTime field) is a 4-byte value at the end of every Bitcoin transaction that specifies the earliest point at which the transaction may…

Explore the Full Glossary

Browse all Bitcoin mining terms from A to Z. Whether you are a beginner or expert, deepen your understanding of the mining ecosystem.

Glossaire du minage

ASIC Miner Database

Compare 500+ miners with real-time profitability data, home mining scores, and detailed specs.

Comparer les mineurs