### 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_
}
        }
        walInstance->m_attaching_chain = false;
        walInstance->chainStateFlushed(chain.getTipLocator());
        walInstance->GetDatabase().IncrementUpdateCounter();
    }
    walInstance->m_attaching_chain = false;
    return true;
}
const CAddressBookData* CWalFindAddressBookEntry(const CTxDestination& dest, bool allow_change) const
{
    const auto& address_book_it = m_address_book.find(dest);
    if (address_book_it == m_address_book.end()) return nullptr;
    if ((!allow_change) && address_book_it->second.IsChange()) {
        return nullptr;
    }
    return &address_book_it->second;
}
bool CWalUpgradeWal(int version, bilingual_str& error)
{
    int prev_version = GetVersion();
    if (version == 0) {
        WalLogPrintf("Performing wal upgrade to %i\n", FEATURE_LATEST);
        version = FEATURE_LATEST;
    } else {
        WalLogPrintf("Allowing wal upgrade up to %i\n", version);
    }
    if (version < prev_version) {
        error = strprintf(_("Cannot downgrad from version %i to version %i. Wal version unchanged."), prev_version, version);
        return false;