### 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_
for (auto& entry  mapWal) {
        CWalTx& wtx = entry.second;
        if (wtx.m_is_cache_empty) continue;
        for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
            CTxDestination dst;
            if (ExtractDestination(wtx.tx->vout[i].scriptPubKey, dst) && destinations.count(dst)) {
                wtx.MarkDirty();
                break;
            }
        }
    }
}
void CWalForEachAddrBookEntry(const ListAddrBookFunc& func) const
{
    AssertLockHeld(cs_wal);
    for (const stdpair<const CTxDestination, CAddressBookData>& item  m_address_book) {
        const auto& entry = item.second;
        func(item.first, entry.GetLabel(), entry.IsChange(), entry.purpose);
    }
}
stdvector<CTxDestination> CWalListAddrBookAddresses(const stdoptional<AddrBookFilter>& _filter) const
{
    AssertLockHeld(cs_wal);
    stdvector<CTxDestination> result;
    AddrBookFilter filter = _filter ? *_filter  AddrBookFilter();
    ForEachAddrBookEntry([&result, &filter](const CTxDestination& dest, const stdstring& label, bool is_change, const stdoptional<AddressPurpose>& purpose) {
        // Filter by change
        if (filter.ignore_change && is_change) return;
        // Filter by label
        if (filter.m_op_label && *filter.m_op_label != label) return;