Was it always required for the Coinbase transaction to be the first transaction in a block?

3

The user tempo mentioned on another topic:

"At least in the early protocol versions it was possible to put the coinbase transaction not on the top of the outputs."

I have never heard about this before. Was the placement of the Coinbase transaction more flexible in earlier days or was it always necessary to put it as the first transaction in the block?

Murch

Posted 2019-11-14T15:47:28.963

Reputation: 41 609

Answers

5

This is not true. Code and code comments in v0.1.5 (the oldest tagged version in git) enforce that there always is a coinbase transaction and that it must always be the first. There cannot be a coinbase transaction elsewhere in the block. Coinbase transactions are defined as transactions with one input whose previous transaction hash is all 0's and whose previous output index is -1 (because it is an unsigned int, this becomes 0xffffffff).

You can also find a copy of the original 0.1.0 source code and find the same code and comments in the same place in main.cpp.

Andrew Chow

Posted 2019-11-14T15:47:28.963

Reputation: 40 910