NOTE: This is a repost from a reply I made to another user, but I felt it was a good topic to include in the Academy.
Basic Info about Change Addresses:
Change addresses will only be generated if you make an outgoing transaction. So coinstake transactions do not involve change addresses.
The Qt wallet by default generates a bunch of change addresses in the background. I think 100. It will then only generate more addresses when it uses these up. So the only way an old backup would cause you to lose coins is if you had a 100+ of outgoing transactions.
The the update to HD Qt wallets (hierarchical deterministic, not high definition) will make this a moot point. laudney teased these a few weeks back, and I believe he is in the process of finalizing the code to make them happen.
A little more detail:
A change address is used when you send Reddcoins to another person and the amount sent does not equal the exact amount of your input(s). Inputs come from deposit transactions.
Say you deposit 1000 RDD, 15000 RDD, and 900 RDD. You have 3 inputs. Now say you send someone 500 RDD. Your wallet will grab one of your inputs (I think the 900 RDD one, but I can’t recall if logical is built in to grab the smallest input that works) and make a new transaction. That transaction will look something like this:
- input: 900 RDD from your wallet address
- 500 RDD to your friend
- 399.999 RDD to a change address
- 0.001 RDD transaction fee (or something like that…) to stakers
Let’s say you decided to also send 700 RDD to another friend in the same transaction. That would look something like this:
- 900 RDD from your wallet address
- 1000 RDD from your wallet address
(could be the same as the 900 or different - whatever your deposited it as)
- 500 RDD to your friend
- 700 RDD to your other friend
- 699.999 RDD to a change address
- 0.001 RDD transaction fee to stakers
Notice the fee didn’t get bigger. In fact, with many transactions the fee will likely be 0 unless you tell it otherwise.
Note on how HD wallets derive keys, and why they are awesome:
Basically, an HD wallet uses a defined tree structure to create new branches with very specific references.
Most work by generating “Receive” addresses and “Change” addresses by using a numbering system.
A wallet might automatically generate 10 receive addresses and 3 change addresses, numbered 0-9 and 0-2, respectively.
The wallet would then check if these addresses are used. In the case of Receive addresses, if it sees that #7 is used, it will generate additional addresses. Then it checks again. Say #14 is used… it will make more. It keeps doing this until there are 10 unused addresses at the end.
Change addresses work in the same way, though usually the wallet doesn’t keep as large of a store of empty change addresses hanging around. This is because the wallet always uses these addresses sequentially. i.e. the first time it needs a change address it uses 0. The next 1. The next 2. And so on. This differs from the receive addresses, where a users might give 10 addresses out on 10 different sites, and only 0, 2, 6, and 9 get used, for example.
In all, what this means is that the inclusion of HD seeds into the Qt wallet means that if you back up your seed, you never need to make any more backups ever again. Because the wallet always uses the same hierarchy to always deterministically generate the same addresses, you can import that seed into a new wallet at any time and not risk losing any Reddcoins.
If you would like to learn more about change addresses and something called “coin control” - a way that the Qt wallet lets the user manage inputs - check out the wiki: