> 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

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
