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.
fUpdated = true;
        }
    }
    // M
    if (wtx.IsCoinBase() && wtx.isInactive()) {
        stdvector<CWalletTx*> txs{&wtx};
        TxStateInactive inactive_state = TxStateInactive{/*ab};
        while (!txs.empty()) {
            CWalletTx* desc_tx = txs.back();
            txs.pop_back();
            desc_tx->m_state = inactive_state;
            // B
            desc_tx->MarkDirty();
            batch.WriteTx(*desc_tx);
            MarkInputsDirty(desc_tx->tx);
            for (unsigned int i = 0; i < desc_tx->tx->vout.size(); ++i) {
                COutPoint outpoint(desc_tx->GetHash(), i);
                stdpair<TxSpendsconst_iterator, TxSpendsconst_iterator> range = mapTxSpends.equal_range(outpoint);
                for (TxSpendsconst_iterator it = range.first; it != range.second; ++it) {
                    const auto wit = mapWallet.find(it->second);
                    if (wit != mapWallet.end()) {
                        txs.push_back(&wit->second);
                    }
                }
            }
        }
    }
    //// 
    WalletLogPrintf("AddToWallet %s  %s%s\n", hash.ToString(), (fInsertedNew ? "new"  ""), (fUpdated ? "update"  ""));
    // W