Post
Topic
Board Development & Technical Discussion
Merits 6 from 5 users
Re: How does a miner receives a transaction fee
by
darosior
on 23/01/2020, 20:31:16 UTC
⭐ Merited by o_e_l_e_o (2) ,pooya87 (1) ,Heisenberg_Hunter (1) ,ETFbitcoin (1) ,Pmalek (1)
Hi,

Each block has a coingen transaction for the block subsidy - so far so good.
But how does the miner gets the fees of transactions in a block? Is there a "getTransactionFees()" transaction?

Transaction fees are implicit in Bitcoin tranasctions. They are the difference between the sum of the inputs' value and the sum of the outputs' value.
All transactions need to have `sum(outputs) <= sum(inputs)` (and not just equal! Which would, by the way not be relayed by most of the nodes).
A block generator needs to create a coinbase transaction outputs which value is <= to `block_subsidy + fees` with `fees = sum(inputs_of_all_txs) - sum(outputs_of_all_txs)` for other network (full) nodes to accept it.