How are transaction fees collected in Bitcoin?

1

I'm looking into the structure of blocks in the Bitcoin blockchain, and I can't figure out when\how the fees collected by miner of the blocks are transferred to the miner. According to what I can tell they are not a part of the coinbase transaction (which as I understand has to be constant since changing it after discovering a block would change the hash of the block). Are the fees paid as separate a transaction? Are they written directly to the UTXO without appearing on the blockchain? Something else?

Thanks!

MayaD

Posted 2018-11-04T17:59:11.750

Reputation: 11

Question was closed 2018-11-04T18:24:32.863

Answers

1

The coinbase transaction itself has the subsidy/coins for mine a block + all fees of the transactions of that block.

Aitorjs

Posted 2018-11-04T17:59:11.750

Reputation: 11

Thanks! If this is the case, how is this implemented in a way which does not change the hash of the block once it's filled out?MayaD 2018-11-04T19:42:49.867

@MayaD The entire contents of the (candidate) block, including the subsidy payout, is determined before mining even begins. Nothing can be modified about a block afterwards, as it would invalidate the proof of work. When a miner wants to update the contents of the block they're working on, mining continues by working on a new, updated, block candidate.Pieter Wuille 2018-11-07T06:43:36.387

Thanks again! If this is the case, is there a way of determining which part of the fee paid to user x came from user y? Do you maybe have a reference to the relevant place in the source code?MayaD 2018-11-12T18:53:56.537