TeachMeBitcoin

Relative Timelocks (BIP 68)

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Relative Timelocks (BIP 68)

While nLockTime sets a specific date or block height for a transaction, Relative Timelocks (defined in BIP 68) allow an input to be locked based on the age of the coins being spent.

1. How it Works

A relative timelock says: "This input cannot be spent until 1,000 blocks have passed since the previous transaction was confirmed."

2. Bitwise Logic of nSequence

BIP 68 uses specific bits to define the lock:

3. Comparison with nLockTime

Feature nLockTime nSequence (BIP 68)
Lock Type Absolute (Date/Height) Relative (Age of UTXO)
Scope Entire Transaction Per-Input
Enabled By Sequence \u003c 0xffffffff Sequence bit 31 = 0

4. Use Case: Lightning Network

Relative timelocks are the foundation of the Lightning Network's security.

5. Hex Example

In the next section, we will discuss the 0xffffffff Sentinel and how it affects consensus.

☕ 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!