# Locktime and sequence

Locktime stops a transaction confirming before a set block or time; sequence numbers enable RBF and relative timelocks. Learn how both work.

Canonical page: https://mybitcoinexplorer.com/learn/locktime-and-sequence
Topic: Transactions
Published: 2026-10-29
Updated: 2026-10-30


## Locktime: "not before"
Every transaction has a 4-byte **locktime** field.

| Locktime value | Meaning |
|---|---|
| 0 | No restriction |
| Below 500,000,000 | A block height: can't be mined before this block |
| 500,000,000 or more | A Unix timestamp: can't be mined before this time |

> Diagram: A transaction with locktime can't be confirmed before its unlock point — 900000

Locktime is only enforced if at least one input's sequence is not `0xffffffff`.

## Anti fee sniping
Many wallets set locktime to the current block height. This makes it slightly less attractive for a miner to rewrite the last block to steal its fees, because your transaction can't move into an earlier block.

## Sequence: per input
Each input has a 4-byte **sequence** field. Today it is used for:
- **Signalling [RBF](https://mybitcoinexplorer.com/learn/replace-by-fee-rbf)** (any value below `0xfffffffe`).
- **Relative timelocks** (BIP 68): "this input can't be spent until N blocks after the output it spends was confirmed". Used by [CSV](https://mybitcoinexplorer.com/learn/timelocks-cltv-csv) scripts and the [The Lightning Network](https://mybitcoinexplorer.com/learn/lightning-network).


## Quick reference
| Field | Value | Meaning |
|---|---|---|
| nLockTime | 0 | No restriction |
| nLockTime | 900000 | Not before block 900,000 |
| nLockTime | 1900000000 | Not before that Unix time (2030) |
| nSequence | 0xffffffff | Final: disables locktime for this input |
| nSequence | 0xfffffffd | Signals RBF, locktime enforced |
| nSequence | 144 (with bit 22 clear) | Relative lock: 144 blocks after confirmation |

Relative locks use the lower 16 bits as the count; bit 22 switches the unit from blocks to 512-second intervals.


## Key takeaways

- Locktime prevents confirmation before a given height or time.
- Values under 500 million are heights; larger values are timestamps.
- Sequence numbers enable RBF signalling and relative timelocks.

## Common questions

### Why does my wallet set a locktime I didn't ask for?

It's probably anti fee sniping: setting locktime to the current height is harmless and slightly improves security.

### What's the difference between locktime and CLTV?

Locktime restricts the whole transaction. CLTV is a script rule that restricts when a specific output can be spent.

### Can I schedule a Bitcoin payment for the future?

You can sign a transaction with a future locktime, but someone must broadcast it after that time, and you could spend the coins elsewhere before then.

### What is a relative timelock?

A lock counted from when the spent output was confirmed, rather than from a fixed date.

## Related lessons

- [Timelocks: CLTV and CSV](https://mybitcoinexplorer.com/learn/timelocks-cltv-csv)
- [Replace-by-fee (RBF)](https://mybitcoinexplorer.com/learn/replace-by-fee-rbf)
- [Anatomy of a raw transaction](https://mybitcoinexplorer.com/learn/anatomy-of-a-raw-transaction)
- [Payment channels](https://mybitcoinexplorer.com/learn/payment-channels)
