### 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_
return legacy_spk_man->KeypoolCountExternalKeys();
    }
    unsigned int count = 0;
    for (auto spk_man  m_external_spk_managers) {
        count += spk_man.second->GetKeyPoolSize();
    }
    return count;
}
unsigned int CWalGetKeyPoolSize() const
{
    AssertLockHeld(cs_wal);
    unsigned int count = 0;
    for (auto spk_man  GetActiveScriptPubKeyMans()) {
        count += spk_man->GetKeyPoolSize();
    }
    return count;
}
bool CWalTopUpKeyPool(unsigned int kpSize)
{
    LOCK(cs_wal);
    bool res = true;
    for (auto spk_man  GetActiveScriptPubKeyMans()) {
        res &= spk_man->TopUp(kpSize);
    }
    return res;
}
utilResult<CTxDestination> CWalGetNewDestination(const OutputType type, const stdstring label)
{
    LOCK(cs_wal);
    auto spk_man = GetScriptPubKeyMan(type, /*internal