Bitcoin Core does not have any descriptor or key deletion functions because users may use them to accidentally delete the data that they need in order to spend their Bitcoin.
The recommended way is to import the things that you need into a new wallet. You can avoid a rescan by setting the timestamp to the string now
when importing. You can then import your transactions using the importprunedfunds
RPC. However if you have many transactions, this can be tedious. And you also risk missing some transactions.
If you are willing to modify the database with an external tool, you can delete the records corresponding to the descriptors that you want to delete.
Descriptor wallets use sqlite so any general purpose sqlite tool can be used to modify it.
Bitcoin Core stores wallet data in key value pairs. Descriptor wallets use sqlite with a single table and two columns named key and value with the data as binary blobs. Each key has a length prefixed string name. Descriptors are stored in records with a name walletdescriptor
. This is followed by a 32 byte hash that is used as an identifer for the descriptor. The value of that record is the descriptor string with some extra metadata.
You can look for a record where the value is the descriptor you want to delete. Before deleting that record, remember what the id is as that will be needed to delete additional records related to that descriptor.
These additional records are walletdescriptorcache
, walletdescriptorlhcache
, walletdescriptorckey
, and walletdescriptorkey
. All of these have a similar prefix in that the descriptor id immediately follows the type string. You can search for those records with those names and the id of the descriptor you want to delete, and delete those records as well. Removing these records should be sufficient to delete a descriptor from your wallet.
If there are transactions that you want to remove, you can do this using the removeprunedfunds
RPC.