<p>I have a ton of old backed up wallet.dat files. More than 150 ones. It's a big mess. I don't think that any of them have any coins sent to them, but there is a non-zero chance that one of them does have a small donation. I'm also trying to grab their transaction history, like you can manually do with &quot;Export as CSV&quot; in Bitcoin Core.</p>
<p>I have of course tried using my <strong>Bitcoin Core</strong>, but this is absolutely hopeless. It does a full &quot;rescan&quot; every time which in practice makes it just sit there forever. It doesn't matter if I load the wallet.dat files in via the config file or with a command in its console window; it just &quot;loads&quot; forever for no reason. This method is completely ruled out as it would take many months of nonstop full system utilization, and meanwhile I can't even use my current wallet.dat since Bitcoin Core is busy doing this pointless busywork which has nothing to do with its theoretical ability to extract data from the wallet files that it created.</p>
<p>I have also spent countless hours installing Python and the many weird dependencies that <strong>pywallet.py</strong> demands to run at all. No matter what, it just gives error messages about how it doesn't understand the wallet format when I load in my wallet.dats. Seems like completely broken and useless software. There is nothing weird about the wallet format, and they aren't corrupted. All of them were created by Bitcoin Core between 2013 and 2017 with no fancy/special options.</p>
<p>What am I supposed to do? I just want the old private keys transferred to my current wallet and their transaction history for bookkeeping purposes.</p>
<p>No existing Stack Exchange question or online discussion/webpage has a working answer. Please see the comments below...</p>

CC BY-SA 4.0
2021-10-12T11:50:53.980Z
What kind of hardware are you using? On a modern desktop, synchronizing Bitcoin Core shouldn't take more than a day or so, if it takes months, there is likely something else wrong.
Pieter Wuille
CC BY-SA 4.0
2021-10-12T12:02:56.567Z
@PieterWuille Very powerful PC. "A day or so"? So you want me to sit here for 150 straight days with this which should take seconds?
Ubaid
CC BY-SA 4.0
2021-10-12T12:05:58.073Z
Oh, I see the problem. It's rescanning all wallets in serial, not in parallel. A hacky workaround would be to add them all to your bitcoin.conf, and then start with -reindex. This will make it redo the block validation work, but while all wallets are already loaded, so they'll all be synced at the same time.
Pieter Wuille
CC BY-SA 4.0
2021-10-12T12:11:02.823Z
You can also use the separate `bitcoin-wallet` tool, which comes with Bitcoin Core. It's a standalone tool that doesn't try to synchronize with the network or anything. It has a `dump` command, but I'm not sure how useful/readable the dump format will be for you.
Pieter Wuille
CC BY-SA 4.0
2021-10-12T12:32:31.407Z
@PieterWuille Thanks for making me aware of the `bitcoin-wallet` tool which is indeed bundled with Bitcoin Core and which I was unaware of until you mentioned it. After a bit of fiddling about, I was able to make a dumpfile, and it was very quick. Unfortunately, I'm not at all sure what to make of the contents of that dumpfile, and I see no obvious way to import it back into another wallet, certainly not with any option in that tool? Also, does it include *all* data from the wallet.dat, including not only the private keys but also made transactions?
Ubaid
CC BY-SA 4.0
2021-10-12T12:43:12.203Z
It includes everything, including transactions, keys, addresses, ...
Pieter Wuille
CC BY-SA 4.0
2021-10-12T13:15:15.430Z
@PieterWuille Do I use the `importwallet` console/RPC command from Bitcoin Core when running my current wallet to "merge" the old one (as the dumpfile) into my current one?
Ubaid
CC BY-SA 4.0
2021-10-12T13:18:10.753Z
No, you can use the `wallet-tool` `createfromdump` command to create a new wallet, but I don't think a feature to merge them is really supported. You could try to concatenate all dumps (removing the first 2 lines from all but the first one), and then recreate (no promises if this will work, but it might). If you quickly want to check if the wallets have any transactions at all; transaction lines will start with "027478" (serialization of "tx" in hex).
Pieter Wuille
CC BY-SA 4.0
2021-10-12T13:24:13.850Z
@PieterWuille That's... frustrating. The idea was to grab all the old ones's unique data into my current one. Your idea might work, but I bet it's going to bark when it sees duplicate keys/entries and it'll be a hell to clean that up...
Ubaid
CC BY-SA 4.0
2021-10-12T13:51:17.980Z
@PieterWuille I'm sad to report that what you suggested doesn't seem to work. I tried by first creating a new wallet manually with just one receive address labeled "TEST", then using `bitcoin-wallet.exe` to dump my current wallet as well as the new manually created one into a dumpfile each. Then I made a new file called combo.txt where I copied the dumpfile from my current wallet and then pasted all but the two first lines of the second dumpfile afterwards, then used `createfromdump` to create a new wallet. When starting Bitcoin Core, it only sees the data for my current
Ubaid
CC BY-SA 4.0
2021-10-12T13:51:21.257Z
wallet -- no "TEST" receive address from the test wallet. So it doesn't work like that. :(
Ubaid
CC BY-SA 4.0
2021-10-12T13:52:33.343Z
(And yes, naturally I have selected the right wallet in the GUI.)
Ubaid
CC BY-SA 4.0
2021-10-12T19:09:33.320Z
Sigh. I can't find any solution. What is the way?
Ubaid
CC BY-SA 4.0
2021-10-12T19:18:40.483Z
Can't "shrink" the number of wallets? Is any wallet a strict subset of another?
Mercedes
CC BY-SA 4.0
2021-10-12T19:20:29.347Z
@Mercedes Many dupes, but not identical files still. But there's still a bunch even after removing near-similar ones...
Ubaid
CC BY-SA 4.0
2021-10-12T19:20:53.753Z
I don't understand why Bitcoin Core has this tool which dumps wallets in an undocumented manner and then has no way to import/restore/merge them back in.
Ubaid
CC BY-SA 4.0
2021-10-12T19:28:59.363Z
I'd use wallet metadata (you should have elsewhere, out of the wallet) to restore only the last wallet (or a few wallets) per user. If you can't do that, you could save the wallets, wait till the node program is separated from the wallet program (several versions from now), then in the future run multiple instances of the wallet program on top of the single node program.
Mercedes
CC BY-SA 4.0
2021-10-12T19:29:58.720Z
@Mercedes I don't understand what you're saying at all...
Ubaid
CC BY-SA 4.0
2021-10-12T19:40:20.417Z
If those wallets aren't from users, that could mean all of the wallets are yours. How on earth could you have more than 150 wallets for a single person? Some must certainly be strict subsets of others. About process separation, read [this](https://github.com/bitcoin/bitcoin/projects/10).
Mercedes
CC BY-SA 4.0
2021-10-12T19:57:21.803Z
@Mercedes Why not stay on topic of how to solve the problem instead of speculating about these were used for?
Ubaid
CC BY-SA 4.0
2021-10-12T19:58:30.300Z
@Ubaid `bitcoin-wallet -help` will give you documentation on the supported features, which includes restoring from a dump. Merging wallets has never been a supported operation. My suggestion at this point is what I said earlier: load all wallets, and start with `-reindex`, so all wallets are rescanned in parallel.
Pieter Wuille
CC BY-SA 4.0
2021-10-12T20:21:28.693Z
@PieterWuille I'm well aware of its help section. How do you think I used the tool at all? But it has no way to import the dump -- only to create a new wallet from *one* of them. Which is pointless. Might as well use that wallet.dat then.
Ubaid
CC BY-SA 4.0
2021-10-12T20:22:13.353Z
Sigh... If that's the only way...
Ubaid
<transactions><wallet.dat><private-key-export>
What is the correct way to extract all the private keys and transaction data from many wallet.dat files?
Ubaid
# What is the correct way to extract all the private keys and transaction data from many wallet.dat files?

(Asked by: username_0 on 2021-10-12)

I have a ton of old backed up wallet.dat files. More than 150 ones. It's a big mess. I don't think that any of them have any coins sent to them, but there is a non-zero chance that one of them does have a small donation. I'm also trying to grab their transaction history, like you can manually do with "Export as CSV" in Bitcoin Core.

I have of course tried using my **Bitcoin Core**, but this is absolutely hopeless. It does a full "rescan" every time which in practice makes it just sit there forever. It doesn't matter if I load the wallet.dat files in via the config file or with a command in its console window; it just "loads" forever for no reason. This method is completely ruled out as it would take many months of nonstop full system utilization, and meanwhile I can't even use my current wallet.dat since Bitcoin Core is busy doing this pointless busywork which has nothing to do with its theoretical ability to extract data from the wallet files that it created.

I have also spent countless hours installing Python and the many weird dependencies that **pywallet.py** demands to run at all. No matter what, it just gives error messages about how it doesn't understand the wallet format when I load in my wallet.dats. Seems like completely broken and useless software. There is nothing weird about the wallet format, and they aren't corrupted. All of them were created by Bitcoin Core between 2013 and 2017 with no fancy/special options.

What am I supposed to do? I just want the old private keys transferred to my current wallet and their transaction history for bookkeeping purposes.

No existing Stack Exchange question or online discussion/webpage has a working answer. Please see the comments below...

**Tags:** transactions, wallet.dat, private-key-export

> **Comments:**
> **username_1**: What kind of hardware are you using? On a modern desktop, synchronizing Bitcoin Core shouldn't take more than a day or so, if it takes months, there is likely something else wrong.  
> **username_0**: @username_1 Very powerful PC. "A day or so"? So you want me to sit here for 150 straight days with this which should take seconds?  
> **username_1**: Oh, I see the problem. It's rescanning all wallets in serial, not in parallel. A hacky workaround would be to add them all to your bitcoin.conf, and then start with -reindex. This will make it redo the block validation work, but while all wallets are already loaded, so they'll all be synced at the same time.  
> **username_1**: You can also use the separate `bitcoin-wallet` tool, which comes with Bitcoin Core. It's a standalone tool that doesn't try to synchronize with the network or anything. It has a `dump` command, but I'm not sure how useful/readable the dump format will be for you.  
> **username_0**: @username_1 Thanks for making me aware of the `bitcoin-wallet` tool which is indeed bundled with Bitcoin Core and which I was unaware of until you mentioned it. After a bit of fiddling about, I was able to make a dumpfile, and it was very quick. Unfortunately, I'm not at all sure what to make of the contents of that dumpfile, and I see no obvious way to import it back into another wallet, certainly not with any option in that tool? Also, does it include *all* data from the wallet.dat, including not only the private keys but also made transactions?  
> **username_1**: It includes everything, including transactions, keys, addresses, ...  
> **username_0**: @username_1 Do I use the `importwallet` console/RPC command from Bitcoin Core when running my current wallet to "merge" the old one (as the dumpfile) into my current one?  
> **username_1**: No, you can use the `wallet-tool` `createfromdump` command to create a new wallet, but I don't think a feature to merge them is really supported. You could try to concatenate all dumps (removing the first 2 lines from all but the first one), and then recreate (no promises if this will work, but it might). If you quickly want to check if the wallets have any transactions at all; transaction lines will start with "027478" (serialization of "tx" in hex).  
> **username_0**: @username_1 That's... frustrating. The idea was to grab all the old ones's unique data into my current one. Your idea might work, but I bet it's going to bark when it sees duplicate keys/entries and it'll be a hell to clean that up...  
> **username_0**: @username_1 I'm sad to report that what you suggested doesn't seem to work. I tried by first creating a new wallet manually with just one receive address labeled "TEST", then using `bitcoin-wallet.exe` to dump my current wallet as well as the new manually created one into a dumpfile each. Then I made a new file called combo.txt where I copied the dumpfile from my current wallet and then pasted all but the two first lines of the second dumpfile afterwards, then used `createfromdump` to create a new wallet. When starting Bitcoin Core, it only sees the data for my current  
> **username_0**: wallet -- no "TEST" receive address from the test wallet. So it doesn't work like that. :(  
> **username_0**: (And yes, naturally I have selected the right wallet in the GUI.)  
> **username_0**: Sigh. I can't find any solution. What is the way?  
> **username_2**: Can't "shrink" the number of wallets? Is any wallet a strict subset of another?  
> **username_0**: @username_2 Many dupes, but not identical files still. But there's still a bunch even after removing near-similar ones...  
> **username_0**: I don't understand why Bitcoin Core has this tool which dumps wallets in an undocumented manner and then has no way to import/restore/merge them back in.  
> **username_2**: I'd use wallet metadata (you should have elsewhere, out of the wallet) to restore only the last wallet (or a few wallets) per user. If you can't do that, you could save the wallets, wait till the node program is separated from the wallet program (several versions from now), then in the future run multiple instances of the wallet program on top of the single node program.  
> **username_0**: @username_2 I don't understand what you're saying at all...  
> **username_2**: If those wallets aren't from users, that could mean all of the wallets are yours. How on earth could you have more than 150 wallets for a single person? Some must certainly be strict subsets of others. About process separation, read [this](https://github.com/bitcoin/bitcoin/projects/10).  
> **username_0**: @username_2 Why not stay on topic of how to solve the problem instead of speculating about these were used for?  
> **username_1**: @username_0 `bitcoin-wallet -help` will give you documentation on the supported features, which includes restoring from a dump. Merging wallets has never been a supported operation. My suggestion at this point is what I said earlier: load all wallets, and start with `-reindex`, so all wallets are rescanned in parallel.  
> **username_0**: @username_1 I'm well aware of its help section. How do you think I used the tool at all? But it has no way to import the dump -- only to create a new wallet from *one* of them. Which is pointless. Might as well use that wallet.dat then.  
> **username_0**: Sigh... If that's the only way...  

---

## 0 answers

