hoping to gain a bit more clarity on how change addresses work here. In the attached example, can the change address be identified with 100% certainty? Is there a potential scenerio where it could be the first one, and a potential where it could be the second (without knowing more details about who sent it, what wallet they used etc). I see some people say you can't be certain, but in most cases it seems fairly obvious (ie the odds are overwhelming that it is the 2nd smaller amount for example) Thanks!

https://www.blockchain.com/btc/tx/90cb1a71128bda33b00d9008b08ec6cfd3ea8f9868753e038a8b719c6b97f9c1

In the attached example, can the change address be identified with 100% certainty?

No.

Is there a potential scenerio where it could be the first one, and a potential where it could be the second (without knowing more details about who sent it, what wallet they used etc).

Yes.

There are a lot of heuristics that can be used to determine which output is the change output. However there are also a lot of ways that wallets can combat this. Without having the wallet that created the transaction, it is impossible to know with 100% certainty which is the change address.

(ie the odds are overwhelming that it is the 2nd smaller amount for example)

In your example, you use what is referred to as the unnecessary input heuristic. This heuristic relies on the assumption that a wallet is not going to include extra inputs to make a payment that could be covered by fewer inputs. Because the second output in your example is smaller than any one of the inputs, if it were the payment, then the transaction has an unnecessary input so it is likely that output is not the payment.

But wallet developers know that this is a heuristic used to determine change. So some wallets actually do exactly what this heuristic assumes to be false. Such wallets will sometimes make a change output that is greater than the payment amount. This breaks the heuristic.

There are a number of other techniques that can be used to determine which output is change, but each heuristic relies on an assumption that wallet developers can also break.

• Thanks man appreciate it!
– doug
Aug 14, 2022 at 14:06

In the attached example, can the change address be identified with 100% certainty?

No. Unless a transaction sends change back to the input address, you can never be 100% certain what the change output is. There are heuristics that can suggest which output is more likely, but wallet developers know about these heuristics and can actively work against them.

In your specific example, one heuristic to determine the change output is looking at script types. The transaction spends two P2WPKH inputs and creates one P2WPKH output and one P2SH output. Since wallets often work with only one script type, this suggests the P2SH output belongs to the recipient. But again, some wallets break this heuristic by randomly sending change to a different script type.

There's also the unnecessary input heuristic, which is discussed in Andrew Chow's answer.

• cheers mate appreciate the response
– doug
Aug 14, 2022 at 14:06