THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin BIP68 Relative Locktime: Sequence Locks in Blocks and Time

permalink THAMER
#bip68#bitcoin#nsequence#relative-locktime#sequence-locks

BIP68 gives selected bits of an input's nSequence field a relative-locktime meaning. Unlike an absolute nLockTime, which refers to a chain height or timestamp, a sequence lock is evaluated relative to the confirmation history of the output being spent. The distinction matters in payment channels, recovery constructions, and transaction validation.

When BIP68 applies

BIP68 sequence locks apply to transactions with version 2 or higher. The sequence field is a 32-bit unsigned integer. Bit 31 is the disable flag: when set, that input does not impose a BIP68 relative lock. If it is clear, bit 22 selects the unit and the low 16 bits encode the relative value. Other reserved bits must not be treated as an arbitrary larger delay.

With the type flag clear, the relative value represents a number of blocks. With the type flag set, it represents intervals of 512 seconds. A value of 10 in time mode means 5,120 seconds of relative time, measured using consensus median-time-past rules rather than an exact countdown from the wallet's clock.

The origin of the delay

A height-based relative lock depends on the height at which the spent output was confirmed. Time-based locks use the relevant ancestor block's median-time-past context. An unconfirmed parent is treated conservatively for mempool sequence-lock evaluation, so a child transaction cannot assume a confirmation that has not happened.

BIP68 is checked per input and the transaction must satisfy the aggregate height and time constraints. A transaction with multiple inputs can therefore be held back by the most restrictive eligible input. Sequence locks do not force a node to broadcast the transaction once it becomes eligible.

BIP68 is not CHECKSEQUENCEVERIFY

BIP68 is a transaction-level consensus rule. BIP112 OP_CHECKSEQUENCEVERIFY is a Script opcode that can require a spending transaction to express a suitable relative locktime. The two mechanisms complement each other but are not interchangeable. Without a Script commitment, a signer may be able to choose a different sequence in a newly constructed transaction; with a committed CSV condition, the spending path imposes additional constraints.

Operational consequences

Software must avoid confusing 0xffffffff (final sequence), RBF signaling conventions, and BIP68 encoding. These uses overlap in the same field but serve different purposes. A sequence value that looks numerically large may have BIP68 disabled because bit 31 is set. Wallet implementations should decode flags explicitly, validate the transaction version, and test boundary conditions against real chain context.

Primary references

BIP68 — Relative lock-time using consensus-enforced sequence numbers: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki

BIP112 — CHECKSEQUENCEVERIFY: https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki

BIP113 — Median time-past: https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects