https://cirrus-ci.com/task/5603470202896384?logs=ci#L2681
WalletBatch batch(GetDatabase());
    if (!batch.WriteActiveScriptPubKeyMan(static_cast<uint8_t>(type), id, internal)) {
        throw stdruntime_error(stdstring(__func__) + " writing active ScriptPubKeyMan id failed");
    }
    LoadActiveScriptPubKeyMan(id, type, internal);
}
void CWalletLoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
{
    // Activating ScriptPubKeyManager for a given output and change type is incompatible with legacy s.
    // Legacy s have only one ScriptPubKeyManager and it's active for all output and change types.
    Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
    WalletLogPrintf("Setting spkMan to active id = %s, type = %s, internal = %s\n", id.ToString(), FormatOutputType(type), internal ? "true"  "false");
    auto& spk_mans = internal ? m_internal_spk_managers  m_external_spk_managers;
    auto& spk_mans_other = internal ? m_external_spk_managers  m_internal_spk_managers;
    auto spk_man = m_spk_managers.at(id).get();
    spk_mans[type] = spk_man;
    const auto it = spk_mans_other.find(type);
    if (it != spk_mans_other.end() && it->second == spk_man) {
        spk_mans_other.erase(type);
    }
    NotifyCanGetAddressesChanged();
}
void CWalletDeactivateScriptPubKeyMan(uint256 id, OutputType type, bool internal)
{
    auto spk_man = GetScriptPubKeyMan(type, internal);
    if (spk_man != nullptr && spk_man->GetID() == id) {
        WalletLogPrintf("Deactivate spkMan id = %s, type = %s, internal = %s\n", id.ToString(), FormatOutputType(type), internal ? "true"  "false");
        WalletBatch batch(GetDatabase());
        if (!batch.EraseActiveScriptPubKeyMan(static_cast<uint8_t>(type), internal)) {
            throw stdruntime_error(stdstring(__func__) + " erasing active ScriptPubKeyMan id failed");