<p>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.</p>
<p>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 <code>now</code> when importing. You can then import your transactions using the <code>importprunedfunds</code> RPC. However if you have many transactions, this can be tedious. And you also risk missing some transactions.</p>
<hr />
<p>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.</p>
<p>Descriptor wallets use sqlite so any general purpose sqlite tool can be used to modify it.</p>
<p>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 <code>walletdescriptor</code>. 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.</p>
<p>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.</p>
<p>These additional records are <code>walletdescriptorcache</code>, <code>walletdescriptorlhcache</code>, <code>walletdescriptorckey</code>, and <code>walletdescriptorkey</code>. 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.</p>
<p>If there are transactions that you want to remove, you can do this using the <code>removeprunedfunds</code> RPC.</p>

CC BY-SA 4.0
2024-03-09T05:08:31.980Z
How do I know which descriptor matches which public address?  I'm looking at the `listdescriptors true` command and it appears a bit daunting.  Any articles with sample outputs mirroring recent Core releases that makes each identifier plain so the viewer knows what they are looking at?  BC help docs are a bit lacking..
Jon Grah
CC BY-SA 4.0
2024-03-09T18:25:53.473Z
`getaddressinfo <address>` can be used to retrieve the descriptor (without private keys) that was used to generate a particular address.
Ava Chow
CC BY-SA 4.0
2022-05-08T15:56:04.827Z
2022-05-08T15:56:04.827Z
Ava Chow
<p>I had accidentally imported descriptors into a wallet that I didn't mean to import to in Bitcoin Core.</p>
<p>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.</p>
<p>Is there any way I could remove the descriptor from the wallet without having to re-scan?</p>

<bitcoin-core><wallet><client><bitcoin-cli><output-script-descriptors>
Remove descriptor from a Bitcoin Core wallet
kcalvinalvin
# Remove descriptor from a Bitcoin Core wallet

(Asked by: username_0 on 2022-05-07)

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?

**Tags:** bitcoin-core, wallet, client, bitcoin-cli, output-script-descriptors


---

## 1 answers

### Answer by username_1 on 2022-05-08. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_2**: How do I know which descriptor matches which public address?  I'm looking at the `listdescriptors true` command and it appears a bit daunting.  Any articles with sample outputs mirroring recent Core releases that makes each identifier plain so the viewer knows what they are looking at?  BC help docs are a bit lacking..  
> **username_1**: `getaddressinfo <address>` can be used to retrieve the descriptor (without private keys) that was used to generate a particular address.  

---

