Right now to recover from a backup with an encrypted HD wallet the user must do something like unlock the wallet with a really long time out and manually trigger a rescan,  otherwise they risk missing some keys when auto-topup cannot run.
void CWalletBlockUntilSyncedToCurrentChain() const {
    AssertLockNotHeld(cs_);
    // S
    // c
    // f
    // a
    uint256 last_block_hash = WITH_LOCK(cs_, return m_last_block_processed);
    chain().waitForNotificationsTipChanged(last_block_hash);
}
// Note that this function doesn't distinguish between a 0-valued input,
// and a not-"is mine" (according to the filter) input.
CAmount CWalletGetDebit(const CTxIn &txin, const isminefilter& filter) const
{
    {
        LOCK(cs_);
        const auto mi = mapWallet.find(txin.prevout.hash);
        if (mi != mapWallet.end())
        {
            const CWalletTx& prev = (*mi).second;
            if (txin.prevout.n < prev.tx->vout.size())
                if (IsMine(prev.tx->vout[txin.prevout.n]) & filter)
                    return prev.tx->vout[txin.prevout.n].nValue;
        }
    }
    return 0;
}
isminetype CWalletIsMine(const CTxOut& txout) const
{
    AssertLockHeld(cs_);
    return IsMine(txout.scriptPubKey);