In a coinbase transaction there are always more than two transaction outputs.
The first transaction output contains the reward. The second contains the witness reserved value.
But why are there other transaction outputs OP_RETURN
with 0 Satoshis? Are they necessary?
1 Answer
A coinbase transaction can have as many outputs as the miner who created it wants. You may see that there are not just one output for the reward, sometimes there are multiple outputs so that the coinbase transaction pays to multiple miners. Additionally, there may be other 0 value OP_RETURN outputs if the miner so chooses. Typically this is because the miner wants to include some additional data for another protocol that they are using.
Additional outputs are not required by Bitcoin's consensus protocol. In fact, Bitcoin does not require any particular outputs. A miner could forfeit all of the generated coins by creating an output with less than the correct amount. A miner can include other OP_RETURN outputs just because they feel like it. Even the BIP 141 OP_RETURN is only required if the block contains any segwit transactions, so if it does not, it doesn't need to be included.
The most common reason for other outputs that go to addresses and have positive value is for mining pools which directly pay their miners from the coinbase reward. Most mining pools do not do this, but some do. There are also peer-to-peer mining pools such as p2pool which directly pay the participating miners from the coinbase transaction.
For additional OP_RETURN outputs, the miner is typically participating in another consensus protocol that require commitments in the block. These are not required for Bitcoin, but rather for something else. There are two common protocols that miners participate in: p2pool, and merged mining. P2pool uses an additional OP_RETURN output to commit to some p2pool data that is stored elsewhere. Merged mining uses the Bitcoin blockchain to help protect an altcoin's blockchain by including a commitment from the altcoin in a Bitcoin block. This is typically done by including a hash in an OP_RETURN output.