The Bitcoin Core wallet (and most other wallets) have this thing called the keypool. The keypool is just several (Bitcoin Core defaults to 1000) keys and their addresses that are pregenerated.
As far as I know, the default used to be
100 addresses, not 1000.
https://en.bitcoin.it/wiki/Running_Bitcoin :
-keypool=<n> Set key pool size to <n> (default: 100)
My current Bitcoin Core 0.15.1:
-keypool=<n>
Set key pool size to <n> (default: 1000)
It seems recent versions use a larger default keypool, but it's something to keep in mind in case you're running an older version.
Is there any command that will give me the amount of used keys from the keypool? I don't know if i have passed 1000 yet or not.
Click Help > Debug window > Console > enter getwalletinfo
Mine says:
The keypool gets refilled up to 1000 every time you unlock the wallet with your passphrase. My 998 means I've used 2 addresses since the last time I unlocked it.
What happens when you pass 1000 then? can I keep using the same wallet.dat file because it will automatically create another keypool inside the same file so it generates batches of 1000 each time you use 1000? how many keypools can be generated? Its not clear to me how this works. I never updated to HD wallet so im using the same old wallet.dat for ages, im worried in case there is any problems if I pass 1000 addresses.
Let's take my wallet as an example. If I make a backup now, my backup holds the private keys to 998 unused addresses.
My wallet has no problem creating more addresses, suppose I receive payments to 1200 new unique addresses. That will work just fine, my keypool gets refilled up to 1000 each time I unlock my wallet. But, all payments I receive to the last 202 addresses, won't be included in my current backup!
For this reason it's important to make a new backup once in a while. I do it often enough to be absolutely sure I don't get close to using the entire 1000 addresses in my keypool. (in reality I do it more like every 10 addresses already, you can never have enough backups)
Note that changing or setting a password also flushes your keypool (for security reasons), and requires you to make a new backup.