<p>The <code>listwallets</code> RPC only lists <em>loaded</em> wallets.</p>
<p>If you want to load an existing wallet, you need the <code>loadwallet</code> RPC first.</p>

CC BY-SA 4.0
2023-06-11T22:43:58.643Z
2023-06-11T22:43:58.643Z
Pieter Wuille
<h1>Questions:</h1>
<ol>
<li>Should it be assumed if you're testing with bitcoincore you should always have a separate datadir per version/bin?</li>
<li>Based on weirdness below, (not being able to list regtest wallets), does it seem like my current node is messed up? If yes, what should I do to recover? If no, what am I doing wrong?</li>
</ol>
<h1>Details:</h1>
<p>I was running version v25.0 of bitcoincore from bitcoincore.org. I crated some wallets and did some testing. I then compiled from master/source <code>bitcoin/bitcoin</code> and pointed to the same backend state/datadir that v25.0 was using. Later I switched back to running the binary v25.0.</p>
<p>I'm curious if that could be the reason for seeing weird things like this or if it's something else:</p>
<pre><code>$ ./bitcoin-cli createwallet wallet_main
error code: -4
error message:
Wallet file verification failed. Failed to create database path '/btcdata/regtest/wallets/wallet_main'. Database already exists.

$ ./bitcoin-cli listwallets
[
]

$ ./bitcoin-cli createwallet wallet_main33
{
  &quot;name&quot;: &quot;wallet_main33&quot;
}

$ ./bitcoin-cli listwallets
[
  &quot;wallet_main33&quot;
]

$ ./bitcoin-cli createwallet wallet_main
error code: -4
error message:
Wallet file verification failed. Failed to create database path '/btcdata/regtest/wallets/wallet_main'. Database already exists.
</code></pre>
<p>I was doing some testing on regtest a few days ago and created several wallets including a &quot;wallet_main&quot;, it seems there is still some data of this and other regtest wallets, but they don't show up with the <code>listwallets</code> command.</p>
<p>Am I doing something wrong to list the all the wallets? Is it maybe a bug? or did I perhaps mess up my node?</p>
<p>Additional notes:
Inside my <code>/btcdata/regtest/wallets/</code> directory all my wallets look the same in term user/permissions the folder for the wallet names are 700, <code>drwx------</code>, and the inner <code>wallet.dat</code>'s are 600, <code>-rw-------</code>. I indeed have a <code>/btcdata/regtest/wallets/wallet_main</code> dir.</p>

CC BY-SA 4.0
2023-06-11T22:15:33.540Z
When you're using regtest (or testnet or signet) you're supposed to add `-regtest` to the `bitcoin-cli` command, so it can find the right data directory and config file sections. I'm surprised anything works at all without that.
Pieter Wuille
CC BY-SA 4.0
2023-06-11T22:19:55.967Z
To actually answer your question: you may need to issue `loadwallet` RPC to load existing wallets, if they're not set to auto loading. If that resolves it, I'll turn this into an answer.
Pieter Wuille
CC BY-SA 4.0
2023-06-11T22:38:38.443Z
Yes, brain fart.. `loadwallet` is what I need to do. I also see there is detailed explanation within bitcoin.conf to help people autoload various wallets.

Also,
bitcoin.conf set to run regtest via `chain=regtest` so I don't need to put `-regtest` it in every command. (I believe this is how it works?) 
Also doing this in bitcoin.conf:
```
# Options for regtest
[regtest]
# Options for regtest
[regtest]
rpcport=8332
fallbackfee=0.01
```
You're good to turn your comment into an answer!
Michael Tidwell
<wallet><bitcoin-cli><regtest><source-code>
Issue listing regtest wallets
Michael Tidwell
# Issue listing regtest wallets

(Asked by: username_0 on 2023-06-11)

Questions:

Should it be assumed if you're testing with bitcoincore you should always have a separate datadir per version/bin?
Based on weirdness below, (not being able to list regtest wallets), does it seem like my current node is messed up? If yes, what should I do to recover? If no, what am I doing wrong?

Details:
I was running version v25.0 of bitcoincore from bitcoincore.org. I crated some wallets and did some testing. I then compiled from master/source bitcoin/bitcoin and pointed to the same backend state/datadir that v25.0 was using. Later I switched back to running the binary v25.0.
I'm curious if that could be the reason for seeing weird things like this or if it's something else:
$ ./bitcoin-cli createwallet wallet_main
error code: -4
error message:
Wallet file verification failed. Failed to create database path '/btcdata/regtest/wallets/wallet_main'. Database already exists.

$ ./bitcoin-cli listwallets
[
]

$ ./bitcoin-cli createwallet wallet_main33
{
  "name": "wallet_main33"
}

$ ./bitcoin-cli listwallets
[
  "wallet_main33"
]

$ ./bitcoin-cli createwallet wallet_main
error code: -4
error message:
Wallet file verification failed. Failed to create database path '/btcdata/regtest/wallets/wallet_main'. Database already exists.

I was doing some testing on regtest a few days ago and created several wallets including a "wallet_main", it seems there is still some data of this and other regtest wallets, but they don't show up with the listwallets command.
Am I doing something wrong to list the all the wallets? Is it maybe a bug? or did I perhaps mess up my node?
Additional notes:
Inside my /btcdata/regtest/wallets/ directory all my wallets look the same in term user/permissions the folder for the wallet names are 700, drwx------, and the inner wallet.dat's are 600, -rw-------. I indeed have a /btcdata/regtest/wallets/wallet_main dir.

**Tags:** wallet, bitcoin-cli, regtest, source-code

> **Comments:**
> **username_1**: When you're using regtest (or testnet or signet) you're supposed to add `-regtest` to the `bitcoin-cli` command, so it can find the right data directory and config file sections. I'm surprised anything works at all without that.  
> **username_1**: To actually answer your question: you may need to issue `loadwallet` RPC to load existing wallets, if they're not set to auto loading. If that resolves it, I'll turn this into an answer.  
> **username_0**: Yes, brain fart.. `loadwallet` is what I need to do. I also see there is detailed explanation within bitcoin.conf to help people autoload various wallets.  Also, bitcoin.conf set to run regtest via `chain=regtest` so I don't need to put `-regtest` it in every command. (I believe this is how it works?)  Also doing this in bitcoin.conf: ``` # Options for regtest [regtest] # Options for regtest [regtest] rpcport=8332 fallbackfee=0.01 ``` You're good to turn your comment into an answer!  

---

## 1 answers

### Answer by username_1 on 2023-06-11. Score: 2 | Accepted answer

The `listwallets` RPC only lists *loaded* wallets.

If you want to load an existing wallet, you need the `loadwallet` RPC first.


---

