<blockquote>
  <p>A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.</p>
</blockquote>

<p>This is not correct. The difference between the input amount and the output amount is exactly what we call <em>fee</em>. It is not lost.</p>

<blockquote>
  <p>It would seem the only way to do this would be to add new output to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.</p>
</blockquote>

<p>That is not possible. Miners cannot modify transactions.</p>

<p>Instead, there is simply a rule that the coinbase transaction (the first transaction in each block, created by the miner) is allowed to have outputs whose summed amount is up to the subsidy value (currently 25 BTC, soon 12.5 BTC) plus the sum of all the fees of the other transactions in the block.</p>

CC BY-SA 3.0
2016-07-06T12:04:11.443Z
2016-07-06T12:04:11.443Z
Pieter Wuille
<blockquote>
  <p>Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.</p>
</blockquote>

<p>No, not true. The discrepancy between the consumed inputs' value and the assigned outputs' value is the transaction fee.</p>

<p>Miners cannot change transactions or add outputs as that would invalidate the signature. Instead, they collect the transaction fees in the <a href="https://bitcoin.stackexchange.com/q/4571/5406">Coinbase transaction</a>.</p>

<p>The three relevant rules hereby are: </p>

<ol>
<li>For a regular transaction: <code>Σ(inputs) ≥ Σ(outputs)</code><br>
The difference may be collected as the transaction fee.</li>
<li>For the coinbase transaction: <code>output ≤ block subsidy + transaction fees</code><br>
The output is equal to block subsidy and fees when the miner collects it in full.</li>
<li>For a block: <code>Σ(inputs) + block subsidy ≥ Σ(outputs)</code><br>
Again, this is equal when the miner collects the maximum allowed reward.</li>
</ol>

CC BY-SA 3.0
2016-07-06T12:10:54.897Z
2016-07-06T12:15:57.453Z
2017-04-13T12:47:33.743Z
Murch
<p>A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.</p>

<p>When a transaction is first submitted there may be a discrepancy between the values of the inputs and outputs. The miner assembling the block may redirect that unaccounted for difference to themselves or any address they wish, called a "transaction fee", however my question is how do they do this?</p>

<p>It would seem the only way to do this would be to add <em>new output</em> to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.</p>

<p>However, isn't the transaction hashed to prevent someone from altering it? If a miner can alter it, why not alter it to just direct all the input to themselves?</p>

<transactions><transaction-fees><transaction-verification>
How are transaction fees claimed from a technical point of view?
Harry Pillsbury
# How are transaction fees claimed from a technical point of view?

(Asked by: username_0 on 2016-07-06)

A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.

When a transaction is first submitted there may be a discrepancy between the values of the inputs and outputs. The miner assembling the block may redirect that unaccounted for difference to themselves or any address they wish, called a "transaction fee", however my question is how do they do this?

It would seem the only way to do this would be to add *new output* to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.

However, isn't the transaction hashed to prevent someone from altering it? If a miner can alter it, why not alter it to just direct all the input to themselves?

**Tags:** transactions, transaction-fees, transaction-verification


---

## 2 answers

### Answer by username_1 on 2016-07-06. Score: 2 | Accepted answer

> A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.

This is not correct. The difference between the input amount and the output amount is exactly what we call *fee*. It is not lost.

> It would seem the only way to do this would be to add new output to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.

That is not possible. Miners cannot modify transactions.

Instead, there is simply a rule that the coinbase transaction (the first transaction in each block, created by the miner) is allowed to have outputs whose summed amount is up to the subsidy value (currently 25 BTC, soon 12.5 BTC) plus the sum of all the fees of the other transactions in the block.


---

### Answer by username_2 on 2016-07-06. Score: 1

> Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.

No, not true. The discrepancy between the consumed inputs' value and the assigned outputs' value is the transaction fee.

Miners cannot change transactions or add outputs as that would invalidate the signature. Instead, they collect the transaction fees in the [Coinbase transaction](https://bitcoin.stackexchange.com/q/4571/5406).

The three relevant rules hereby are:

1. For a regular transaction: `Σ(inputs) ≥ Σ(outputs)`  
   The difference may be collected as the transaction fee.
2. For the coinbase transaction: `output ≤ block subsidy + transaction fees`  
   The output is equal to block subsidy and fees when the miner collects it in full.
3. For a block: `Σ(inputs) + block subsidy ≥ Σ(outputs)`  
   Again, this is equal when the miner collects the maximum allowed reward.


---

