TeachMeBitcoin

nLockTime vs. CLTV (BIP 65)

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

nLockTime vs. CheckLockTimeVerify (CLTV)

Bitcoin has two ways to enforce absolute timelocks: nLockTime (the transaction-level field) and CheckLockTimeVerify (the script-level opcode). While they serve similar goals, they operate at different stages of the protocol.

1. nLockTime (Transaction-Level)

2. CLTV (Script-Level / BIP 65)

3. How They Work Together

CLTV actually works by inspecting the nLockTime field. When a node runs a script containing CLTV, it checks:

  1. Is the value in the nLockTime field greater than or equal to the value specified in the script?

  2. Is the nSequence field set to enforce the lock (less than 0xffffffff)?

If these conditions are not met, the script fails, and the transaction is invalid. Essentially, CLTV forces a transaction to use a specific nLockTime.

4. Summary Table

Feature nLockTime CLTV (BIP 65)
Control Sender-controlled Enforced by the coin's lock
Visibility Public in the TX hex Hidden in the script (until spent)
Use Case Post-dating a payment Trustless escrow / Hashed Timelock Contracts (HTLCs)
Level Transaction Data Consensus Script

In the final section, we will build a Python Locktime Decoder.

☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!