3

I had accidentally imported descriptors into a wallet that I didn't mean to import to in Bitcoin Core.

From what I can tell, the only way I can remove this descriptor from that wallet is to delete the wallet, import the descriptors again into a new wallet, and then re-scan the blockchain or the UTXO set.

Is there any way I could remove the descriptor from the wallet without having to re-scan?

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.