I am building a wallet that complies with BIP32, BIP39, BIP44, and EIP55.
It should be easy to restore keys if a wallet owner generates keys in sequence, but in my understanding, they can create a parent key and then derive a child key of it from anywhere in the tree structure.
Then how do we make sure that we restore all the keys?
Should we traverse the tree, check the balance of each address and then generate keys for the ones with some ETH(or tokens) in them?
My concern is that some people might own an address with zero balance after some transactions though. In this case, should we check transactions for all the addresses and then generate keys accordingly?
This process doesn’t seem to be beautiful and I might have some wrong assumptions here. I’d appreciate it if you could let me know the best practice. If there were any library that can help me to implement this, that even better.