BIP004 states that a derivation path's 4th digit will be 1 if it is a change address like this:
m / purpose' / coin_type' / account' / change / address_index
The idea is that once money is spent from a given address, the left over is moved in to a new address which is used as the change address. Wallet software should not leave the left over funds in an address in the old address, they should be moved to the new address. I guess that some wallets follow this, and some don't. But wallets that do not follow this would be breaking the BIP.
So, my question is, from looking at a given address on the blockchain is there a programmatic way to tell where the funds have been moved to?
If you have the public key and the derivation path for the address, you can derive the change address, but if I don't have these things, is there a way to figure it out? Or, at least to take a good guess as to what it might be based on where the funds are moved to?
Use Case (View-Only Wallet):
- User adds a loose address to their wallet (without public key)
- App scans blockchain for address
- App realizes balance has changed and transaction occurred
- Funds have moved to another address, but app can't figure this out without prompting user, or displaying an incorrect balance.