Difference between revisions of "Change"

m
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=== Introduction ===
 
=== Introduction ===
When the output of a transaction is used as the input of another transaction, the output must be spent in its entirety. The coin value of the output may be higher than what the user wishes to pay. In this case, the client generates a new Bitcoin address that spender owns, and sends the difference back to this address. This is known as [[change]].
+
When a UTXO is spent, it must be consumed entirely. If the value of the UTXO is greater than the amount being spent, then the difference in the amount must be allocated to a new address that the spender owns; this is a change address.
  
For example if a customer would like to buy a candy bar from a store for $1 but they only have a $20 bill. The customer cannot pay a partial denomination of the $20 bill; they must pay with the full bill and the merchant must give the customer change back. The merchant owes the customer $19 in this case. Bitcoin works in this same manner.
+
===Example 1===
 +
In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.
  
===Typical example===
+
In [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df this example], we can see that address 197vdcD73wQF5FviYXXgv6cXJBibc9phdq held a UTXO containing 47,097 [[Satoshis]].
In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.
+
 
 +
The sender paid 10,000 Satoshis to 1C7UVhVnspkxot82j6ooMxUUFEWy4Pj1tc and received 36,871 Satoshis as change into address 1LNq2ZePCj2mycctrvQqBVnTLeaJeyDeR4.
  
An example of this type of transaction can be viewed [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df here].
+
The difference of 226 Satoshis was paid as [[Transaction fees]] to the Miner who found block 605,046.
  
=== Change back to spending address ===
+
===Example 2===
In a naive implementation, the sender consumes a single UTXO as in the previous example, with the only difference being to receive the change into the same spending address. This means of transacting is not recommended as it does not take advantage of Bitcoin's privacy model.
+
In [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 this example], we can see more clearly that the difference between the input and output is the mining fee.
  
An example of this is [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 here].
+
In this transaction a UTXO held by address 13N2c1uxZee4LYGruhWED6K4P4D8Ncmepq is spent in a transaction that writes a message onto the ledger in an [[False_Return#OP_RETURN_Outputs|OP_RETURN output]], and receives the original amount minus the 276 Satoshi mining fee back into the same address.
  
 
=== Consolidating UTXOs ===
 
=== Consolidating UTXOs ===
In some cases, the spender may have many UTXOs that they would like to consolidate. This has the added benefit of reducing the network's total UTXOs, thus shrinking the database that all nodes must maintain. On the other hand the computation for processing these inputs could be high. Potentially miners could process these types of transactions at a lower rate.
+
In some cases, the spender may have many UTXOs that they would like to consolidate. In this situation, the only output is their 'change' address where the total amount, less mining fees is sent.
 +
 
 +
These 'consolidation transactions' have the added benefit of reducing the size of the UTXO set, shrinking the database that all nodes maintain. While the computation for processing these inputs could be expensive, it is envisaged that the savings in storage will encourage Miners to potentially process these types of transactions for a lower fee.
  
 
An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here].
 
An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here].
  
==See Also==
+
==Attribution==
 
+
This content is based on content sourced from https://en.bitcoin.it/wiki/Change under [https://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0]. Although it may have been extensively revised and updated, we acknowledge the original authors.
* [[Coin analogy]]
 
 
 
[[Category:Technical]]
 
[[Category:Vocabulary]]
 

Latest revision as of 02:51, 27 October 2020

Introduction

When a UTXO is spent, it must be consumed entirely. If the value of the UTXO is greater than the amount being spent, then the difference in the amount must be allocated to a new address that the spender owns; this is a change address.

Example 1

In a standard payment scenario, the sender consumes a single UTXO, paying the spending amount to the receiver's address, then receiving the change into a new address that they control to take advantage of privacy.

In this example, we can see that address 197vdcD73wQF5FviYXXgv6cXJBibc9phdq held a UTXO containing 47,097 Satoshis.

The sender paid 10,000 Satoshis to 1C7UVhVnspkxot82j6ooMxUUFEWy4Pj1tc and received 36,871 Satoshis as change into address 1LNq2ZePCj2mycctrvQqBVnTLeaJeyDeR4.

The difference of 226 Satoshis was paid as Transaction fees to the Miner who found block 605,046.

Example 2

In this example, we can see more clearly that the difference between the input and output is the mining fee.

In this transaction a UTXO held by address 13N2c1uxZee4LYGruhWED6K4P4D8Ncmepq is spent in a transaction that writes a message onto the ledger in an OP_RETURN output, and receives the original amount minus the 276 Satoshi mining fee back into the same address.

Consolidating UTXOs

In some cases, the spender may have many UTXOs that they would like to consolidate. In this situation, the only output is their 'change' address where the total amount, less mining fees is sent.

These 'consolidation transactions' have the added benefit of reducing the size of the UTXO set, shrinking the database that all nodes maintain. While the computation for processing these inputs could be expensive, it is envisaged that the savings in storage will encourage Miners to potentially process these types of transactions for a lower fee.

An example can be found here.

Attribution

This content is based on content sourced from https://en.bitcoin.it/wiki/Change under Creative Commons Attribution 3.0. Although it may have been extensively revised and updated, we acknowledge the original authors.