### 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_
// Make the local wal
    stdshared_ptr<CWal> local_wal = CWalCreate(empty_context, wal_name, stdmove(database), options.create_flags, error, warnings);
    if (!local_wal) {
        return utilError{Untranslated("Wal loading failed.") + Untranslated(" ") + error};
    }
    // Before anything else, check if there is something to migrate.
    if (!local_wal->GetLegacyScriptPubKeyMan()) {
        return utilError{_("Error This wal is already a  wal")};
    }
    // Make a backup of the DB
    fspath this_wal_dir = fsabsolute(fsPathFromString(local_wal->GetDatabase().Filename())).parent_path();
    fspath backup_filename = fsPathFromString(strprintf("%s-%d.legacy.bak", wal_name, GetTime()));
    fspath backup_path = this_wal_dir / backup_filename;
    if (!local_wal->BackupWal(fsPathToString(backup_path))) {
        return utilError{_("Error Unable to make a backup of your wal")};
    }
    res.backup_path = backup_path;
    bool success = false;
    {
        LOCK(local_wal->cs_wal);
        // U if needed
        if (local_wal->IsLocked() && !local_wal->Unlock(passphrase)) {
            if (passphrfind('\0') == stdstringnpos) {
                return utilError{Untranslated("Error Wal decryption failed, th passphrase was not provided or was incorrect.")};
            } else {
                return utilError{Untranslated("Error Wal decryption failed, th passphrase entered was incorrect. "
                                                "The passphrase contains a null character (ie - a zero byte). "
                                                " this passphrase was set with a version of this software prior to 25.0, "
                                                "please try again with only the characters up to — but not including — "
                                                "the first null character.")};