# ZIP 68: Relative lock-time using consensus-enforced sequence numbers

Status: Draft

Owners: Daira-Emma Hopwood

Snapshot: a34cfc091434275120ff017c92c3b50d3cef623a

Source date: 2026-10-16T02:56:04+01:00

[Source revision](https://github.com/zcash/zips/commit/a34cfc091434275120ff017c92c3b50d3cef623a)

[Official source](https://zips.z.cash/zip-0068) · [Source file](https://github.com/zcash/zips/blob/a34cfc091434275120ff017c92c3b50d3cef623a/zips/zip-0068.rst)

Preamble

**ZIP**: 68

**Title**: Relative lock-time using consensus-enforced sequence numbers

**Owners**: [Daira-Emma Hopwood](mailto:daira@jacaranda.org)

**Credits**: 

- Mark Friedenbach
- BtcDrak
- Nicolas Dorier
- kinoshitajona

**Category**: Consensus

**Status**: Draft

**Created**: 2016-06-06

<a id="terminology"></a>

## Terminology

The key words "MUST" and "MAY" in this document are to be interpreted as described in RFC 2119.<a id="fnref1"></a>
[1](#fn1)

The "Median Time Past" of a block in this document is to be interpreted as described in <a id="fnref2"></a>
[2](#fn2).

<a id="abstract"></a>

## Abstract

This ZIP introduces relative lock-time (RLT) consensus-enforced semantics of the sequence number field, to enable a signed transaction input to remain invalid for a defined period of time after confirmation of its corresponding outpoint.

<a id="motivation"></a>

## Motivation

Zcash transactions have a sequence number field for each input, inherited from Bitcoin. The original idea in Bitcoin appears to have been that a transaction in the mempool would be replaced by using the same input with a higher sequence value. Although this was not properly implemented, it assumes miners would prefer higher sequence numbers even if the lower ones were more profitable to mine. However, a miner acting on profit motives alone would break that assumption completely. The change described by this ZIP repurposes the sequence number for new use cases without breaking existing functionality. It also leaves room for future expansion and other use cases.

The transaction `nLockTime` is used to prevent the mining of a transaction until a certain date. `nSequence` will be repurposed to prevent mining of a transaction until a certain age of the spent output in blocks or timespan. This, among other uses, allows bi-directional payment channels as used in<a id="fnref3"></a>
[3](#fn3) and<a id="fnref4"></a>
[4](#fn4).

<a id="specification"></a>

## Specification

This specification defines the meaning of sequence numbers for transactions in blocks after this proposal has activated.

If bit (1 << 31) of the sequence number is set, then no consensus meaning is applied to the sequence number and can be included in any block under all currently possible circumstances.

If bit (1 << 31) of the sequence number is not set, then the sequence number is interpreted as an encoded relative lock-time.

The sequence number encoding MUST be interpreted as follows:

Bit (1 << 22) determines if the relative lock-time is time-based or block based: If the bit is set, the relative lock-time specifies a timespan in units of 32 seconds granularity. The timespan starts from the Median Time Past of the output’s previous block, and ends at the Median Time Past of the previous block. If the bit is not set, the relative lock-time specifies a number of blocks.

Note: the 64-second time unit differs from Bitcoin's BIP 68, which uses a 512-second time unit.

The flag (1 << 22) is the highest order bit in a 3-byte signed integer for use in Zcash scripts as a 3-byte `PUSHDATA` with `OP_CHECKSEQUENCEVERIFY`<a id="fnref5"></a>
[5](#fn5).

This specification only interprets 22 bits of the sequence number as relative lock-time, so a mask of `0x003FFFFF` MUST be applied to the sequence field to extract the relative lock-time. The 22-bit specification allows for over 8.5 years of relative lock-time.

![../rendered/assets/images/zip-0068-encoding.png](https://raw.githubusercontent.com/zcash/zips/a34cfc091434275120ff017c92c3b50d3cef623a/rendered/assets/images/zip-0068-encoding.png)
A 32-bit field with 'Disable Flag' at bit (1 << 31), 'Type Flag' at bit (1 << 22), and 'Value' in the low 22 bits.

For time-based relative lock-time, 64-second granularity was chosen because the block target spacing for Zcash, after activation of the Blossom network upgrade, is 75 seconds. So when using block-based or time-based, roughly the same amount of time can be encoded with the available number of bits. Converting from a sequence number to seconds is performed by multiplying by 64.

When the relative lock-time is time-based, it is interpreted as a minimum block-time constraint over the input's age. A relative time-based lock-time of zero indicates an input which can be included in any block. More generally, a relative time-based lock-time n can be included into any block produced 64 * n seconds after the mining date of the output it is spending, or any block thereafter. The mining date of the output is equal to the Median Time Past of the previous block that mined it.

The block produced time is equal to the Median Time Past of its previous block.

When the relative lock-time is block-based, it is interpreted as a minimum block-height constraint over the input's age. A relative block-based lock-time of zero indicates an input that can be included in any block. More generally, a relative block lock-time n MAY be included n blocks after the mining date of the output it is spending, or any block thereafter.

The new rules are not applied to the `nSequence` field of the input of the coinbase transaction.

<a id="reference-implementation"></a>

## Reference Implementation

<a id="acknowledgments"></a>

## Acknowledgments

This ZIP is based on BIP 68, authored by Mark Friedenbach, BtcDrak, Nicolas Dorier, and kinoshitajona.

Credit goes to Gregory Maxwell for providing a succinct and clear description of the behavior of this change, which became the basis of the BIP text.

<a id="deployment"></a>

## Deployment

At the time of writing it has not been decided which network upgrade (if any) will implement this proposal.

This ZIP is designed to be deployed simultaneously with<a id="fnref6"></a>
[6](#fn6) and<a id="fnref7"></a>
[7](#fn7).

<a id="compatibility"></a>

## Compatibility

The only use of sequence numbers by the zcashd reference client software is to disable checking the `nLockTime` constraints in a transaction. The semantics of that application are preserved by this ZIP.

As can be seen from the specification section, a number of bits are undefined by this ZIP to allow for other use cases by setting bit (1 << 31) as the remaining 31 bits have no meaning under this ZIP. Additionally, bits (1 << 23) through (1 << 30) inclusive have no meaning at all when bit (1 << 31) is unset.

Unlike BIP 68 in Bitcoin, all of the low 22 bits are used for the value. This reflects the fact that blocks are more frequent (75 seconds instead of 600 seconds), and so more bits are needed to obtain approximately the same range of time.

The most efficient way to calculate sequence number from relative lock-time is with bit masks and shifts:

c++

// 0 <= nHeight <= 4194303 blocks (~10 years at post-Blossom block target spacing) nSequence = nHeight; nHeight = nSequence & 0x003fffff;

// 0 <= nTime <= 268435392 seconds (~8.5 years) nSequence = (1 << 22) | (nTime >> 6); nTime = (nSequence & 0x003fffff) << 6;

<a id="references"></a>

## References

---

1. [Key words for use in RFCs to Indicate Requirement Levels](https://tools.ietf.org/html/rfc2119)[↩︎](#fnref1)

2. [ZIP 113: Median Time Past as endpoint for lock-time calculations](https://github.com/daira/zips/blob/op-csv/zip-0113.rst)[↩︎](#fnref2)

3. [Reaching The Ground With Lightning (draft 0.2)](https://github.com/ElementsProject/lightning/raw/master/doc/deployable-lightning.pdf)[↩︎](#fnref3)

4. [ZIP 112: CHECKSEQUENCEVERIFY](https://github.com/daira/zips/blob/op-csv/zip-0112.rst)[↩︎](#fnref4)

5. [ZIP 112: CHECKSEQUENCEVERIFY](https://github.com/daira/zips/blob/op-csv/zip-0112.rst)[↩︎](#fnref5)

6. [ZIP 112: CHECKSEQUENCEVERIFY](https://github.com/daira/zips/blob/op-csv/zip-0112.rst)[↩︎](#fnref6)

7. [ZIP 113: Median Time Past as endpoint for lock-time calculations](https://github.com/daira/zips/blob/op-csv/zip-0113.rst)[↩︎](#fnref7)

## Citation relationships

Cites: [ZIP 112](https://zip-tools-web.harpocrates.workers.dev/zip/112), [ZIP 113](https://zip-tools-web.harpocrates.workers.dev/zip/113)

Cited by: [ZIP 112](https://zip-tools-web.harpocrates.workers.dev/zip/112), [ZIP 113](https://zip-tools-web.harpocrates.workers.dev/zip/113)