The Sequence Field Overview
The 4-Byte Sequence Field
Every input in a Bitcoin transaction contains a 4-byte field called nSequence. While often overlooked, this field is the foundation for advanced features like Replace-By-Fee (RBF) and the Lightning Network.
1. Original Purpose
Satoshi Nakamoto originally intended the Sequence field to be used for "High-Frequency Trades" (the first concept of payment channels).
-
A user could update a transaction by increasing the sequence number.
-
Miners would theoretically only mine the version with the highest sequence number.
-
However, this was insecure because there was no way to force miners to ignore lower sequence numbers.
2. Modern Purpose
Today, the Sequence field has been repurposed for three main features:
-
Enabling Locktime: If all sequence numbers in a transaction are
0xffffffff, the nLockTime field is ignored. -
Replace-By-Fee (RBF): Signaling that a transaction in the mempool can be replaced with a higher-fee version.
-
Relative Timelocks: Locking an input based on the age of the coins being spent.
3. Data Format
The field is a 4-byte Unsigned Integer (uint32) stored in Little-Endian.
-
Max Value:
0xffffffff(4,294,967,295) -
Standard RBF Value:
0xfffffffd(MAX - 2)
4. The RBF Threshold
Any sequence value less than 0xffffffff is generally treated by modern nodes as a signal that the transaction is "malleable" or replaceable while it is still in the mempool.
| Property | Value |
|---|---|
| Size | 4 Bytes |
| Storage | Little-Endian |
| Logic | Input-level |
| Scope | Mempool replacement \u0026 Timelocks |
In the next section, we will explore the mechanics of Replace-By-Fee (RBF).
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: