2

I'm trying to understand how Bitcoin works but there's a concept I can't get my head around.

I understand that transactions are validated by checking the signatures of each input is valid. However how do you validate new bitcoins or rewards that have entered the system through mining if these don't contain any any inputs?

For example if you're checking a transactions inputs are valid eventually you'll reach the point when the inputs were originally mined, so how would you know these were created legitimately?

3

The first transaction of each block is special according to the Bitcoin Protocol, and people give it a special name: generation transaction (because it can generate new bitcoins) or coinbase transaction (because it's the only transaction to contain a field called the "coinbase" [the company Coinbase is named after this field, but is otherwise unrelated]).

Generation transations have the following rules (among others not relevant to your question):

  1. One, and exactly one, generation transaction must be present in every block. (If you've ever heard of "empty blocks", that just means a block with nothing besides the generation transaction.)

  2. They can only have one input.

  3. That input "spends" an output (outpoint) of all zeroes. This doesn't correspond to any actual transaction output.

  4. That all-zero outpoint is considered to contain the newly-generated bitcoins (subsidy) for this block as well as the transaction fees paid in this block (fees), which are collectively known as the block reward.

  5. The special input has a field called the coinbase field where the signature script (scriptSig) would go in a regular transaction. Anything put in this field is validated like in a normal transaction, but in the original Bitcoin protocol, miners were not required to put anything in this field at all---they didn't need to provide a signature since the only person who could've created this transaction as the first in the block was the miner themselves. Since them, BIP34 and BIP141 have changed the rules somewhat, but not in a way relevant to your question. Also not particularly relevant, the coinbase field is limited to 100 bytes in length.

Actual validation works like this:

  1. When a node receives a new block, it starts by looking at all of the transactions besides the generation transaction. It calculates how much transaction fee they all pay.

  2. Then the node calculates the amount of new bitcoins (subsidy) the miner is eligible to claim, for example 50 BTC for the first 210,000 blocks or 12.5 BTC as of this writing (blocks 420,000-629,999).

  3. The node adds these two numbers together. This is the maximum amount of block reward the miner can claim.

  4. Now the node looks at the generation transaction, makes sure it follows all of the other rules, and validates that its outputs spend a total of less than or equal to the block reward computed above.

Of interesting historical note, the generation transactions in over 1,000 blocks did not claim all the block reward they were eligible to claim. This seems to have mostly occurred early on. What happened to those bitcoins? They can't be claimed by the miners of those blocks after the fact and nobody else can claim them, so they're permanently lost.

0

from the wiki:

The coinbase is the content of the 'input' of a generation transaction. While regular transactions use the 'inputs' section to refer to their parent transaction outputs, a generation transaction has no parent, and creates new coins from nothing.

So the miner who mines the block is free to send the newly created coins to any address he wants. There is nothing to validate (other than it is the correct amount).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.