### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

I randomly encountered this by loading a wallet created from master with an older version. I could trace it down to bd13dc2f46ea10302a928fcf0f53b7aed77ad260 (#26076), but I don't know descriptor wallets enough to understand what's going on (cc @Sjors @achow101).

### Expected behaviour

`bitcoind` starts, or at least tells me to use a later version if #26076 was a breaking change instead of corrupting `wallet.dat`.

### Steps to reproduce

(master, clean chain): 
`createwallet -regtest ""`
(v25.0rc2):
first `bitcoind -regtest` succeeds
then stop and restart the node: The second `bitcoind -regtest` leads to an InitError:
`Error: Error: Unable to expand wallet descriptor from cache`
now, the wallet cannot be loaded by either version.

### Relevant log output

_No response_

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

v25.0rc2 / master

### Operating system and version

Ubuntu

### Machine specifications

_No response_
out.solvable_descs.push_back({wsh_desc->ToString(), creation_time});
                std::unique_ptr<Descriptor> sh_wsh_desc = InferDescriptor(sh_wsh_spk, *GetSolvingProvider(sh_wsh_spk));
                out.solvable_descs.push_back({sh_wsh_desc->ToString(), creation_time});
            }
        }
    }
    
    assert(spks.size() == 0);
    return out;
}
bool LegacyScriptPubKeyMan::DeleteRecords()
{
    LOCK(cs_KeyStore);
    WalletBatch batch(m_storage.GetDatabase());
    return batch.EraseRecords(DBKeys::LEGACY_TYPES);
}
util::Result<CTxDestination> DescriptorScriptPubKeyMan::GetNewDestination(const OutputType type)
{
    
    if (!CanGetAddresses()) {
        return util::Error{_("No addresses available")};
    }
    {
        LOCK(cs_desc_man);
        assert(m_wallet_descriptor.descriptor->IsSingleType()); 
        std::optional<OutputType> desc_addr_type = m_wallet_descriptor.descriptor->GetOutputType();
        assert(desc_addr_type);
        if (type != *desc_addr_type) {
            throw std::runtime_error(std::string(__func__) + ": Types are inconsistent. Stored type does not match type of newly generated address");
        }