Andreas M Antonopoulos, the author of Mastering Bitcoin and a Bitcoin proponent, elucidated the reason Bitcoin transaction fee does not show up in the block explorer as a transaction output, during his recent Q&A session on Youtube. He also spoke about the where the payment is actually stored.
The author started by stating that the block explorer shows all the information except the transaction fees because the information is not included there. He added that a transaction fee does not include a specific output for fees and that fees are not explicitly a part of the transaction. Andreas further pointed two hurdles for including the transaction fees in the block explorer.
First, the miner’s address is required for output, and an output is needed in the transaction that can be redeemed by a miner. However, since there is no prior information on the miner, this is rendered impossible. Second, there would be an extra output in every transaction if fees were considered as one. So, if there are 4000 transactions in a block, then there would be 4000 extra output for transaction fees.
“Yet if the fees [of the transactions in that block] will all go to one miner [or mining pool], why do we need 4,000 outputs [Luckily], that is not how fees work.Fees are leftover, meaning you have inputs that bring a certain [amount of] value into a transaction, and then you have outputs that spend less than that.”
He went on to say:“The difference, the [portion] that is funded by the inputs but isn’t spent by the outputs, the over-fund of inputs minus outputs, whatever is left over, is the fee. You make a fee in a bitcoin transaction by funding the transaction with inputs… and then spending less than the entire amount. Whatever is left over is the fee. It is implicit, it is not explicit.”
This was followed by the author speaking about where the public address that receives all the fees is, including the payment. Here, he stated that they are included in the coinbase with the block where the transaction is mined.
“If you look at your transaction in a block and at the coinbase transaction of that block… the coinbase reward is 12.5 bitcoin. The coinbase transaction pays to a specific P2PKH, or it might be a different type of script, but usually it is a P2PKH. You can see which address the miner is [being paid] to, which is not the 12.5 bitcoin. They are [paid an amount like] 12.513621, 12.6, or 12.6253 [bitcoin]”
He further stated that the extra satoshis is the fees from all of the transactions included in the block.