BOMBARCHIVE
Explore

A living reference collection. Written in the wiki, preserved in Git.

The archiveBitcoin

Bitcoin timelocks

Bitcoin timelocks are rules that delay when a transaction, or a particular way of spending an output, may be included in a valid Bitcoin block. A lock can refer to an absolute block height or time, or to the relative age of a previously confirmed output. The distinction matters for refunds, payment channels, Lightning, and claims about when an asset becomes spendable. BIP 65 · BIP 68 · BIP 112

A timelock is not an alarm that broadcasts a payment, and an elapsed deadline is not a guarantee of confirmation. It says when a proposed spend becomes eligible; somebody must still construct, relay, and, if necessary, fee-bump the transaction, while miners decide which eligible transactions enter a block.

Two axes of time

  • Absolute versus relative. An absolute lock specifies an earliest chain height or time; a relative lock measures a duration after the output being spent was confirmed.
  • Transaction field versus script condition. Consensus can evaluate a proposed transaction's nLockTime or per-input nSequence. A script can additionally demand that the spend use a sufficiently restrictive value.
  • Height versus clock. Height-based conditions refer to the blockchain's ordered sequence, not a promised civil date. Time-based checks use consensus-defined interpretations of block time, not the observer's wall clock. See Bitcoin time.

These mechanisms were not introduced together. The original client already had a lock-time field and sequence numbers, but later upgrades gave them new and more enforceable uses.

The input-level history deserves its own reading: Bitcoin sequence numbers traces the original replacement mechanism, the all-final value 0xffffffff, BIP 68's version-2-and-higher relative-locktime encoding and the separate BIP 125 opt-in RBF threshold. Those meanings share a serialized field but do not share an enforcement layer. A modern fee-bump signal is not the same thing as an output-age restriction.

2009: the original code was height-based

The official Bitcoin source tagged v0.1.5, announced by Satoshi Nakamoto on 4 February 2009, contains both CTransaction::nLockTime and an IsFinal() method. It checks whether the field is zero or less than the best-known block height; if not, it tests whether every input's nSequence is final. This is direct evidence of height-based finality checking in the early client. There is no 500,000,000 timestamp threshold in that method. Bitcoin v0.1.5 — CTransaction::IsFinal · Nakamoto — v0.1.5 release message

An important limitation is visible in the companion source: the old mining path consulted transaction finality, but CBlock::AcceptBlock() did not yet reject blocks simply because they contained non-final transactions. Thus the early software's selection behaviour should not be described as if today's height/time lock rules were already a fully enforced 2009 consensus package. Bitcoin v0.1.5 — mining and block-acceptance code

A source commit dated 29 October 2009, cc0b4c3, changed both sides of that design. Its diff introduces a 500,000,000 threshold to interpret high lock-time values as time rather than height, and adds a future-height condition for rejecting blocks containing non-final transactions. The same change comments that time-based nLockTime was implemented in 0.1.6, while advising against using it before enough 0.1.5 nodes had upgraded. These facts come from the preserved source diff; they are not proof that every node changed behaviour on 29 October. Bitcoin — 29 October 2009 commit

The proposed enforcement gate was also revised. In the October commit, block acceptance checked finality only above a best-chain height of 31,000. On 6 December 2009, commit b075bbf moved that gate to above 36,000. Later source no longer carries a conditional startup gate and checks finality as part of accepting blocks. This is a traceable sequence of code revisions; establishing precisely which historical mainnet block first exercised the rule would require a separate chain-and-node audit. October source · December source · Bitcoin v0.3.12 block validation

This early history is easy to reverse in retrospect: height locks appear in the first publicly versioned code; timestamp-based interpretation came later. Neither stage created a self-executing Bitcoin escrow.

How absolute transaction locktime works

The contemporary nLockTime field is a four-byte unsigned value. A value below 500,000,000 denotes height; a value at or above it denotes a Unix timestamp. Zero disables the lock. For a nonzero lock to matter, at least one input must have an nSequence value below 0xffffffff; if every input is final, transaction-level locktime is bypassed. A transaction only satisfies the ordinary absolute comparison when its locktime is strictly less than the relevant candidate-block cutoff. BIP 65 — transaction and sequence interaction · BIP 113 — finality cutoff

For example, an otherwise valid spend with height locktime 840,000 and a non-final input is not made eligible for inclusion in block 840,000 by the mere equality of those numbers. At height 840,001, the height comparison can succeed. This illustrates the strict inequality, not a prediction that a miner will actually include the transaction there.

Because nLockTime constrains one signed transaction, it cannot by itself prove that the same coins are forbidden from moving earlier through a different transaction. The distinction was a central motivation for the later script opcode.

In Bitcoin Core 0.11.0 (2015), wallet software also began using a recent block-height locktime to discourage fee sniping in newly made transactions. This ordinary wallet behaviour does not indicate that a recipient arranged a long-term vault or a special collectible release schedule. Bitcoin Core 0.11.0 release notes — PR 2340

2014–2015: BIP 65 makes an output enforce a deadline

Peter Todd's BIP 65, assigned 1 October 2014, proposed OP_CHECKLOCKTIMEVERIFY (CLTV), redefining the previously reserved OP_NOP2. A locking script can demand that a spending transaction's nLockTime be at least a specified height or time. The opcode checks compatibility of the two lock types and rejects a finalized sequence on that input. Consensus's separate transaction-finality check then ensures the deadline has actually been reached. BIP 65 — specification, assignment and credits

This indirect comparison matters. CLTV does not read the current height or clock and spontaneously release coins. It verifies the transaction's own commitment to a sufficiently late deadline; ordinary consensus rules determine whether that transaction can enter the chain. BIP 65 credits Gregory Maxwell with suggesting comparison to transaction nLockTime rather than reading the block context inside script.

A commonly illustrated output allows Alice and Bob to spend cooperatively now but allows Alice alone after a specified deadline. The output's script can require the future deadline on its unilateral branch, making that particular spending path impossible before expiry even if somebody has Alice's signature. This is stronger than merely holding a pre-signed refund transaction. BIP 65 explicitly discussed escrow, two-factor wallet recovery, and earlier Jeremy Spilman-style channels. It does not itself prove any one of those applications was launched. BIP 65 — examples and historical motivation

CLTV was deployed as a Bitcoin consensus soft fork in December 2015. The current Bitcoin Core mainnet consensus-parameter source identifies its buried activation height as 388,381. An assigned BIP date, an implementation merged in source, and the height when new consensus rules apply are distinct milestones. Bitcoin Core — mainnet BIP65Height · BIP 65 — deployment mechanism

2015–2016: relative time and a second script opcode

The original nSequence had been used in transaction-version and replacement discussions. BIP 68 gave part of that same per-input field a new consensus-enforced relative locktime meaning for version-2-or-higher transactions. With bit 31 unset, its low sixteen bits encode a duration in blocks, or in 512-second units if bit 22 is set. The measured age is tied to confirmation of the output being spent, not to the date the owner created a transaction. BIP 68 — specification, motivation and compatibility

BIP 112 supplied the matching script primitive: OP_CHECKSEQUENCEVERIFY (CSV), replacing reserved OP_NOP3. A script branch can demand a minimum per-input relative lock. As with CLTV, the script checks the relevant commitment in the transaction; the chain-relative age requirement is separately enforced by consensus. A 144-block delay, for example, is measured in '''blocks after the spent output's confirmation**, not as an exact 24-hour countdown. BIP 112 — specification and motivating examples

**BIP 113''' changed the time cutoff used for transaction locktime from the containing block's miner-supplied timestamp to the median time past of the preceding eleven blocks. The median rule for validating block headers already existed at public launch; this upgrade reused that chain clock for transaction finality. It was intended in part to remove incentives to advance a block timestamp merely to include more time-locked transactions. See Bitcoin time for why block timestamps need not increase monotonically. BIP 113 — motivation and specification · Bitcoin's earlier block-time validation

The three proposals BIP 68, BIP 112 and BIP 113 were deployed together through BIP 9 signalling. In its contemporary notice of 21 June 2016, Bitcoin Core reported a successful lock-in period (1,946 of 2,016 signalling blocks) and warned miners to upgrade before block 419,328. The rules took effect there in July 2016. Bitcoin Core's maintained mainnet parameters also identify CSVHeight = 419328. This was an activation of base-layer spending rules, not the launch of Lightning software. Bitcoin Core — contemporary activation guidance · Maintained activation height

Relative delays matter when nobody can know in advance when an output will confirm. A channel's unilateral exit can grant the other party a period to react after commitment publication, rather than naming an arbitrary calendar date long before that event. That is part of why these rules were important building blocks for later Lightning channels, alongside subsequent transaction-malleability improvements and shared channel specifications.

What a record proves

A BIP proves a documented specification and its stated motivations. A commit proves source code changed. A chain activation height documents when a consensus rule applies; it does not reveal all wallets, services or contracts that adopted it. A particular locktime value in a confirmed transaction is not by itself proof of a specific commercial arrangement, nor does it establish when an off-chain counterparty first received a signature.

For historical Ordinals and Bitmap research, keep three clocks separate: '''the output's confirmation height**, the minimum height or median time when a later spend becomes valid, and **the actual confirmation height of that spend'''. The last one establishes where the revealed or transferred object enters Bitcoin's permanent history; the earlier deadline merely sets a lower bound.

From the archivist's desk

The small surprise here was buried in the first release-era code. Bitcoin had a lock-time field before it had today's clock interpretation, and its first height-based check did not mean every received block was rejected for breaking it. Later developers made the rule enforceable, made deadlines possible within scripts, and finally made delays relative to the output itself.

Time did not arrive in Bitcoin as one feature. It accumulated as several different promises, each with its own rules about who could act, when, and what counted as proof.

Open question
Trace the October–December 2009 finality-enforcement changes through exact historical mainnet heights and node release versions. The source gates at 31,000 and then 36,000 are documented, but this page has not independently tested historical block acceptance.
Open question
Recover a contemporaneous, independently identifiable on-chain CLTV or CSV spend from their first deployment periods, distinguishing script evidence from first-party application demonstrations.