<p>With help from Pieter above (in the comments) I located my testnet coins.</p>
<p>The CLI command <code>listwalletdir</code> should return the available wallet names (also located in <code>$DATADIR/testnet3/wallets</code>) but I'm pretty sure this didn't work for me initially.</p>
<p>You can't use the CLI command <code>listwallets</code> though as this only lists wallets that have been loaded. If a wallet exists but hasn't been loaded it won't be listed in the output of <code>listwallets</code>.</p>
<p>If you know the name of the wallet (located in <code>$DATADIR/testnet3/wallets</code>) you can run <code>bitcoin-cli loadwallet insert_wallet_name</code> and then the wallet should show up in the output of <code>bitcoin-cli listwallets</code>.</p>
<blockquote>
<p>I try to open my wallet.dat file using sqlite3 wallet.dat and then .dump but this returns an error code saying wallet.dat is not a database. What am I doing wrong here? How do I dump the contents of the wallet.dat file?</p>
</blockquote>
<p>My <code>wallet.dat</code> file was a <a href="https://github.com/bitcoin/bitcoin/issues/20160" rel="nofollow noreferrer">legacy BerkeleyDB Core wallet</a> (can check with <code>file wallet.dat</code>) rather than a non-legacy SQLite Core wallet so obviously couldn't be viewed using <code>sqlite3</code>.</p>

CC BY-SA 4.0
2022-08-22T20:50:34.667Z
2022-08-22T21:34:07.347Z
2022-08-22T21:34:07.347Z
Michael Folkson
<p>I think I've lost some testnet coins in my Core wallet and I'm not sure how. I do <code>bitcoin-cli -testnet listwallets</code> and it doesn't show any wallets for me to load. But I definitely had testnet coins a number of weeks ago in the Core wallet and I haven't deleted or edited the <code>wallet.dat</code> file manually.</p>
<ol>
<li><p>Apart from looking in my <code>wallet.dat</code> file is there anything I should do?</p>
</li>
<li><p>I try to open my <code>wallet.dat</code> file using <code>sqlite3 wallet.dat</code> and then <code>.dump</code> but this returns an error code saying <code>wallet.dat</code> is not a database. What am I doing wrong here? How do I dump the contents of the <code>wallet.dat</code> file?</p>
</li>
</ol>

CC BY-SA 4.0
2022-08-22T18:16:28.347Z
Might this `wallet.dat` be a pre-descriptors BDB wallet file? Only descriptors wallets use sqlite. What does `getwalletinfo` say?
Pieter Wuille
CC BY-SA 4.0
2022-08-22T18:41:07.517Z
@PieterWuille: Possibly... I have BDB installed and hence legacy wallet support should be built too. How do I do a listwallets for legacy/descriptors=false? I'm looking around https://github.com/bitcoin/bitcoin/issues/20160 but I haven't found instructions yet
Michael Folkson
CC BY-SA 4.0
2022-08-22T18:48:38.800Z
`getwalletinfo` says `No wallet is loaded`
Michael Folkson
CC BY-SA 4.0
2022-08-22T18:59:52.263Z
What does `file` say on the wallet.dat file?
Pieter Wuille
CC BY-SA 4.0
2022-08-22T19:24:46.793Z
wallet.dat: Berkeley DB (Btree, version 9, little-endian). So it is BDB. I'll try to dump the BDB file
Michael Folkson
CC BY-SA 4.0
2022-08-22T20:10:42.247Z
Also: listwallets only lists loaded wallets. You need to load the wallet first before you can see it. Is the problem that funds are missing, or just that the wallet isn't loaded?
Pieter Wuille
CC BY-SA 4.0
2022-08-22T20:14:53.217Z
I can't remember what I named/labeled the wallet. So I don't know what to load. At the moment funds are missing or I just don't know how to access the wallet with the funds in. Is there no CLI command to list the possible wallets that are available to load?
Michael Folkson
CC BY-SA 4.0
2022-08-22T20:26:47.360Z
Just look in $DATADIR/testnet3/wallets. I think there is a `listwalletdir` command too. If the wallet is elsewhere, you'll need to remember where you put the file...
Pieter Wuille
CC BY-SA 4.0
2022-08-22T20:29:34.090Z
Wait... you have the filename, how are you invoking `file` otherwise? If so, you can just `loadwallet` that filename.
Pieter Wuille
CC BY-SA 4.0
2022-08-22T20:41:27.207Z
Aha yes. I can get the filename from the testnet datadir and then `loadwallet` that file name . That works and I've located my testnet funds. I swear `listwalletdir` wasn't working until I `loadwallet` the file name. Was returning empty. Strange
Michael Folkson
<bitcoin-core><wallet><wallet-recovery><wallet.dat>
How do I use sqlite3 to view the contents of the wallet.dat file? Anywhere else to look for records of lost coins?
Michael Folkson
# How do I use sqlite3 to view the contents of the wallet.dat file? Anywhere else to look for records of lost coins?

(Asked by: username_0 on 2022-08-22)

I think I've lost some testnet coins in my Core wallet and I'm not sure how. I do `bitcoin-cli -testnet listwallets` and it doesn't show any wallets for me to load. But I definitely had testnet coins a number of weeks ago in the Core wallet and I haven't deleted or edited the `wallet.dat` file manually.

1. Apart from looking in my `wallet.dat` file is there anything I should do?
2. I try to open my `wallet.dat` file using `sqlite3 wallet.dat` and then `.dump` but this returns an error code saying `wallet.dat` is not a database. What am I doing wrong here? How do I dump the contents of the `wallet.dat` file?

**Tags:** bitcoin-core, wallet, wallet-recovery, wallet.dat

> **Comments:**
> **username_1**: Might this `wallet.dat` be a pre-descriptors BDB wallet file? Only descriptors wallets use sqlite. What does `getwalletinfo` say?  
> **username_0**: @username_1: Possibly... I have BDB installed and hence legacy wallet support should be built too. How do I do a listwallets for legacy/descriptors=false? I'm looking around https://github.com/bitcoin/bitcoin/issues/20160 but I haven't found instructions yet  
> **username_0**: `getwalletinfo` says `No wallet is loaded`  
> **username_1**: What does `file` say on the wallet.dat file?  
> **username_0**: wallet.dat: Berkeley DB (Btree, version 9, little-endian). So it is BDB. I'll try to dump the BDB file  
> **username_1**: Also: listwallets only lists loaded wallets. You need to load the wallet first before you can see it. Is the problem that funds are missing, or just that the wallet isn't loaded?  
> **username_0**: I can't remember what I named/labeled the wallet. So I don't know what to load. At the moment funds are missing or I just don't know how to access the wallet with the funds in. Is there no CLI command to list the possible wallets that are available to load?  
> **username_1**: Just look in $DATADIR/testnet3/wallets. I think there is a `listwalletdir` command too. If the wallet is elsewhere, you'll need to remember where you put the file...  
> **username_1**: Wait... you have the filename, how are you invoking `file` otherwise? If so, you can just `loadwallet` that filename.  
> **username_0**: Aha yes. I can get the filename from the testnet datadir and then `loadwallet` that file name . That works and I've located my testnet funds. I swear `listwalletdir` wasn't working until I `loadwallet` the file name. Was returning empty. Strange  

---

## 1 answers

### Answer by username_0 on 2022-08-22. Score: 0 | Accepted answer

With help from username_1 above (in the comments) I located my testnet coins.

The CLI command `listwalletdir` should return the available wallet names (also located in `$DATADIR/testnet3/wallets`) but I'm pretty sure this didn't work for me initially.

You can't use the CLI command `listwallets` though as this only lists wallets that have been loaded. If a wallet exists but hasn't been loaded it won't be listed in the output of `listwallets`.

If you know the name of the wallet (located in `$DATADIR/testnet3/wallets`) you can run `bitcoin-cli loadwallet insert_wallet_name` and then the wallet should show up in the output of `bitcoin-cli listwallets`.

> I try to open my wallet.dat file using sqlite3 wallet.dat and then .dump but this returns an error code saying wallet.dat is not a database. What am I doing wrong here? How do I dump the contents of the wallet.dat file?

My `wallet.dat` file was a [legacy BerkeleyDB Core wallet](https://github.com/bitcoin/bitcoin/issues/20160) (can check with `file wallet.dat`) rather than a non-legacy SQLite Core wallet so obviously couldn't be viewed using `sqlite3`.


---

