Ok, that's exactly what I'm trying to understand. How does the process of building a transactions with no inputs create a valid amount of UTXO for the miners coinbase?
In very broad strokes here
1 - Bitcoin Core node mine a winning hash
2 - Block is assembled from transactions in the mempool
3- Block reward transactions is created
4 - Block is written to the chain
5 - CoinBase is populated with new UTXO
Questions
1 - How is the verification of the winning hash done?
3 - How is the actual mining reward transaction created and verified
I'm studying currency inflation mechanisms, any incite would be greatly appreciated. -Thanks
Your understanding about how bitcoin works is not correct. Xynerise has explained a lot of it.
Lets skip blocks for a moment and think about transactions. As Xynerise explained, transactions spend previously unspent outputs, and create new unspent outputs. They "spend previously unspent outputs" by referencing them as inputs. Once an output has been referenced as an input in the blockchain, it is "spent" and can never again be referenced as an input in any other transaction.
Here's a nice analogy. It isn't a perfect representation, but it makes it easier to visualize inputs and outputs at the transaction level. Don't try to stretch the analogy all the way back to the behavior of blocks and confirmations. Imagine that each output is a lump of gold...
So, if you receive three payments:
1 BTC, 0.75 BTC, and 1.5 BTC
Then imagine that as lump of gold worth 1 BTC, a lump of gold worth 0.75 BTC, and a lump of gold worth 1.5 BTC.
Now you want to pay someone 1.25 BTC. Think of a transaction as a crucible in which you can melt and pour out lumps of gold.
You choose put the 1 BTC lump and the 0.75 BTC lump IN to the crucible. These are the "inputs" into your transaction. Then you turn on the fire and melt them. You now have a crucible with 1.75 BTC worth of gold in it. You pour OUT a 1.25 BTC lump of gold for the payment that you want to make. You still have 0.5 BTC worth of gold left in the crucible. Therefore, you pour OUT a second lump of gold worth 0.5 BTC and keep that for yourself. The original 1 BTC and 0.75 BTC lumps of gold are gone. They've been "spent" as inputs. Meanwhile two new outputs have been created (a 1.25 BTC output that you gave to the person you were paying, and a 0.5 BTC "change" output that you kept for yourself. If you choose to leave any gold in the crucible, then that becomes a transaction fee that the miner can mix into his coinbase crucible and include when he pours out his reward for himself. So, if you have only poured out a 0.49 BTC output for yourself, then there would have been 0.01 BTC worth of gold left in the crucible that the miner could scrape out and keep as a fee.
As for the "coinbase transaction" (also called the "generation transaction"). Imagine that the miner has a magical crucible. It is magically linked to all the other bitcoin crucibles that everyone else uses. It starts out empty, but when he tips it over it pours out some gold. Notice that he didn't put any gold IN it (there are no inputs), and yet some new gold comes OUT. It creates new outputs. You can see how this special crucible creates inflation (an increase in the total amount of gold in the world). This is where the analogy starts to fall apart a bit. The miner doesn't include the transaction fees as inputs. He does NOT put the gold from all the transaction crucibles INTO his coinbase crucible. Instead all the transaction fees from all of the transaction crucibles just disappear from all of their crucibles, and the amount of gold that pours out of this magical crucible is the current subsidy PLUS all those fees. Don't try to push this part of the analogy too far. There are conditions on how this coinbase crucible works and the analogy completely falls apart when you look at how blocks work (the output vanishes and the fees all go back to the transaction crucibles if the block is not included in the blockchain, the fees that pour out are only the fees of the transactions that were included in the block, multiple miners can all pour out the same fees at the same time while they are building their block, but only the fees of the block that makes it into the blockchain continue to exist, all the others vanish or go back to their transaction crucibles)
As has been explained by Xynerise, the bock process involves 5 steps in the following order:
- 1. Choose a set of valid unconfirmed transactions for your block.
- 2. Build your coinbase transaction with no inputs and paying outputs that sum to no more than the sum of the current subsidy (12.5 BTC right now) plus the transaction fees from all of the transactions selected in step 1.
- 3. Build the block header which references it's previous block, and has a merkle root commitment for the transactions of steps 1 & 2
- 4. Complete the proof of work on the block header created in step 3.
- 5. Broadcast the block completed in step 4 to all connected peers, and go back to step 1.
If at any time you receive a valid block from a connected peer, you need to abandon the block you are working on and immediately go back to step 1.
If at any time you discover that the block you are working on has no valid solution, then you need to modify your block header. This can be done by going back to step 3, 2, or 1.
In step 3 the block header can be modified by adjusting the block timestamp.
In step 2 the block header can be modified by adjusting the extranonce (a value is stored in the coinbase transaction in place of the missing inputs). After this you proceed to step 3 and have a different merkle root since the merkle root is based on this new data.
In step 1 the block header can be modified by adjusting the transaction selection or ordering. After this you proceed to step 2 since the new transaction selection might have a different transaction fees sum. Then you proceed to step 3 and have a different merkle root since the merkle root is based on this new data.