Currently, we keep only keypool indexes (a int64_t) in memory.
If we need the CKeyID of a keypool key (or if we need to know if it’s an internal key), we need to load the whole CKeyPool entry from the database.
This PR will change the in-memory set entries from int64_t to KeypoolCache.
This essentially allows us to efficiently scan the CKeyIDs of our keypool which is almost a pre-requirement if we want to have an efficient HD rescan (otherwise we would have to load the complete key pool each time we found an IsMine or IsFromMe tx).
There are no direct performance optimisations implemented in this PR.