Author

Topic: Restoring wallet.dat to Bitcoin core client on Macbook (Read 208 times)

legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
-snip-
Thanks! I'm assuming we can set the addresstype just so that dumpwallet only outputs private keys for that address type, thereby reducing the output
Unfortunately no, it wont reduce the amount of keys in the output.
The setting will only change the associated address derived from each private key, the number of private keys in your wallet remains the same.

As you can see in my example, the WIF private key is the same (in testnet, the ones starting with "c") while the address changes depending on the setting.
Legacy Bitcoin Core can derive three address types from your private keys, the setting just let you pick which one to associate with the private key in the dump file.

On the contrary, since you don't know which address has balance, you may have to dump three separate dumpwallets, each with different address types.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Let's say we have extracted lot of addresses from the wallet (say more than 2000), is there a quick and safe way to bulk check their balance?
You can use my list of funded addresses locally (explanation in that topic) to see which addresses are funded. This can be done offline and in private.

Since you have an old wallet, you should note that funds sent to pubkey don't show up in a watch-only Electrum wallet.



You have "privacy" in your name. Dumping all addresses in Electrum or a block explorer kinda tells someone they all belong to one person.
hero member
Activity: 406
Merit: 443
I quickly checked online and few options are:

1. Use websites that allow you to enter addresses in bulk and then they will check the balance. I'm assuming they do it all client-side in the browser and use an API key to query one of the blockchain explorers.
You can do this in two ways:

1)
  • Offline machine: Writing a simple script that searches for the public key (Bitcoin addresses) and extracts it to a file.
  • Online version: check the addresses that contain a balance and then return again to offline machine to extract the private keys for addresses with balance only.

2) dump wallet using pywallet.py https://github.com/jackjack-jj/pywallet using the command

Code:
python pywallet.py --dumpwallet  // (dump wallet in json format)

dealing with json format is easier than txt file.
newbie
Activity: 24
Merit: 1
And I just remembered, since you do not know which addresses have bitcoins.
If it's no too old, you have to specify which address type prior to using dummpwallet command because it'll associate such address type to the private keys in the dump file,
Those with associated transaction history saved in the wallet file even for another address type will show the correct address though.

Thanks! I'm assuming we can set the addresstype just so that dumpwallet only outputs private keys for that address type, thereby reducing the output

Let's say we have extracted lot of addresses from the wallet (say more than 2000), is there a quick and safe way to bulk check their balance?

I quickly checked online and few options are:

1. Use websites that allow you to enter addresses in bulk and then they will check the balance. I'm assuming they do it all client-side in the browser and use an API key to query one of the blockchain explorers.

2. Create a watch-only wallet in Electrum, and import all the addresses there. I haven't tried this before but I guess this could be a way
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
Isn't there a way in Bitcoin Core console to list all the wallet addresses?
I'm, not aware of any.
Most of the commands require to sync the node to update the wallet's transactions or rely on the "already-seen" addresses via GUI or command.
Getting the entire keypool from the dumpwallet is the only way if you do not want to sync it.

And I just remembered, since you do not know which addresses have bitcoins.
If it's no too old, you have to specify which address type prior to using dummpwallet command because it'll associate such address type to the private keys in the dump file,
Those with associated transaction history saved in the wallet file even for another address type will show the correct address though.

For example: If you set addresstype=bech32 in bitcoin.conf or arg, the dump file will only contain "bc1q" addresses if the WIF private keys aren't uncompressed.
If addresstype=p2sh-segwit it'll contain SegWit "3" addresses instead.

For example, here's a sample keys and address part of the dump file from the same wallet but with different addresstype= setting;
addresstype=p2sh-segwit (testnet):
Code:
-snip-
cNAwvEHcp4wkmWzFwG72httRYXxKLyRhohKF43rg5PoB7BkZGRzK 2022-05-16T13:24:06Z reserve=1 # addr=2N4goens89eLn67Ed48u6rDAxzyK1xm71EK hdkeypath=m/0'/0'/1360'
cRP2Kkso2RUrWEcYisHUjMfFhdqbgTcfJDrKuq2NPeeQWZqtibX9 2022-05-16T13:24:06Z change=1 # addr=2MsJyecsfSBoAfggNfEuxDBh8YbaYDJ5Yfv hdkeypath=m/0'/0'/1042'
cPcfaVDxLdp35fpts2BsEWZQGVxqr1Qz7w9dLLUsNrxC1kgrrwL5 2022-05-16T13:24:06Z reserve=1 # addr=2N7GwvBz1PgwnsK8AKUhdYveTvCPQk2hgp4 hdkeypath=m/0'/0'/1396'
cPafqzpXmtEDJoPKXx67rUoWDdnvdXDJ5jq8w9zCNAR5Kzpnenbw 2022-05-16T13:24:06Z change=1 # addr=2NC5o8svHHFEDZ6GMLVreLM8Ho4srtRsdTy hdkeypath=m/0'/0'/1134'
cPhJX6BiYY9KEjShsYYvosVHynnj5amMes5Zxce2k4VXTp8N7uBv 2022-05-16T13:24:06Z reserve=1 # addr=2MunSQxSVK6iQkJkZeLEXb3voDedbr8uoyW hdkeypath=m/0'/0'/1461'
cVxKGpvaHjtcFyL3nvx26MpmqWu81BpXVVzB2d43nJHrCFkxt2Ls 2022-05-16T13:24:06Z reserve=1 # addr=2N5xCx4XGqThAqaFM9fc1EuViQxQBgWZ86r hdkeypath=m/0'/0'/1383'
-snip-
addresstype=bech32 (testnet), after restarting the node:
Code:
-snip-
cNAwvEHcp4wkmWzFwG72httRYXxKLyRhohKF43rg5PoB7BkZGRzK 2022-05-16T13:24:06Z reserve=1 # addr=bcrt1qqq0hztd8gjhxjrc2a27rdj29gshsgddx7cwlv8 hdkeypath=m/0'/0'/1360'
cRP2Kkso2RUrWEcYisHUjMfFhdqbgTcfJDrKuq2NPeeQWZqtibX9 2022-05-16T13:24:06Z change=1 # addr=bcrt1qqqeut3n977pmlzpdzl0j3ccrthvranlgxvzmv6 hdkeypath=m/0'/0'/1042'
cPcfaVDxLdp35fpts2BsEWZQGVxqr1Qz7w9dLLUsNrxC1kgrrwL5 2022-05-16T13:24:06Z reserve=1 # addr=bcrt1qqpdez6rsp6gjyadtn8y2vmlj7ykljhgnqcjrcd hdkeypath=m/0'/0'/1396'
cPafqzpXmtEDJoPKXx67rUoWDdnvdXDJ5jq8w9zCNAR5Kzpnenbw 2022-05-16T13:24:06Z change=1 # addr=bcrt1qqfhnlhecg54f7caesyc73ud5temfrf7zr8zx9z hdkeypath=m/0'/0'/1134'
cPhJX6BiYY9KEjShsYYvosVHynnj5amMes5Zxce2k4VXTp8N7uBv 2022-05-16T13:24:06Z reserve=1 # addr=bcrt1qqtp6a42epm3x6kqdemg96x8973kx8kvjp0ael8 hdkeypath=m/0'/0'/1461'
cVxKGpvaHjtcFyL3nvx26MpmqWu81BpXVVzB2d43nJHrCFkxt2Ls 2022-05-16T13:24:06Z reserve=1 # addr=bcrt1qqwt6z8n4f5ly0h24tlra5gcsak4edek2s7yz4c hdkeypath=m/0'/0'/1383'
-snip-
newbie
Activity: 24
Merit: 1

You can even keep it offline to be safe and just make another "watch-only" wallet on an online machine by pasting the addresses instead of private key.


Okay, thanks. This is quite complicated although I understand the benefits of this process

Isn't there a way in Bitcoin Core console to list all the wallet addresses?

dumpwallet output will contain a lot of extra info

If I can extract all the addresses, then I'll use it to identify which ones contain the funds and proceed accordingly
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
By the way, does Electrum wallet need to be online at the time of private key import process?
Yes, that can be done offline.
You can even keep it offline to be safe and just make another "watch-only" wallet on an online machine by pasting the addresses instead of private key.

Then you can use that like a "cold-storage" setup: Create the transaction in the online Electrum, export the 'PSBT' (Partially Signed Bitcoin Transaction) to the offline Electrum and sign it.
Then transfer the signed raw transaction to back to the online Electrum to broadcast it.
Here's how to, read the transaction part: bitcoinelectrum.com/creating-a-cold-storage-wallet-in-electrum

Quote from: privacyn3on
Also, once the private keys are imported into Electrum, I can move the coins from Electrum wallet without any need for additional passphrase or authentication right?
Depends if you set a password to Electrum.
newbie
Activity: 24
Merit: 1
While you're at it, find a way to append the script type in each line as well.

Thanks!

I think it would make sense to automate some of this considering the number of lines.

If the dumpwallet output contains the wallet addresses, then I could make a backup of those addresses in another file and move it to another machine from which I can look up the addresses on the blockchain explorer.

Then I have a list of addresses which I know contain funds and extract private key only for those

By the way, does Electrum wallet need to be online at the time of private key import process?

Also, once the private keys are imported into Electrum, I can move the coins from Electrum wallet without any need for additional passphrase or authentication right?
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
So I need to extract the private keys from this file and import them into Electrum. Can I import multiple private keys at once in Electrum?
Yes, in Electrum's new wallet menu: "Import bitcoin address and private keys" option, you can paste multiple lines of WIF private keys.
And heads-up; if your addresses aren't legacy '1' addresses, you need to append the associated script type to each WIF private key.
When importing to Electrum, click "more info" to see those script types. (spoiler: p2wpkh:private_key or p2wpkh-p2sh:private_key)

E.g.:
Code:
L4ZV9ZAeze7NyhSFBt59EsxLmZvYhfsMiP9sVjcy2mCYVKNKHWnC
p2wpkh:L3sxVzU2XG6WUCASbQsoe5fKS3Dnu1Sg7gsJ9AbLnAaqATeFSRo3
p2wpkh-p2sh:KweiFm9GRmr6bmT9kmUT2dtwKBEBVE7rg3jpRKJtpTTdm6miS87G
5HwrwBCJPj8afcTrjkCT44doBbgF2ENm7NNMCSnJcJ8Aq9k9752

Thanks for the response. Can you please elaborate on this part?

I'm assuming dumpwallet output includes both the addresses and the corresponding private keys
There'll be more data in the dump file than that but AFAIK, some tools can remove unnecessary texts from a text file but it's out of Bitcoin's scope so you'll need to do your own research regarding that.
Or you can manually copy-paste each WIF private key to a new text file, one per line. (there's at least 2000 of them if the wallet is relatively new or loaded to newer Core client)
While you're at it, find a way to append the script type in each line as well.

Based from that, you would need to leave the lines:
Code:
private key 1
private key 2
...
newbie
Activity: 24
Merit: 1
If not, dumpwallet, then extract the private keys from the wallet dump file,
e.g.: Google search for ways to extract the texts that you need from a text file, but you must only meddle with the dump file in an air-gap machine.

Thanks for the response. Can you please elaborate on this part?

I'm assuming dumpwallet output includes both the addresses and the corresponding private keys

Code:
address 1 : private key 1
address 2 : private key 2
...

So I need to extract the private keys from this file and import them into Electrum. Can I import multiple private keys at once in Electrum?
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
My question regarding this was more about "if I just need to dumpwallet from console in Bitcoin Core, then do I really need Bitcoin core to start syncing?"
Yes, dumpwallet will work even offline.

Can someone confirm how to import the whole wallet into Electrum instead of all the private keys one by one?
A workaround to that is only possible in the newer "descriptor wallet" that has a compatible extended public/private key at account_index.

But your old legacy wallet.dat uses "hardened addresses" which Electrum doesn't support.
For clarification, Even if your wallet is HD, you simply cannot derive the master private key to be imported to Electrum as master key because Electrum will derive addresses with unhardened derivation while your Bitcoin Core used hardened derivation to derive your private keys from it.

Quote from: privacyn3on
dumprivkey works with only one address at a time
dumpwallet should dump whole wallet. Then do I just copy paste all the private keys into Electrum to import all at once?

Which method is recommended?
Depends if you know which addresses are funded.
If you know which ones, and you can count them with your fingers (and toes), then dumpprivkey is the way.
If not, dumpwallet, then extract the private keys from the wallet dump file,
e.g.: Google search for ways to extract the texts that you need from a text file, but you must only meddle with the dump file in an air-gap machine.
newbie
Activity: 24
Merit: 1
Can someone confirm how to import the whole wallet into Electrum instead of all the private keys one by one?

dumprivkey works with only one address at a time
dumpwallet should dump whole wallet. Then do I just copy paste all the private keys into Electrum to import all at once?

Which method is recommended?
newbie
Activity: 24
Merit: 1
Yes, but the data will be downloaded to the default directory, which is

~/Library/Application Support/Bitcoin/

You need to modify it to the external hard drive data path.



Thanks for the details. My question regarding this was more about "if I just need to dumpwallet from console in Bitcoin Core, then do I really need Bitcoin core to start syncing?"

I think dumpwallet command should work even if the Bitcoin core client is not entirely synced up

One more question I have which I would really appreciate if you can clarify. Most articles online talk about using dumpprivkey command for a specific address and importing that into Electrum

I instead want to dump the entire wallet to a file and then import the whole wallet into Electrum. Is that possible to do for all at once?

legendary
Activity: 1596
Merit: 1288

Can you share the official links to these wallets or any other recommended ones? I want to make sure that I'm accessing only the official links

Electrum wallet is the best option. You can see this link to learn how to download the wallet and verify the signature How to Safely Download and Verify Electrum [Guide

Can you elaborate on the verify signature part? How do I do this?
Signature verification is a step to ensure that you downloaded programs from the official link. The developer signs the program code using a digital signature, and if a single line of code is changed, the signature verification step will fail.

Also, wouldn't Bitcoin Core client start syncing the blockchain as soon as I start it?
Yes, but the data will be downloaded to the default directory, which is

~/Library/Application Support/Bitcoin/

You need to modify it to the external hard drive data path.

newbie
Activity: 24
Merit: 1
If your purpose is Restoring wallet.dat, you do not need to run the Bitcoin core client to obtain your coins. You can extract the private key and import it in Electrum or any SPV wallet. These wallets do not require you to download more than 500 GB.

To do this, make several backup copies of wallet.dat.
Download bitcoincore Verify signature Open wallet.dat Enter password.
Create a file and save the path.
Open console in bitcoincore and type dumpwallet

Hello,

thanks for the reply. Could you please provide the commands in sequence?

Also, wouldn't Bitcoin Core client start syncing the blockchain as soon as I start it?

Kindly share the steps

it would be great if you could also share the steps to import the whole wallet into Electrum instead of just one private key. I'm reading online that it is better to sweep rather than import into Electrum. Also, my wallet is a bit old so I'm assuming some of the address types might be legacy. I wonder if I need to take some extra steps for such type of addresses
newbie
Activity: 24
Merit: 1
Thanks for the response. This seems like a good option. I will do my research to make sure I understand it properly before I do this though

Quote
You can extract the private key and import it in Electrum or any SPV wallet.

Can you share the official links to these wallets or any other recommended ones? I want to make sure that I'm accessing only the official links

Quote
Download bitcoincore Verify signature Open wallet.dat Enter password.

Can you elaborate on the verify signature part? How do I do this?
legendary
Activity: 1596
Merit: 1288
If your purpose is Restoring wallet.dat, you do not need to run the Bitcoin core client to obtain your coins. You can extract the private key and import it in Electrum or any SPV wallet. These wallets do not require you to download more than 500 GB.

To do this, make several backup copies of wallet.dat.
Download bitcoincore Verify signature Open wallet.dat Enter password.
Create a file and save the path.
Open console in bitcoincore and type dumpwallet

4. I want to make sure that an external hard disk is used as a data directory (where all the synced up blockchain data is stored). Should I specify this external hard disk name before or after installation of the client?

Change Bitcoin Core's default directory to the external hard drive data directory and you need to do this during installation, otherwise the data will be loaded into the default directory.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
Hey All,

I have my wallet.dat saved from an older version of Bitcoin core client on Windows. I want to restore this wallet.dat to a newer and latest version of Bitcoin core client on Macbook.

What measures should I take to prevent any compatibility issues?

Bitcoin Core have ability to open wallet.dat file created by older version. IIRC wallet.dat file which created by Bitcoin Qt (previous name of Bitcoin Core) version 0.8 or newer can be opened by newest version (26.0). But just in case, make backup of your wallet.dat file.

Below are the steps I have in mind. Kindly confirm the best way to do it

1. Download latest version of Bitcoin core client from here: https://bitcoin.org/en/download
2. Choose macOS dmg depending on the type of processor. Verify the MD5 or SHA256 hashes of the downloaded files to ensure file integrity. Maybe verify digital signatures as well
3. Install Bitcoin Core client on macOS. Any specific configuration options I need to enable at time of installation?
4. I want to make sure that an external hard disk is used as a data directory (where all the synced up blockchain data is stored). Should I specify this external hard disk name before or after installation of the client?
5. Once all the options are set, I open the client and let it sync with the network to download the latest blockchain, synced up to the latest block
6. I'm assuming a wallet.dat file is not created by default with the latest Bitcoin Core client. Do I need to do something to create a default one?
7. Once it is all synced up, I will close the client app and then place my wallet.dat in the data directory and re-open the client. That should allow me to access my wallet?

I don't own macOS, but
1. Are you willing to download and verify 550GB+ of blockchain data?
2. You better copy wallet.dat before sync, so Bitcoin Core automatically detect and show relevant TX on your wallet.dat file.
2. Be careful when using external storage. Sudden disconnect or unstable power may lead to data loss.
newbie
Activity: 24
Merit: 1
Hey All,

I have my wallet.dat saved from an older version of Bitcoin core client on Windows. I want to restore this wallet.dat to a newer and latest version of Bitcoin core client on Macbook.

What measures should I take to prevent any compatibility issues?

As far as I understand, wallet.dat does not depend on the version of Bitcoin core client and neither does it depend on the platform OS. Back then, wallet.dat did not have any seed phrase option. It was all based on a private key. I'm not sure if that's how Bitcoin core client handles the wallet nowadays

Below are the steps I have in mind. Kindly confirm the best way to do it

1. Download latest version of Bitcoin core client from here: https://bitcoin.org/en/download
2. Choose macOS dmg depending on the type of processor. Verify the MD5 or SHA256 hashes of the downloaded files to ensure file integrity. Maybe verify digital signatures as well
3. Install Bitcoin Core client on macOS. Any specific configuration options I need to enable at time of installation?
4. I want to make sure that an external hard disk is used as a data directory (where all the synced up blockchain data is stored). Should I specify this external hard disk name before or after installation of the client?
5. Once all the options are set, I open the client and let it sync with the network to download the latest blockchain, synced up to the latest block
6. I'm assuming a wallet.dat file is not created by default with the latest Bitcoin Core client. Do I need to do something to create a default one?
7. Once it is all synced up, I will close the client app and then place my wallet.dat in the data directory and re-open the client. That should allow me to access my wallet?
Jump to: