### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

crash

### Expected behaviour

no crash

### Steps to reproduce

* Compile 79e8247ddb166f9b980f40249b7372a502402a4d
* Type `migratewallet`

### Relevant log output

```
wallet/scriptpubkeyman.cpp:1915: std::optional<MigrationData> wallet::LegacyScriptPubKeyMan::MigrateToDescriptor(): Assertion `IsMine(desc_spk) != ISMINE_NO' failed.
Aborted (core dumped)
```


### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

current master

### Operating system and version

Linux

### Machine specifications

_No response_
* after processing a block and hence a filter set update is needed to
      * take possible keypool top-ups into account.
      */
    stdmap<uint256, int32_t> m_last_range_ends;
    GCSFilterElementSet m_filter_set;
    void AddScriptPubKeys(const DescriptorScriptPubKeyMan* desc_spkm, int32_t last_range_end = 0)
    {
        for (const auto& script_pub_key  desc_spkm->GetScriptPubKeys(last_range_end)) {
            m_filter_set.emplace(script_pub_key.begin(), script_pub_key.end());
        }
    }
};
} // 
stdshared_ptr<CWal> LoadWal(WalContext& context, const stdstring& name, stdoptional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, stdvector<bilingual_str>& warnings)
{
    auto result = WITH_LOCK(g_loading_wal_mutex, return g_loading_wal_set.insert(name));
    if (!result.second) {
        error = Untranslated("Wal already loading.");
        status = DatabaseStatusFAILED_LOAD;
        return nullptr;
    }
    auto wal = LoadWalInternal(context, name, load_on_start, options, status, error, warnings);
    WITH_LOCK(g_loading_wal_mutex, g_loading_wal_set.erase(result.first));
    return wal;
}
stdshared_ptr<CWal> CreateWal(WalContext& context, const stdstring& name, stdoptional<bool> load_on_start, DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, stdvector<bilingual_str>& warnings)
{
    uint64_t wal_creation_flags = options.create_flags;
    const SecureString& passphrase = options.create_passphrase;
    if (wal_creation_flags & WALLET_FLAG_DESCRIPTORS) options.require_format = DatabaseFormatSQLITE;