<p>Note that the accepted answer is outdated.</p>

<p>Currently, sequence numbers are mainly used for signaling RBF - replace-by-fee - that allows you to resend a transaction with a higher fee.</p>

<p>See <a href="https://bitcoincore.org/en/faq/optin_rbf/" rel="noreferrer">https://bitcoincore.org/en/faq/optin_rbf/</a> , <a href="https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki</a></p>

CC BY-SA 3.0
2017-07-01T13:41:01.297Z
2017-07-01T13:41:01.297Z
Karel Bílek
<p>Sequence numbers aren't shown on the Bitcoin Block Explorer HTML pages because they are not used by the network currently. Non-default sequence numbers would be shown on raw block/tx pages, but I'm not sure whether this has ever happened.</p>

<p>Sequence numbers are intended to be used for replacement. Replacement is currently disabled, but how it would work is:</p>

<ul>
<li>You send a transaction with a LockTime in the future and a sequence number of 0. The transaction is then not considered by the network to be "final", and it can't be included in a block until the specified LockTime is reached.</li>
<li>Before LockTime expires, you can replace the transaction with as many new versions as you want. Newer versions have higher sequence numbers.</li>
<li>If you ever want to lock the transaction permanently, you can set the sequence number to UINT_MAX. Then the transaction is considered to be final, even if LockTime has not been reached.</li>
</ul>

<p>This is useful in several cases. For example, two parties can use it to set up a "prepared transaction". Once the prepared transaction is created, the parties can move money between each other instantly, securely, and without fees. So you could set one of these up with an exchange and withdraw and deposit without waiting for confirmations.</p>

<p>Since replacement is not used currently, all transactions Bitcoin creates have LockTime = 0 and Sequence = UINT_MAX. This is the case with the genesis block's generation transaction.</p>

CC BY-SA 3.0
2014-03-08T06:12:01.880Z
For reference UINT_MAX = 4294967295U
makerofthings7
CC BY-SA 3.0
2017-02-15T14:30:09.367Z
Your answer seems to assume that a transaction has **a single sequence number**, but according to the protocol specification, a transaction will have a sequence number _per each input_. In this case, I'm not sure how replacement would work. Consider a transaction with two inputs: input #0 has seqno 1 and input #1 has seqno 2. How would this transaction be compared to one where input #0 has seqno 2 and input #1 has seqno 1?
Alin Tomescu
CC BY-SA 3.0
2018-02-19T13:40:03.913Z
UINT_MAX is a 32 bit value. In hex it is "FFFFFFFF".
Thorkil Værge
CC BY-SA 3.0
2018-03-05T02:54:22.877Z
This answer seems to be outdated.  See the answer of https://bitcoin.stackexchange.com/a/55113/47528
Yuki Inoue
CC BY-SA 3.0
2011-12-23T16:54:39.373Z
How does the network determine whether to accept a new version as a replacement transaction? Could an attacker replace transactions maliciously?
jl6
CC BY-SA 3.0
2012-02-11T04:38:58.653Z
Non-default sequence numbers have happened.  Once in January 2011 and 6 times in February 2011.  The sequence number was zero in each case.  See transaction c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73 for an example.  http://blockexplorer.com/rawtx/c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73
Chris Moore
CC BY-SA 3.0
2011-11-20T21:33:23.600Z
2011-11-20T21:38:42.927Z
2011-11-20T21:38:42.927Z
theymos
<p>I'm currently trying to generate the genesis block with my code and I've stumbled upon the <a href="https://en.bitcoin.it/wiki/Protocol_specification#tx">TxIn sequence</a> field that is not explained in the Protocol Specification wiki page, nor does it seem to appear in the <a href="http://blockexplorer.com/rawtx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b">block explorer</a>. What is the way the value of this field is calculated, and what was its value for the genesis block?</p>

<transactions><protocol><raw-data><genesis-block><sequence>
What is TxIn's sequence?
ThePiachu
# What is TxIn's sequence?

(Asked by: username_0 on 2011-11-20)

I'm currently trying to generate the genesis block with my code and I've stumbled upon the [TxIn sequence](https://en.bitcoin.it/wiki/Protocol_specification#tx) field that is not explained in the Protocol Specification wiki page, nor does it seem to appear in the [block explorer](http://blockexplorer.com/rawtx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b). What is the way the value of this field is calculated, and what was its value for the genesis block?

**Tags:** transactions, protocol, raw-data, genesis-block, sequence


---

## 2 answers

### Answer by username_2 on 2011-11-20. Score: 35 | Accepted answer

Sequence numbers aren't shown on the Bitcoin Block Explorer HTML pages because they are not used by the network currently. Non-default sequence numbers would be shown on raw block/tx pages, but I'm not sure whether this has ever happened.

Sequence numbers are intended to be used for replacement. Replacement is currently disabled, but how it would work is:

* You send a transaction with a LockTime in the future and a sequence number of 0. The transaction is then not considered by the network to be "final", and it can't be included in a block until the specified LockTime is reached.
* Before LockTime expires, you can replace the transaction with as many new versions as you want. Newer versions have higher sequence numbers.
* If you ever want to lock the transaction permanently, you can set the sequence number to UINT\_MAX. Then the transaction is considered to be final, even if LockTime has not been reached.

This is useful in several cases. For example, two parties can use it to set up a "prepared transaction". Once the prepared transaction is created, the parties can move money between each other instantly, securely, and without fees. So you could set one of these up with an exchange and withdraw and deposit without waiting for confirmations.

Since replacement is not used currently, all transactions Bitcoin creates have LockTime = 0 and Sequence = UINT\_MAX. This is the case with the genesis block's generation transaction.

> **Comments:**
> **username_7**: How does the network determine whether to accept a new version as a replacement transaction? Could an attacker replace transactions maliciously?  
> **username_8**: Non-default sequence numbers have happened.  Once in January 2011 and 6 times in February 2011.  The sequence number was zero in each case.  See transaction c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73 for an example.  http://blockexplorer.com/rawtx/c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73  
> **username_3**: For reference UINT_MAX = 4294967295U  
> **username_4**: Your answer seems to assume that a transaction has **a single sequence number**, but according to the protocol specification, a transaction will have a sequence number _per each input_. In this case, I'm not sure how replacement would work. Consider a transaction with two inputs: input #0 has seqno 1 and input #1 has seqno 2. How would this transaction be compared to one where input #0 has seqno 2 and input #1 has seqno 1?  
> **username_5**: UINT_MAX is a 32 bit value. In hex it is "FFFFFFFF".  
> **username_6**: This answer seems to be outdated.  See the answer of https://bitcoin.stackexchange.com/a/55113/47528  

---

### Answer by username_1 on 2017-07-01. Score: 28

Note that the accepted answer is outdated.

Currently, sequence numbers are mainly used for signaling RBF - replace-by-fee - that allows you to resend a transaction with a higher fee.

See <https://bitcoincore.org/en/faq/optin_rbf/> , <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki>


---

