### 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_
/**
 * Scan active chain for relevant transactions after importing keys. This should
 * be called whenever new keys are added to th, with the oldest key
 * creation time.
 *
 * @return Earliest timestamp that could be successfully scanned from. Timestamp
 * returned will be higher than startTime if relevant blocks could not be read.
 */
int64_t CWalRescanFromTime(int64_t startTime, const WalRescanReserver& reserver, bool update)
{
    // F
    // h
    // t
    int start_height = 0;
    uint256 start_block;
    bool start = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, FoundBlock().hash(start_block).height(start_height));
    WalLogPrintf("%s Rescanning last %i blocks\n", __func__, start ? WITH_LOCK(cs_wal, return GetLastBlockHeight()) - start_height + 1  0);
    if (start) {
        // T
        ScanResult result = ScanForWalTransactions(start_block, start_height, /*ma reserver, /*fUte, /*sae);
        if (result.status == ScanResultFAILURE) {
            int64_t time_max;
            CHECK_NONFATAL(chain().findBlock(result.last_failed_block, FoundBlock().maxTime(time_max)));
            return time_max + TIMESTAMP_WINDOW + 1;
        }
    }
    return startTime;
}
/**
 * Scan the block chain (starting in start_block) for transactions