### 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_
{
    LOCK(context.wals_mutex);
    return context.wals;
}
stdshared_ptr<CWal> GetDefaultWal(WalContext& context, size_t& count)
{
    LOCK(context.wals_mutex);
    count = context.wals.size();
    return count == 1 ? context.wals[0]  nullptr;
}
stdshared_ptr<CWal> GetWal(WalContext& context, const stdstring& name)
{
    LOCK(context.wals_mutex);
    for (const stdshared_ptr<CWal>& wal  context.wals) {
        if (wal->GetName() == name) return wal;
    }
    return nullptr;
}
stdunique_ptr<interfacesHandler> HandleLoadWal(WalContext& context, LoadWalFn load_wal)
{
    LOCK(context.wals_mutex);
    auto it = context.wal_load_fns.emplace(context.wal_load_fns.end(), stdmove(load_wal));
    return interfacesMakeCleanupHandler([&context, it] { LOCK(context.wals_mutex); context.wal_load_fns.erase(it); });
}
void NotifyWalLoaded(WalContext& context, const stdshared_ptr<CWal>& wal)
{