In HD wallet recovery, how does the wallet know which address to recover?
Do you try every possible address associated with that seed’s master key? (This doesn’t seem practical).
no. In practice this is not possible because the number of addresses that can be generated from a single master private key is virtually infinite.
Instead, the wallet generates its keys from a standardized derivation path and assumes that other wallets follow the same standard. This is generally a safe assumption. Wallets that do not follow the standard derivation path usually have documentation explaining which derivation path they use so that other wallets can specify which derivation path to use.
Most wallets follow the BIP 44 specification for derivation paths.
Is there a standard for up to nth address to be generated on the wallet side?
no. Typically, the wallet generates addresses until they are created. n
Unused Addresses (also known as Gap Limits) Gap limits are not standardized and can be configured in many wallets. Many wallets have a key spacing limit of 20, but this may not be sufficient for restores. In another wallet it could be 100 keys, in another it could be 1000 keys.