<p>There are various ways to extract and dump the private/public keys from a wallet.dat depending on how it became corrupted.</p>
<p>First, try to run -salvagewallet command to repair it.</p>
<p>If you have a tool to dump the mongo db, yes its possible to find possible keypairs (pub/priv) and dump them out using python tools. Of course you would need the passphrase for this.</p>
<p>What system are you using, mac, Linux, Windows, and what version was the wallet created with?</p>

CC BY-SA 4.0
2021-03-09T23:52:42.490Z
salvagewallet and the python tools listed earlier do not work.

Using Linux to run these utilities
watermelon
CC BY-SA 4.0
2021-03-09T15:54:16.570Z
2021-03-09T15:54:16.570Z
KeychainX
<p>I have a corrupted wallet.dat that is unreadable by pywallet and db5.3-util.</p>
<p>Having a look in the corrupted wallet in a hex editor, its easy to find the plaintext pubkeys.</p>
<p>Is the structure of the dat file such that it is possible to copy/paste sections of the corrupted wallet so that the key is now part of a new wallet file?</p>
<p>edit - it also seems useful to ask if there is any other manual process for key recovery?</p>

CC BY-SA 4.0
2021-03-05T10:19:52.423Z
Related: [What do the different .dat files contain?](https://bitcoin.stackexchange.com/q/853/13866) and less relvantly  [File format — rev*.dat](https://bitcoin.stackexchange.com/q/57978/13866) and [What is the database for](https://bitcoin.stackexchange.com/q/11104/13866)
RedGrittyBrick
CC BY-SA 4.0
2021-12-05T00:42:34.613Z
Which Bitcoin Core version did you use to initially create this wallet?
Pieter Wuille
<wallet-recovery><recover-private-key>
File structure of wallet.dat
watermelon
# File structure of wallet.dat

(Asked by: username_0 on 2021-03-05)

I have a corrupted wallet.dat that is unreadable by pywallet and db5.3-util.

Having a look in the corrupted wallet in a hex editor, its easy to find the plaintext pubkeys.

Is the structure of the dat file such that it is possible to copy/paste sections of the corrupted wallet so that the key is now part of a new wallet file?

edit - it also seems useful to ask if there is any other manual process for key recovery?

**Tags:** wallet-recovery, recover-private-key

> **Comments:**
> **username_1**: Related: [What do the different .dat files contain?](https://bitcoin.stackexchange.com/q/853/13866) and less relvantly  [File format — rev*.dat](https://bitcoin.stackexchange.com/q/57978/13866) and [What is the database for](https://bitcoin.stackexchange.com/q/11104/13866)  
> **username_2**: Which Bitcoin Core version did you use to initially create this wallet?  

---

## 1 answers

### Answer by username_3 on 2021-03-09. Score: 1

There are various ways to extract and dump the private/public keys from a wallet.dat depending on how it became corrupted.

First, try to run -salvagewallet command to repair it.

If you have a tool to dump the mongo db, yes its possible to find possible keypairs (pub/priv) and dump them out using python tools. Of course you would need the passphrase for this.

What system are you using, mac, Linux, Windows, and what version was the wallet created with?

> **Comments:**
> **username_0**: salvagewallet and the python tools listed earlier do not work.  Using Linux to run these utilities  

---

