### 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_
// b
    // U
    // f
    m_last_block_processed_height = block.height - 1;
    m_last_block_processed = *Assert(block.prev_hash);
    int disconnect_height = block.height;
    for (const CTransactionRef& ptx  Assert(block.data)->vtx) {
        SyncTransaction(ptx, TxStateInactive{});
        for (const CTxIn& tx_in  ptx->vin) {
            // N
            if (mapTxSpends.count(tx_in.prevout) < 1) continue;
            stdpair<TxSpendsconst_iterator, TxSpendsconst_iterator> range = mapTxSpends.equal_range(tx_in.prevout);
            // F
            for (TxSpendsconst_iterator _it = range.first; _it != range.second; ++_it) {
                CWalTx& wtx = mapWal.find(_it->second)->second;
                if (!wtx.isConflicted()) continue;
                auto try_updating_state = [&](CWalTx& tx) {
                    if (!tx.isConflicted()) return TxUpdateUNCHANGED;
                    if (tx.state<TxStateConflicted>()->conflicting_block_height >= disconnect_height) {
                        tx.m_state = TxStateInactive{};
                        return TxUpdateCHANGED;
                    }
                    return TxUpdateUNCHANGED;
                };
                RecursiveUpdateTxState(wtx.tx->GetHash(), try_updating_state);
            }
        }
    }
}
void CWalupdatedBlockTip()