<p>Many wallet software obfuscate the information about payment and change address in order to protect the privacy of the user. When you see block explorer websites showing addresses in the outputs as change addresses, they are merely guessing as there is no sure shot way of knowing. Some of the techniques used to identify change addresses are below. I have also mentioned the current steps taken to prevent detection of such change addresses.</p>

<ul>
<li><strong>Sending change back to the same address:</strong> If you send the change back to the same address from which you are initiating the transaction, then there is high likelihood of that address being a change address. This is mitigated by preventing address re-use.</li>
<li><strong>Change goes back to the same address type:</strong> If you initiated a transaction from a native segwit address (addresses starting with bc1) to a P2SH address (starting with 3). In some wallets, the change will be sent to the native segwit (bc1) address as that is the default for your wallet, thus leaking which output is the change. This is prevented by making the change address match the format of the payout address in order to mask privacy.</li>
<li><strong>Coin selection:</strong> Assume you want to make a payment of 5 BTC for your coffee (let's hope that the coffee is that good :-)). Your wallet contains two UTXOs: 4 BTC and 3 BTC. To make a payment of 5 BTC, you will have to use both UTXOs and send 2 BTC change back to yourself. Now, the person looking at this transaction would think that if you wanted to make a 2 BTC payment you would have just used your 3 BTC output and sent 1 BTC as change as compared to using both the UTXOs. Thus it is revealed that the 2 BTC is in fact a change output rather than a payment output. Wallet softwares might create two or more change addresses in order to mask which is exactly the change address, or if multiple UTXOs exist, it will optimally select those UTXOs in order to prevent such leak.</li>
<li><strong>Change address is the last output:</strong> If you build your transaction in such a way that your payment addresses comes first and change comes last, then it reveals which of the output is a change. For example, Bitcoin Core had a bug years ago, where it would never put change first despite randomization, which for single-payment transactions resulted in a deterministic position of change address (second). To prevent such deterministic ordering of change address in outputs, <a href="https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki" rel="nofollow noreferrer">BIP 69</a> recommends lexicographical ordering of inputs and outputs. Outputs are arranged in ascending order of the amounts, followed by the <code>scriptPubKey</code>.</li>
</ul>

CC BY-SA 4.0
2019-07-10T13:05:51.870Z
I don't know of any software that always put change last. The standard intended behavior was always to put the change in a random position.
Pieter Wuille
CC BY-SA 4.0
2019-07-10T13:14:28.850Z
@pieterwuille I actually picked that from the BIP 69 'motivation' text. "Many wallets will place spending outputs first and change outputs second, ..."
Ugam Kamat
CC BY-SA 4.0
2019-07-10T13:19:07.220Z
Bitcoin Core for a while (years ago) had a bug where it would never put change first despite randomization, which for single-payment transactions resulted in a deterministic position. Perhaps it's referring to that?
Pieter Wuille
CC BY-SA 4.0
2019-07-10T13:24:41.587Z
@PieterWuille gotcha. Yeah, may be the case. I'll reword my answer
Ugam Kamat
CC BY-SA 4.0
2019-07-10T11:05:04.280Z
2019-07-10T13:28:19.323Z
2019-07-10T13:28:19.323Z
Ugam Kamat
<p>say i have a transaction details of one address from blockchain info. is there a more updated heuristics for address clustering ? i.e. if a transaction has 2 output which address belongs to a different entity and which one belongs to the same entity(if there is any)
thanks</p>

<address><network>
A more updated address clustering method?
nicholas___
# A more updated address clustering method?

(Asked by: username_0 on 2019-07-10)

say i have a transaction details of one address from blockchain info. is there a more updated heuristics for address clustering ? i.e. if a transaction has 2 output which address belongs to a different entity and which one belongs to the same entity(if there is any)
thanks

**Tags:** address, network


---

## 1 answers

### Answer by username_1 on 2019-07-10. Score: 2 | Accepted answer

Many wallet software obfuscate the information about payment and change address in order to protect the privacy of the user. When you see block explorer websites showing addresses in the outputs as change addresses, they are merely guessing as there is no sure shot way of knowing. Some of the techniques used to identify change addresses are below. I have also mentioned the current steps taken to prevent detection of such change addresses.

* **Sending change back to the same address:** If you send the change back to the same address from which you are initiating the transaction, then there is high likelihood of that address being a change address. This is mitigated by preventing address re-use.
* **Change goes back to the same address type:** If you initiated a transaction from a native segwit address (addresses starting with bc1) to a P2SH address (starting with 3). In some wallets, the change will be sent to the native segwit (bc1) address as that is the default for your wallet, thus leaking which output is the change. This is prevented by making the change address match the format of the payout address in order to mask privacy.
* **Coin selection:** Assume you want to make a payment of 5 BTC for your coffee (let's hope that the coffee is that good :-)). Your wallet contains two UTXOs: 4 BTC and 3 BTC. To make a payment of 5 BTC, you will have to use both UTXOs and send 2 BTC change back to yourself. Now, the person looking at this transaction would think that if you wanted to make a 2 BTC payment you would have just used your 3 BTC output and sent 1 BTC as change as compared to using both the UTXOs. Thus it is revealed that the 2 BTC is in fact a change output rather than a payment output. Wallet softwares might create two or more change addresses in order to mask which is exactly the change address, or if multiple UTXOs exist, it will optimally select those UTXOs in order to prevent such leak.
* **Change address is the last output:** If you build your transaction in such a way that your payment addresses comes first and change comes last, then it reveals which of the output is a change. For example, Bitcoin Core had a bug years ago, where it would never put change first despite randomization, which for single-payment transactions resulted in a deterministic position of change address (second). To prevent such deterministic ordering of change address in outputs, [BIP 69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki) recommends lexicographical ordering of inputs and outputs. Outputs are arranged in ascending order of the amounts, followed by the `scriptPubKey`.

> **Comments:**
> **username_2**: I don't know of any software that always put change last. The standard intended behavior was always to put the change in a random position.  
> **username_1**: @username_2 I actually picked that from the BIP 69 'motivation' text. "Many wallets will place spending outputs first and change outputs second, ..."  
> **username_2**: Bitcoin Core for a while (years ago) had a bug where it would never put change first despite randomization, which for single-payment transactions resulted in a deterministic position. Perhaps it's referring to that?  
> **username_1**: @username_2 gotcha. Yeah, may be the case. I'll reword my answer  

---

