I'm currently trying to generate the genesis block with my code and I've stumbled upon the TxIn sequence field that is not explained in the Protocol Specification wiki page, nor does it seem to appear in the block explorer. What is the way the value of this field is calculated, and what was its value for the genesis block?
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.
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.