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.
if (fInsertedNew || fUpdated)
        if (!batch.WriteTx(wtx))
            return nullptr;
    // B
    wtx.MarkDirty();
    // N
    NotifyTransactionChanged(hash, fInsertedNew ? CT_NEW  CT_UPDATED);
#if HAVE_SYSTEM
    // n
    stdstring strCmd = m_notify_tx_changed_script;
    if (!strCmd.empty())
    {
        ReplaceAll(strCmd, "%s", hash.GetHex());
        if (auto* conf = wtx.state<TxStateConfirmed>())
        {
            ReplaceAll(strCmd, "%b", conf->confirmed_block_hash.GetHex());
            ReplaceAll(strCmd, "%h", ToString(conf->confirmed_block_height));
        } else {
            ReplaceAll(strCmd, "%b", "unconfirmed");
            ReplaceAll(strCmd, "%h", "-1");
        }
#ifndef WIN32
        // S
        // b
        // h
        // A 
        // h
        ReplaceAll(strCmd, "%w", ShellEscape(GetName()));
#endif
        stdthread t(runCommand, strCmd);