Mining Fees, Block Data, Block Headers, and Proof-of-Work
Now that we have some background on what the mining process does for Bitcoin, let's cover the specifics. This chapter covers the technical process, including mining fees, block data, block headers, and Proof-of-Work.
Structure of the Coinbase Transaction
With these calculations, Jing's node then constructs the coinbase transaction to pay himself 25.09094928 bitcoin.
As you can see in Coinbase transaction, the coinbase transaction has a special format. Instead of a transaction input specifying a previous UTXO to spend, it has a "coinbase" input. We examined transaction inputs in [tx_in_structure]. Let's compare a regular transaction input with a coinbase transaction input. The structure of a "normal" transaction input shows the structure of a regular transaction input, while The structure of a coinbase transaction input shows the structure of the coinbase transaction's input.
Table 1. The structure of a "normal" transaction input
Size | Field | Description |
---|---|---|
32 bytes |
Transaction Hash |
Pointer to the transaction containing the UTXO to be spent |
4 bytes |
Output Index |
The index number of the UTXO to be spent, first one is 0 |
1–9 bytes (VarInt) |
Unlocking-Script Size |
Unlocking-Script length in bytes, to follow |
Variable |
Unlocking-Script |
A script that fulfills the conditions of the UTXO locking script |
4 bytes |
Sequence Number |
Usually set to 0xFFFFFFFF to opt out of BIP 125 and BIP 68 |
Table 2. The structure of a coinbase transaction input
Size | Field | Description |
---|---|---|
32 bytes |
Transaction Hash |
All bits are zero: Not a transaction hash reference |
4 bytes |
Output Index |
All bits are ones: 0xFFFFFFFF |
1–9 bytes (VarInt) |
Coinbase Data Size |
Length of the coinbase data, from 2 to 100 bytes |
Variable |
Coinbase Data |
Arbitrary data used for extra nonce and mining tags. In v2 blocks; must begin with block height |
4 bytes |
Sequence Number |
Set to 0xFFFFFFFF |
In a coinbase transaction, the first two fields are set to values that do not represent a UTXO reference. Instead of a "transaction hash," the first field is filled with 32 bytes all set to zero. The "output index" is filled with 4 bytes all set to 0xFF (255 decimal). The "Unlocking Script" (scriptSig) is replaced by coinbase data, a data field used by the miners, as we will see next.