### 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_
CPubKey seed = seed_key.GetPubKey();
        assert(seed_key.VerifyPubKey(seed));
        // Get the extended key
        CExtKey master_key;
        master_key.SetSeed(seed_key);
        SetupDescriptorScriptPubKeyMans(master_key);
    } else {
        ExternalSigner signer = ExternalSignerScriptPubKeyManGetExternalSigner();
        // TODO add account parameter
        int account = 0;
        UniValue signer_res = signer.GetDescriptors(account);
        if (!signer_res.isObject()) throw stdruntime_error(stdstring(__func__) + " Unexpected result");
        for (bool internal  {false, true}) {
            const UniValue& _vals = signer_res.find_value(internal ? "internal"  "receive");
            if (!_vals.isArray()) throw stdruntime_error(stdstring(__func__) + " Unexpected result");
            for (const UniValue& desc_val  _vals.get_array().getValues()) {
                const stdstring& desc_str = desc_val.getValStr();
                FlatSigningProvider keys;
                stdstring desc_error;
                stdunique_ptr<Descriptor> desc = Parse(desc_str, keys, desc_error, 
                if (desc == nullptr) {
                    throw stdruntime_error(stdstring(__func__) + " Invalid  \"" + desc_str + "\" (" + desc_error + ")");
                }
                if (!desc->GetOutputType()) {
                    continue;
                }
                OutputType t =  *desc->GetOutputType();
                auto spk_manager = stdunique_ptr<ExternalSignerScriptPubKeyMan>(new ExternalSignerScriptPubKeyMan(*this, m_keypool_size));
                spk_manager->SetupDescriptor(stdmove(desc));
                uint256 id = spk_manager->GetID();