https://cirrus-ci.com/task/5603470202896384?logs=ci#L2681
}
    // only active ScriptPubKeyMan can be internal
    if (!GetActiveScriptPubKeyMans().count(spk_man)) {
        return stdnullopt;
    }
    const auto desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man);
    if (!desc_spk_man) {
        throw stdruntime_error(stdstring(__func__) + " unexpected ScriptPubKeyMan type.");
    }
    LOCK(desc_spk_man->cs_desc_man);
    const auto& type = desc_spk_man->GetWalletDescriptor().->GetOutputType();
    assert(type.has_value());
    return GetScriptPubKeyMan(*type, /* internal= sc_spk_man;
}
ScriptPubKeyMan* CWalletAddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const stdstring& label, bool internal)
{
    AssertLockHeld(cs_);
    if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
        WalletLogPrintf("Cannot add WalletDescriptor to a non- \n");
        return nullptr;
    }
    auto spk_man = GetDescriptorScriptPubKeyMan(desc);
    if (spk_man) {
        WalletLogPrintf("Update existing  %s\n", desc.->ToString());
        spk_man->UpdateWalletDescriptor(desc);
    } else {
        auto new_spk_man = stdunique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, desc));
        spk_man = new_spk_man.get();
        // Save the  to memory
        m_spk_managers[new_spk_man->GetID()] = stdmove(new_spk_man);