<p>You can unload the wallet using <code>unloadwallet</code> and then delete the wallet file.</p>

CC BY-SA 4.0
2019-10-21T23:11:25.003Z
2019-10-21T23:11:25.003Z
Ava Chow
<p>For my unit tests, I'd like to be able to delete and recreate a wallet without having to stop <code>bitcoind</code> and manually deleting the wallet directory.</p>

<p>When I try to delete such wallet directory without stopping <code>bitcoind</code>, I get an error since an handle exists on "<code>db.log</code>" (on Windows at least).</p>

<p>Is there a clean way to delete a (testnet) wallet without stopping <code>bitcoind</code>?</p>

CC BY-SA 4.0
2019-10-21T10:09:32.370Z
Why are you using testnet? Regtest mode exists explicitly for that purpose.
Claris
CC BY-SA 4.0
2019-10-21T13:47:11.877Z
Would `bitcoind` really allow me to delete a wallet when running on regtest? For some reason I doubt it would make any difference... I guess I should try!
electrotype
CC BY-SA 4.0
2019-10-21T13:47:47.543Z
Why do you want to? You can just restart the node.
Claris
CC BY-SA 4.0
2019-10-21T16:45:44.427Z
That is exactly what I try to avoid and why I ask this question in the first place! :-)
electrotype
CC BY-SA 4.0
2019-10-21T16:46:19.823Z
You seem to be very confused i to believing that restarting a node during a unit test is somehow bad or abnormal.
Claris
CC BY-SA 4.0
2019-10-21T17:06:35.373Z
Well, recreating a wallet would make way more sense in my case and would be way faster (even if I'm sure the regTest node is faster to restart than a testnet one). I guess I'll indeed have to restart the node, if wallets can't be deleted otherwise. Thanks.
electrotype
CC BY-SA 4.0
2019-10-21T17:07:21.457Z
It takes seconds to restart a regtest node. Faster than whining on stack exhange about it.
Claris
<bitcoind><wallet><testnet><testing>
Is there a way to delete a test wallet without stopping bitcoind?
electrotype
# Is there a way to delete a test wallet without stopping bitcoind?

(Asked by: username_0 on 2019-10-21)

For my unit tests, I'd like to be able to delete and recreate a wallet without having to stop `bitcoind` and manually deleting the wallet directory.

When I try to delete such wallet directory without stopping `bitcoind`, I get an error since an handle exists on "`db.log`" (on Windows at least).

Is there a clean way to delete a (testnet) wallet without stopping `bitcoind`?

**Tags:** bitcoind, wallet, testnet, testing

> **Comments:**
> **username_1**: Why are you using testnet? Regtest mode exists explicitly for that purpose.  
> **username_0**: Would `bitcoind` really allow me to delete a wallet when running on regtest? For some reason I doubt it would make any difference... I guess I should try!  
> **username_1**: Why do you want to? You can just restart the node.  
> **username_0**: That is exactly what I try to avoid and why I ask this question in the first place! :-)  
> **username_1**: You seem to be very confused i to believing that restarting a node during a unit test is somehow bad or abnormal.  
> **username_0**: Well, recreating a wallet would make way more sense in my case and would be way faster (even if I'm sure the regTest node is faster to restart than a testnet one). I guess I'll indeed have to restart the node, if wallets can't be deleted otherwise. Thanks.  
> **username_1**: It takes seconds to restart a regtest node. Faster than whining on stack exhange about it.  

---

## 1 answers

### Answer by username_2 on 2019-10-21. Score: 1 | Accepted answer

You can unload the wallet using `unloadwallet` and then delete the wallet file.


---

