Difference between revisions of "Change"
(Created page with "=DISCLAIMER= This article is a direct copy of the original https://en.bitcoin.it/wiki/Transaction and has not been checked for correctness or edited. 9th October 2019 Expected...") |
|||
Line 1: | Line 1: | ||
− | = | + | === 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]]. | |
− | |||
− | |||
− | + | 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. | |
+ | ===Standard example=== | ||
+ | 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. | ||
+ | An example of this type of transaction can be viewed [https://whatsonchain.com/tx/d0033a539a426de7142f4b230328c84306b6ebc1c985515d522a411c397522df here]. | ||
+ | === Change back to spending address === | ||
+ | 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. | ||
+ | An example of this is [https://whatsonchain.com/tx/defaaec6d8687a27da68d2bd445dac9c1333c4460246309070a5a3cf40f3d6f0 here]. | ||
− | + | === 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. | ||
− | + | An example can be found [https://whatsonchain.com/tx/682e4ee70f5ba2a174e5427e4bdd645ee229ed64d2b9ca55d315035de6d85668 here]. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==See Also== | ==See Also== |
Revision as of 11:32, 15 January 2020
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.
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.
Standard example
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.
An example of this type of transaction can be viewed here.
Change back to spending address
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.
An example of this is here.
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.
An example can be found here.