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.
status = DatabaseStatusFAILED_INVALID_BACKUP_FILE;
            return nullptr;
        }
        if (fsexists(_path) || !TryCreateDirectories(_path)) {
            error = Untranslated(strprintf("Failed to create database path '%s'. Database already exists.", fsPathToString(_path)));
            status = DatabaseStatusFAILED_ALREADY_EXISTS;
            return nullptr;
        }
        fscopy_file(backup_file, _file, fscopy_optionsnone);
         = LoadWallet(context, _name, load_on_start, options, status, error, warnings);
    } catch (const stdexception& e) {
        assert(!);
        if (!error.empty()) error += Untranslated("\n");
        error += strprintf(Untranslated("Unexpected exception %s"), e.what());
    }
    if (!) {
        fsremove_all(_path);
    }
    return ;
}
/** @defgroup mapWallet
 *
 * @{
 */
const CWalletTx* CWalletGetWalletTx(const uint256& hash) const
{
    AssertLockHeld(cs_);
    const auto it = mapWallet.find(hash);
    if (it == mapWallet.end())
        return nullptr;