<p>I doubt there is a canned solution sitting on a shelf somewhere. However there is almost always a way to solve problems like this, if you are willing to invest time and effort.</p>
<p>Since your log says</p>
<pre><code> Legacy Wallet Keys: 0 plaintext, 206 encrypted, 0 w/ metadata, 206 total.
</code></pre>
<p>We know that the wallet db file contains 206 encrypted keys.</p>
<p>I imagine you can use one of the BDB tools such as <a href="https://bitcoin.stackexchange.com/q/88317/13866">db_dump</a> to extract those 206 data values.</p>
<p>If you know the password for the wallet, it is possible, in principle, to decrypt each of those data values. Maybe using openssl or other tools. Maybe by writing a short script/program in Python or your preferred language. I believe the keys are encrypted individually so that the password is only needed when spending money, not when merely checking balance or receiving money (creating a new receiving address).</p>
<p>You might then be able to import those unencrypted keys into a legacy wallet or create descriptors for importing into a descriptor-wallet.</p>
<p>I think it would be prudent to sweep the Bitcoin into a new wallet after recovery but that would obviously incur costs.</p>
<ul>
<li><a href="https://bitcoin.stackexchange.com/q/117209/13866">How to import a descriptor into a wallet?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/118127/13866">How to recover and sweep P2PK coins</a></li>
</ul>

CC BY-SA 4.0
2024-03-03T14:09:14.463Z
the [wallet key tool](https://github.com/prof7bit/wallet-key-tool) already generated a list of address/key/description.   I don't see any tutorials from the link you provided on how to obtain and use `db_dump` tool.
And no one is telling us how to [re]create a legacy wallet to where we can import our private keys.
I could try the `create descriptors` method; can you please point me to a tutorial or template that has the steps for this?  Or update your answer with steps.
Jon Grah
CC BY-SA 4.0
2024-03-03T19:32:34.883Z
See links appended to  answer
RedGrittyBrick
CC BY-SA 4.0
2024-03-03T10:15:08.333Z
2024-03-03T19:30:27.063Z
2024-03-03T19:30:27.063Z
RedGrittyBrick
<p>Try running an older version of bitcoin core, like v12.1 or v0.11, these were still in use around 2016/2017 before segwit fork. You might have better luck.</p>
<p>Otherwise if you have the private keys for the addresses, simply import them into the running node. If you import them at the start of syncing (assuming syncing from scratch), it won't have to rescan each time you do an importprivkey.</p>
<p>Good luck, hope there is lots of change for you!!</p>

CC BY-SA 4.0
2024-03-14T10:55:44.033Z
i actually didn't attempt this (older version).   But I ended up using blockchain.com which relaxed my mind after I saw how easily they imported the private key.   I was typing an answer to the question and then I got distracted.
Jon Grah
CC BY-SA 4.0
2024-03-14T10:56:30.360Z
can you provide step-by-step to the "simply import them into the running node"?
Jon Grah
CC BY-SA 4.0
2024-08-16T22:18:03.280Z
How exactly did you import a `wallet.dat` file in blockchain.com?
Vinny
CC BY-SA 4.0
2024-03-13T16:16:35.987Z
2024-03-13T16:16:35.987Z
Mylo Mylo
<p>Ok.  So I have a bitcoin core wallet from around August, 2012.  I don't think I backed it up &quot;properly&quot; in that I just copied the wallet.dat file, zipped it and stuck it in cloud storage.</p>
<p>I have some change in 2 of the addresses, which I've later learned split into BTC Cash as well.</p>
<p>I've loaded Bitcoin Core 22.0.0 and have completely synced the blockchain.  No wallets loaded or new wallets created at this point.   Then I tried to <code>restore</code> the <code>old-wallet.dat</code> and after about 20+ minutes, I get this popup error:</p>
<p><a href="https://i.sstatic.net/AA2OF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AA2OF.png" alt="Open wallet failed: DB error adding transaction to wallet, write failed" /></a></p>
<p>And the <code>db.log</code> in the <code>AppData\Roaming\..\old-wallet\</code> shows</p>
<pre><code>file wallet.dat has LSN 1/76511, past end of log at 1/476
Commonly caused by moving a database from one database environment
to another without clearing the database LSNs, or by removing all of
the log files from a database environment
[..... these 4 lines repeat 48 times]
</code></pre>
<p>the <code>debug.log</code></p>
<pre><code>2024-03-02T17:22:43Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2024-03-02T17:22:43Z Using wallet C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\wallet.dat
2024-03-02T17:22:43Z BerkeleyEnvironment::Open: LogDir=C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\database ErrorFile=C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\db.log
2024-03-02T17:22:43Z init message: Loading wallet…
2024-03-02T17:22:43Z [Old-Wallet] Wallet file version = 10500, last client version = 260000
2024-03-02T17:22:43Z [Old-Wallet] Legacy Wallet Keys: 0 plaintext, 206 encrypted, 0 w/ metadata, 206 total.
2024-03-02T17:22:43Z [Old-Wallet] Descriptors: 0, Descriptor Keys: 0 plaintext, 0 encrypted, 0 total.
2024-03-02T17:22:43Z [Old-Wallet] Wallet completed loading in              56ms
2024-03-02T17:22:43Z init message: Rescanning…
2024-03-02T17:22:43Z [Old-Wallet] Rescanning last 493953 blocks (from block 338894)...
2024-03-02T17:22:43Z [Old-Wallet] Rescan started from block 00000000000000000ff6f346bea61d1c87e455e2dd4e1da154e830dcfddba1f9... (slow variant inspecting all blocks)
2024-03-02T17:23:43Z [Old-Wallet] Still rescanning. At block 350638. Progress=0.066077
2024-03-02T17:23:43Z [Old-Wallet] Saving scan progress 350638.
2024-03-02T17:24:43Z [Old-Wallet] Still rescanning. At block 361394. Progress=0.074327
2024-03-02T17:24:43Z [Old-Wallet] Saving scan progress 361394.
2024-03-02T17:25:43Z [Old-Wallet] Still rescanning. At block 368839. Progress=0.081201
2024-03-02T17:25:43Z [Old-Wallet] Saving scan progress 368839.
2024-03-02T17:26:43Z [Old-Wallet] Still rescanning. At block 377874. Progress=0.089103
2024-03-02T17:26:43Z [Old-Wallet] Saving scan progress 377874.
2024-03-02T17:27:43Z [Old-Wallet] Still rescanning. At block 385876. Progress=0.097212
2024-03-02T17:27:43Z [Old-Wallet] Saving scan progress 385876.
2024-03-02T17:28:43Z [Old-Wallet] Still rescanning. At block 392935. Progress=0.105676
2024-03-02T17:28:43Z [Old-Wallet] Saving scan progress 392935.
2024-03-02T17:29:43Z [Old-Wallet] Still rescanning. At block 398759. Progress=0.113347
2024-03-02T17:29:43Z [Old-Wallet] Saving scan progress 398759.
2024-03-02T17:30:43Z [Old-Wallet] Still rescanning. At block 404095. Progress=0.121186
2024-03-02T17:30:43Z [Old-Wallet] Saving scan progress 404095.
2024-03-02T17:31:43Z [Old-Wallet] Still rescanning. At block 410007. Progress=0.129667
2024-03-02T17:31:43Z [Old-Wallet] Saving scan progress 410007.
2024-03-02T17:32:43Z [Old-Wallet] Still rescanning. At block 415252. Progress=0.137660
2024-03-02T17:32:43Z [Old-Wallet] Saving scan progress 415252.
2024-03-02T17:33:43Z [Old-Wallet] Still rescanning. At block 420359. Progress=0.145469
2024-03-02T17:33:43Z [Old-Wallet] Saving scan progress 420359.
2024-03-02T17:34:43Z [Old-Wallet] Still rescanning. At block 424845. Progress=0.152556
2024-03-02T17:34:43Z [Old-Wallet] Saving scan progress 424845.
2024-03-02T17:35:43Z [Old-Wallet] Still rescanning. At block 429990. Progress=0.160343
2024-03-02T17:35:43Z [Old-Wallet] Saving scan progress 429990.
2024-03-02T17:36:43Z [Old-Wallet] Still rescanning. At block 435183. Progress=0.168730
2024-03-02T17:36:44Z [Old-Wallet] Saving scan progress 435183.
2024-03-02T17:37:44Z [Old-Wallet] Still rescanning. At block 439881. Progress=0.176782
2024-03-02T17:37:44Z [Old-Wallet] Saving scan progress 439881.
2024-03-02T17:38:44Z [Old-Wallet] Still rescanning. At block 444238. Progress=0.185090
2024-03-02T17:38:44Z [Old-Wallet] Saving scan progress 444238.
2024-03-02T17:39:44Z [Old-Wallet] Still rescanning. At block 448552. Progress=0.193078
2024-03-02T17:39:44Z [Old-Wallet] Saving scan progress 448552.
2024-03-02T17:40:44Z [Old-Wallet] Still rescanning. At block 453098. Progress=0.201544
2024-03-02T17:40:44Z [Old-Wallet] Saving scan progress 453098.
2024-03-02T17:41:44Z [Old-Wallet] Still rescanning. At block 457196. Progress=0.209873
2024-03-02T17:41:44Z [Old-Wallet] Saving scan progress 457196.
2024-03-02T17:42:44Z [Old-Wallet] Still rescanning. At block 461365. Progress=0.217692
2024-03-02T17:42:44Z [Old-Wallet] Saving scan progress 461365.
2024-03-02T17:43:44Z [Old-Wallet] Still rescanning. At block 465338. Progress=0.225723
2024-03-02T17:43:44Z [Old-Wallet] Saving scan progress 465338.
2024-03-02T17:44:44Z [Old-Wallet] Still rescanning. At block 469048. Progress=0.233615
2024-03-02T17:44:44Z [Old-Wallet] Saving scan progress 469048.
2024-03-02T17:45:44Z [Old-Wallet] Still rescanning. At block 473171. Progress=0.241268
2024-03-02T17:45:44Z [Old-Wallet] Saving scan progress 473171.
2024-03-02T17:46:07Z [Old-Wallet] AddToWallet 4306eb4278cd03af36b9b4bb2bbfceaa2297acad4293c724255c792d8c02d9ac  new Confirmed (block=000000000000000000dc975c23fd082c77d57feef2f98ec23a27f907616101ba, height=475104, index=548)
2024-03-02T17:46:07Z Flushed fee estimates to fee_estimates.dat.
2024-03-02T17:49:13Z New block-relay-only v1 peer connected: version: 70016, blocks=832847, peer=33
</code></pre>
<ul>
<li><p>So I noticed that Bitcoin QT never prompted me for the encryption password when importing this <code>wallet.dat</code>...or at least I never remembered seeing the prompt.  Not sure if that means anything.</p>
</li>
<li><p>I was able to use this <a href="https://github.com/prof7bit/wallet-key-tool" rel="nofollow noreferrer">wallet key tool</a> to view the <code>old-wallet.dat</code> file. (I was prompted for the encryption key each time I wanted to decrypt it). So IMO, the database can't be that corrupt if a reader is able to open it.</p>
<p>It appeared to be a list of strings.  One column had addresses, another column had private keys associated with each address, and another column had what appeared to be address labels that I remember giving to some of the addresses. The <code>date created</code> column doesn't appear accurate.</p>
</li>
</ul>
<p><a href="https://i.sstatic.net/zMCbx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zMCbx.png" alt="wallet key tool screenshot" /></a></p>
<p>But there were more addresses than I created  (I had either 6 or 8 addresses, but there were more than 200 rows of addresses/key combinations).</p>
<h2>So here are my questions:</h2>
<p>-&gt; Is it possible using Bitcoin Core to get this <code>old-wallet.dat</code> file to import properly and addresses show up in the GUI.</p>
<p>-&gt; Is there a way to rebuild the wallet.dat file?  It seems to crash as newer transactions may have additional columns that the older database doesn't have.</p>
<p>-&gt; is there another way to force import the addresses/keys?  (in Bitcoin core or like using a different wallet) to where I can sweep/access the bitcoins?</p>
<p>-&gt; why was 3rd party tool able to read .dat file (after decrypting) but Bitcoin Core cannot?  Or why isn't there a simply way to do this?</p>

<bitcoin-core><wallet-recovery><bitcoin-cli>
Recover bitcoin from wallet.dat from 2012 (probably not backed up properly)
Jon Grah
# Recover bitcoin from wallet.dat from 2012 (probably not backed up properly)

(Asked by: username_0 on 2024-03-02)

Ok. So I have a bitcoin core wallet from around August, 2012. I don't think I backed it up "properly" in that I just copied the wallet.dat file, zipped it and stuck it in cloud storage.

I have some change in 2 of the addresses, which I've later learned split into BTC Cash as well.

I've loaded Bitcoin Core 22.0.0 and have completely synced the blockchain. No wallets loaded or new wallets created at this point. Then I tried to `restore` the `old-wallet.dat` and after about 20+ minutes, I get this popup error:

[![Open wallet failed: DB error adding transaction to wallet, write failed](https://i.sstatic.net/AA2OF.png)](https://i.sstatic.net/AA2OF.png)

And the `db.log` in the `AppData\Roaming\..\old-wallet\` shows

```
file wallet.dat has LSN 1/76511, past end of log at 1/476
Commonly caused by moving a database from one database environment
to another without clearing the database LSNs, or by removing all of
the log files from a database environment
[..... these 4 lines repeat 48 times]

```

the `debug.log`

```
2024-03-02T17:22:43Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2024-03-02T17:22:43Z Using wallet C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\wallet.dat
2024-03-02T17:22:43Z BerkeleyEnvironment::Open: LogDir=C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\database ErrorFile=C:\Users\...\AppData\Roaming\Bitcoin\wallets\Old-Wallet\db.log
2024-03-02T17:22:43Z init message: Loading wallet…
2024-03-02T17:22:43Z [Old-Wallet] Wallet file version = 10500, last client version = 260000
2024-03-02T17:22:43Z [Old-Wallet] Legacy Wallet Keys: 0 plaintext, 206 encrypted, 0 w/ metadata, 206 total.
2024-03-02T17:22:43Z [Old-Wallet] Descriptors: 0, Descriptor Keys: 0 plaintext, 0 encrypted, 0 total.
2024-03-02T17:22:43Z [Old-Wallet] Wallet completed loading in              56ms
2024-03-02T17:22:43Z init message: Rescanning…
2024-03-02T17:22:43Z [Old-Wallet] Rescanning last 493953 blocks (from block 338894)...
2024-03-02T17:22:43Z [Old-Wallet] Rescan started from block 00000000000000000ff6f346bea61d1c87e455e2dd4e1da154e830dcfddba1f9... (slow variant inspecting all blocks)
2024-03-02T17:23:43Z [Old-Wallet] Still rescanning. At block 350638. Progress=0.066077
2024-03-02T17:23:43Z [Old-Wallet] Saving scan progress 350638.
2024-03-02T17:24:43Z [Old-Wallet] Still rescanning. At block 361394. Progress=0.074327
2024-03-02T17:24:43Z [Old-Wallet] Saving scan progress 361394.
2024-03-02T17:25:43Z [Old-Wallet] Still rescanning. At block 368839. Progress=0.081201
2024-03-02T17:25:43Z [Old-Wallet] Saving scan progress 368839.
2024-03-02T17:26:43Z [Old-Wallet] Still rescanning. At block 377874. Progress=0.089103
2024-03-02T17:26:43Z [Old-Wallet] Saving scan progress 377874.
2024-03-02T17:27:43Z [Old-Wallet] Still rescanning. At block 385876. Progress=0.097212
2024-03-02T17:27:43Z [Old-Wallet] Saving scan progress 385876.
2024-03-02T17:28:43Z [Old-Wallet] Still rescanning. At block 392935. Progress=0.105676
2024-03-02T17:28:43Z [Old-Wallet] Saving scan progress 392935.
2024-03-02T17:29:43Z [Old-Wallet] Still rescanning. At block 398759. Progress=0.113347
2024-03-02T17:29:43Z [Old-Wallet] Saving scan progress 398759.
2024-03-02T17:30:43Z [Old-Wallet] Still rescanning. At block 404095. Progress=0.121186
2024-03-02T17:30:43Z [Old-Wallet] Saving scan progress 404095.
2024-03-02T17:31:43Z [Old-Wallet] Still rescanning. At block 410007. Progress=0.129667
2024-03-02T17:31:43Z [Old-Wallet] Saving scan progress 410007.
2024-03-02T17:32:43Z [Old-Wallet] Still rescanning. At block 415252. Progress=0.137660
2024-03-02T17:32:43Z [Old-Wallet] Saving scan progress 415252.
2024-03-02T17:33:43Z [Old-Wallet] Still rescanning. At block 420359. Progress=0.145469
2024-03-02T17:33:43Z [Old-Wallet] Saving scan progress 420359.
2024-03-02T17:34:43Z [Old-Wallet] Still rescanning. At block 424845. Progress=0.152556
2024-03-02T17:34:43Z [Old-Wallet] Saving scan progress 424845.
2024-03-02T17:35:43Z [Old-Wallet] Still rescanning. At block 429990. Progress=0.160343
2024-03-02T17:35:43Z [Old-Wallet] Saving scan progress 429990.
2024-03-02T17:36:43Z [Old-Wallet] Still rescanning. At block 435183. Progress=0.168730
2024-03-02T17:36:44Z [Old-Wallet] Saving scan progress 435183.
2024-03-02T17:37:44Z [Old-Wallet] Still rescanning. At block 439881. Progress=0.176782
2024-03-02T17:37:44Z [Old-Wallet] Saving scan progress 439881.
2024-03-02T17:38:44Z [Old-Wallet] Still rescanning. At block 444238. Progress=0.185090
2024-03-02T17:38:44Z [Old-Wallet] Saving scan progress 444238.
2024-03-02T17:39:44Z [Old-Wallet] Still rescanning. At block 448552. Progress=0.193078
2024-03-02T17:39:44Z [Old-Wallet] Saving scan progress 448552.
2024-03-02T17:40:44Z [Old-Wallet] Still rescanning. At block 453098. Progress=0.201544
2024-03-02T17:40:44Z [Old-Wallet] Saving scan progress 453098.
2024-03-02T17:41:44Z [Old-Wallet] Still rescanning. At block 457196. Progress=0.209873
2024-03-02T17:41:44Z [Old-Wallet] Saving scan progress 457196.
2024-03-02T17:42:44Z [Old-Wallet] Still rescanning. At block 461365. Progress=0.217692
2024-03-02T17:42:44Z [Old-Wallet] Saving scan progress 461365.
2024-03-02T17:43:44Z [Old-Wallet] Still rescanning. At block 465338. Progress=0.225723
2024-03-02T17:43:44Z [Old-Wallet] Saving scan progress 465338.
2024-03-02T17:44:44Z [Old-Wallet] Still rescanning. At block 469048. Progress=0.233615
2024-03-02T17:44:44Z [Old-Wallet] Saving scan progress 469048.
2024-03-02T17:45:44Z [Old-Wallet] Still rescanning. At block 473171. Progress=0.241268
2024-03-02T17:45:44Z [Old-Wallet] Saving scan progress 473171.
2024-03-02T17:46:07Z [Old-Wallet] AddToWallet 4306eb4278cd03af36b9b4bb2bbfceaa2297acad4293c724255c792d8c02d9ac  new Confirmed (block=000000000000000000dc975c23fd082c77d57feef2f98ec23a27f907616101ba, height=475104, index=548)
2024-03-02T17:46:07Z Flushed fee estimates to fee_estimates.dat.
2024-03-02T17:49:13Z New block-relay-only v1 peer connected: version: 70016, blocks=832847, peer=33

```

* So I noticed that Bitcoin QT never prompted me for the encryption password when importing this `wallet.dat`...or at least I never remembered seeing the prompt. Not sure if that means anything.
* I was able to use this [wallet key tool](https://github.com/prof7bit/wallet-key-tool) to view the `old-wallet.dat` file. (I was prompted for the encryption key each time I wanted to decrypt it). So IMO, the database can't be that corrupt if a reader is able to open it.

  It appeared to be a list of strings. One column had addresses, another column had private keys associated with each address, and another column had what appeared to be address labels that I remember giving to some of the addresses. The `date created` column doesn't appear accurate.

[![wallet key tool screenshot](https://i.sstatic.net/zMCbx.png)](https://i.sstatic.net/zMCbx.png)

But there were more addresses than I created (I had either 6 or 8 addresses, but there were more than 200 rows of addresses/key combinations).

## So here are my questions:

-> Is it possible using Bitcoin Core to get this `old-wallet.dat` file to import properly and addresses show up in the GUI.

-> Is there a way to rebuild the wallet.dat file? It seems to crash as newer transactions may have additional columns that the older database doesn't have.

-> is there another way to force import the addresses/keys? (in Bitcoin core or like using a different wallet) to where I can sweep/access the bitcoins?

-> why was 3rd party tool able to read .dat file (after decrypting) but Bitcoin Core cannot? Or why isn't there a simply way to do this?

**Tags:** bitcoin-core, wallet-recovery, bitcoin-cli


---

## 2 answers

### Answer by username_1 on 2024-03-03. Score: 1

I doubt there is a canned solution sitting on a shelf somewhere. However there is almost always a way to solve problems like this, if you are willing to invest time and effort.

Since your log says

```
 Legacy Wallet Keys: 0 plaintext, 206 encrypted, 0 w/ metadata, 206 total.

```

We know that the wallet db file contains 206 encrypted keys.

I imagine you can use one of the BDB tools such as [db\_dump](https://bitcoin.stackexchange.com/q/88317/13866) to extract those 206 data values.

If you know the password for the wallet, it is possible, in principle, to decrypt each of those data values. Maybe using openssl or other tools. Maybe by writing a short script/program in Python or your preferred language. I believe the keys are encrypted individually so that the password is only needed when spending money, not when merely checking balance or receiving money (creating a new receiving address).

You might then be able to import those unencrypted keys into a legacy wallet or create descriptors for importing into a descriptor-wallet.

I think it would be prudent to sweep the Bitcoin into a new wallet after recovery but that would obviously incur costs.

* [How to import a descriptor into a wallet?](https://bitcoin.stackexchange.com/q/117209/13866)
* [How to recover and sweep P2PK coins](https://bitcoin.stackexchange.com/q/118127/13866)

> **Comments:**
> **username_0**: the [wallet key tool](https://github.com/prof7bit/wallet-key-tool) already generated a list of address/key/description.   I don't see any tutorials from the link you provided on how to obtain and use `db_dump` tool. And no one is telling us how to [re]create a legacy wallet to where we can import our private keys. I could try the `create descriptors` method; can you please point me to a tutorial or template that has the steps for this?  Or update your answer with steps.  
> **username_1**: See links appended to  answer  

---

### Answer by username_2 on 2024-03-13. Score: 0

Try running an older version of bitcoin core, like v12.1 or v0.11, these were still in use around 2016/2017 before segwit fork. You might have better luck.

Otherwise if you have the private keys for the addresses, simply import them into the running node. If you import them at the start of syncing (assuming syncing from scratch), it won't have to rescan each time you do an importprivkey.

Good luck, hope there is lots of change for you!!

> **Comments:**
> **username_0**: i actually didn't attempt this (older version).   But I ended up using blockchain.com which relaxed my mind after I saw how easily they imported the private key.   I was typing an answer to the question and then I got distracted.  
> **username_0**: can you provide step-by-step to the "simply import them into the running node"?  
> **username_3**: How exactly did you import a `wallet.dat` file in blockchain.com?  

---

