<p>When a sender creates a transaction, they explicitly define which pieces of bitcoin they spend. We call such pieces of bitcoin <em>Unspent Transaction Outputs (UTXO)</em> and you can think of the UTXO set as the distributed ledger of Bitcoin balances. The state of UTXO is ternary: they either don't exist yet, are available for spending, or have been spent. You can't deduct from a UTXO, they must be spent completely in one transaction.</p>
<p>Spenders explicitly pick the transaction inputs by referencing the UTXO via its unique outpoint <code>txid:vout</code> which is derived from the transaction that created the to-be-spent UTXO and its position in the output list.</p>
<p>After declaring the UTXO getting spent, the spender has assignable balance to the sum of the inputs' total value. The spender will  explicitly assign the value of the consumed inputs to new outputs. Any funds not assigned are considered transaction fees and will be collectable by the miner that includes the transaction in a block.</p>
<p>This means the total of assigned funds is less or equal than the value of the spent UTXOs, and the remainder is the transaction fee. The following hold true for non-<a href="https://bitcoin.stackexchange.com/q/4571/5406">coinbase</a> transactions:</p>
<ul>
<li><code>Σ(outputs) ≤ Σ(inputs)</code></li>
<li><code>transaction fees = Σ(inputs) - Σ(outputs)</code></li>
</ul>
<p>So, only the inputs and outputs on transactions are explicitly defined. The transaction fee is implicitly defined by the inputs and output.</p>
<p>It follows that a simple transaction sending to a single recipient will usually have two outputs:</p>
<ul>
<li>a recipient output to conduct the payment</li>
<li>a change output to return the remaining funds from the inputs to the sender</li>
</ul>
<p>I grabbed a random transaction from blockchair.com to visualize:</p>
<p><a href="https://i.sstatic.net/izzD7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/izzD7.png" alt="transaction with one input and two outputs of which one has a round number amount" /></a></p>
<p>If Alice's wallet had not created the change output to itself, Alice would have paid 11,044.… BTC in additional fees. ;)</p>
<p>Note, that I'm simply guessing that the 610 BTC is the recipient output due to the round number, I'm not intimately familiar with this transaction.</p>

CC BY-SA 4.0
2020-05-07T15:00:24.303Z
2022-03-22T17:37:09.560Z
2022-03-22T17:37:09.560Z
Murch
<p>I'm learning that Bitcoin doesn't have a way to represent the account balance, but it's, rather, a sum of UTXO owned by the users of the private key.  Then where is the change from the output stored? </p>

<p>What I mean is, when the output of a transaction is used as the input of another transaction, it must be spent in its entirety. Sometimes the coin value of the output is higher than what the user wishes to pay. In this case, the client generates a new Bitcoin address, and sends the difference back to this address. </p>

<p>Does the change get stored back in UTXO? </p>

<bitcoin-core><transactions><balance><change>
Where is the change from the output stored in?
Kevvv
# Where is the change from the output stored in?

(Asked by: username_0 on 2020-05-07)

I'm learning that Bitcoin doesn't have a way to represent the account balance, but it's, rather, a sum of UTXO owned by the users of the private key. Then where is the change from the output stored?

What I mean is, when the output of a transaction is used as the input of another transaction, it must be spent in its entirety. Sometimes the coin value of the output is higher than what the user wishes to pay. In this case, the client generates a new Bitcoin address, and sends the difference back to this address.

Does the change get stored back in UTXO?

**Tags:** bitcoin-core, transactions, balance, change


---

## 1 answers

### Answer by username_1 on 2020-05-07. Score: 6 | Accepted answer

When a sender creates a transaction, they explicitly define which pieces of bitcoin they spend. We call such pieces of bitcoin *Unspent Transaction Outputs (UTXO)* and you can think of the UTXO set as the distributed ledger of Bitcoin balances. The state of UTXO is ternary: they either don't exist yet, are available for spending, or have been spent. You can't deduct from a UTXO, they must be spent completely in one transaction.

Spenders explicitly pick the transaction inputs by referencing the UTXO via its unique outpoint `txid:vout` which is derived from the transaction that created the to-be-spent UTXO and its position in the output list.

After declaring the UTXO getting spent, the spender has assignable balance to the sum of the inputs' total value. The spender will explicitly assign the value of the consumed inputs to new outputs. Any funds not assigned are considered transaction fees and will be collectable by the miner that includes the transaction in a block.

This means the total of assigned funds is less or equal than the value of the spent UTXOs, and the remainder is the transaction fee. The following hold true for non-[coinbase](https://bitcoin.stackexchange.com/q/4571/5406) transactions:

* `Σ(outputs) ≤ Σ(inputs)`
* `transaction fees = Σ(inputs) - Σ(outputs)`

So, only the inputs and outputs on transactions are explicitly defined. The transaction fee is implicitly defined by the inputs and output.

It follows that a simple transaction sending to a single recipient will usually have two outputs:

* a recipient output to conduct the payment
* a change output to return the remaining funds from the inputs to the sender

I grabbed a random transaction from blockchair.com to visualize:

[![transaction with one input and two outputs of which one has a round number amount](https://i.sstatic.net/izzD7.png)](https://i.sstatic.net/izzD7.png)

If Alice's wallet had not created the change output to itself, Alice would have paid 11,044.… BTC in additional fees. ;)

Note, that I'm simply guessing that the 610 BTC is the recipient output due to the round number, I'm not intimately familiar with this transaction.


---

