> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/bitcoin-protocol-documentation/concepts/sequence-and-locktime.md).

# Sequence and Locktime

nLockTime and nSequence finality

Two fields govern when a transaction is final: the transaction-level `nLockTime` and the per-input `nSequence`. Their exact encodings are in [Transactions](/bitcoin-protocol-documentation/specification/transactions.md#nlocktime); their role in the finality consensus rule is on the [Consensus Rules](/bitcoin-protocol-documentation/specification/consensus-rules.md#finality-nlocktime--nsequence) page. This page summarises the behaviour.

## nLockTime

`nLockTime` (4-byte LE) sets the earliest point at which a transaction may be mined:

* `0` — final immediately.
* below `LOCKTIME_THRESHOLD` (500,000,000) — a **block height**; final once the chain reaches that height.
* at or above the threshold — a **Unix timestamp**; final once that time is reached.

`nLockTime` has effect only while at least one input is non-final. If **every** input has `nSequence = 0xffffffff` (`SEQUENCE_FINAL`), the transaction is final regardless of `nLockTime`.

## nSequence

The only role of `nSequence` that affects validity in the current protocol is this finality flag: `0xffffffff` marks an input final. A value below `0xffffffff` marks the input non-final, which activates the `nLockTime` condition above.

{% hint style="warning" %}
The BIP68 **relative-locktime** interpretation of `nSequence` (and the original sequence-number transaction-replacement mechanism) applied **only before Genesis**, tied to `OP_CHECKSEQUENCEVERIFY`, which reverts to a no-op at Genesis. After Genesis, `nSequence` carries no relative-locktime meaning — see [Transactions](/bitcoin-protocol-documentation/specification/transactions.md#bip68-relative-locktime--pre-genesis-only).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hub.bsvblockchain.org/bitcoin-protocol-documentation/concepts/sequence-and-locktime.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
