This process is in general very complicated and – missing a possible transaction – can lead to lost funds. Be careful.
With HD, you always generate
publickeys. To find corresponding transaction, you need to turn them into addresses (which involves a bitcoin-script template like P2PKH).
If you just going to create standard P2PKH addresses in order to find transaction, you may miss relevant transactions.
For example: For a long time, Copay used 1of1 multisig (P2SH) for single user wallets. Restoring a such xpriv HD master with just P2PKH can result in lost funds.
Also, you need to know the used BIP32 keypath scheme of the wallet you like to restore. Some wallets are using
m/k, others stick to BIP44. This makes it again more complex to "regenerate" funds.
Without a fully address-index blockchain, scanning for funds can be complicated and may take serval hours.
Probably best practice is to generate a large lookup window, where the size depends on the type of the wallet. Example: if it was a merchant wallet, there are probably serval thousand key involved. This would speak for larger lookup window.
If you want to use Core, what you can do, is generating addresses in a first lookup window.
generate pubkeys from
m/0'/5000 (lookup-window of 5000 keys). Attention, this will not catch BIP44 wallet funds.
You can use a BIP32 tool for that purpose (maybe https://github.com/libbtc/libbtc#the-bitcointool-cli).
Import all these pubkeys into a new wallet (use
importmulti in Core 0.14,
importpubkey before 0.14 without a rescan).
Restart bitcoin-core with the
Decide if you want to extend the lookup-window (maybe if addresses up to 4900 are used), and start again with 1.)
Someone should write a script/tool/app.