### 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_
result.erase(myHash);
    return result;
}
bool CWalShouldResend() const
{
    // Don't attempt to resubmit if th is configured to not broadcast
    if (!fBroadcastTransactions) return false;
    // During reindex, importing and IBD, old wal transactions become
    // unconfirmed. Don't resend them as that would spam other nodes.
    // We only allow forcing mempool submission when not relaying to avoid this spam.
    if (!chain().isReadyToBroadcast()) return false;
    // Do this infrequently and randomly to avoid giving away
    // that these are our transactions.
    if (NodeClocknow() < m_next_resend) return false;
    return true;
}
NodeClocktime_point CWalGetDefaultNextResend() { return FastRandomContext{}.rand_uniform_delay(NodeClocknow() + 12h, 24h); }
// Resubmit transactions from th to the mempool, optionally asking the
// mempool to relay them. On startup, we will do this for all unconfirmed
// transactions but will not ask the mempool to relay them. We do this on startup
// to ensure that our own mempool is aware of our transactions. There
// is a privacy side effect here as not broadcasting on startup also means that we won't
// inform the world of our wal's state, particularly if th (or node) is not
// yet synced.
//
// Otheise this function is called periodically in order to relay our unconfirmed txs.
// We do this on a random timer to slightly obfuscate which transactions
// come from our wal.
//
// TODO Ideally, we'd only resend transactions that we think should have been