Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: frankescoin on August 14, 2023, 03:15:44 PM



Title: Export private keys of wallet.dat using BTCrecover
Post by: frankescoin on August 14, 2023, 03:15:44 PM
Is there any command to be able to export privatekeys from a wallet.dat using BTCrecover?

I am not able to do it using Bitcoin-qt or pywallet with an old wallet.dat from 2018.

Thank you.


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: BitMaxz on August 14, 2023, 03:35:27 PM
Btcrecover is supposed to be used for recovering missing characters or seed phrases or brute-forcing passphrases. Did you forget the password of your wallet.dat?

If not, then maybe you didn't include the command for the passphrase before you use dumpprivkey from the bitcoin-qt console or PyWallet.

If you forgot the password there is documentation for BTCrecoved from this link below that you can follow you can also check the sample commands under that link.

- https://btcrecover.readthedocs.io/en/latest/


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: frankescoin on August 14, 2023, 03:40:54 PM
I used pywallet but I get this:

python3 pywallet.py --dumpwallet  --wallet=/home/pywallet/wallet.dat --passphrase=mypassword


22, 'Invalid argument -- BDB0210 /home/pywallet/wallet.dat: metadata page checksum error'


Thank you


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: BitMaxz on August 14, 2023, 03:48:51 PM
I have the password. Which command I have write to use dumpprivkey with BTCrecover?

If you have then you should be able to export or dump the keys on the Bitcoin-qt console or pywallet.

What issue or errors did you get when trying to dump the keys from Qt and Pywallet?

Here are the sample commands on the Bitcoin-qt

Code:
walletpassphrase mypassword 600

And then dump the private key

Code:
dumpprivkey theaddressthatiwanttodumpprivkey


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: DaveF on August 14, 2023, 03:51:33 PM
Your wallet.dat is corrupted:
https://github.com/akx/walletool/issues/9

What do you get when you try to open the wallet in core itself?
Did you try salvage?
https://bitcointalk.org/index.php?topic=5330381.0

Obligatory, don't use that file make a copy and use those.

-Dave


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: BitMaxz on August 14, 2023, 04:09:34 PM
22, 'Invalid argument -- BDB0210 /home/pywallet/wallet.dat: metadata page checksum error'


Based on this error like the above said the wallet.dat file might be corrupted you have a similar case here "Another recovery attempt (https://bitcointalk.org/index.php?topic=5371701.0)".

What I think is to use -salvagewallet but it was moved to bitcoin-wallet.exe there is a guide here on how to perform salvage wallet using bitcoin-wallet tool (https://bitcointalk.org/index.php?topic=5452748.msg62251246#msg62251246).

But before you salvage this wallet make sure you make a backup copy of your wallet.dat file first.


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: nc50lc on August 15, 2023, 11:41:19 AM
Is there any command to be able to export privatekeys from a wallet.dat using BTCrecover?
I used pywallet but I get this:
22, 'Invalid argument -- BDB0210 /home/pywallet/wallet.dat: metadata page checksum error'
There is --dump-privkeys that should be used together with --correct-wallet-password and --wallet args.
But if pywallet and Bitcoin Core didn't work in the first place which should've worked, I doubt using BTCRecover will do any difference.
And lastly, AFAIK, it only works on Blockchain(.com) "wallet.aes.json" file.


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: frankescoin on August 15, 2023, 04:34:01 PM
I was asking to use BTCrecover because It was able to identify the correct password that I already know that is correct. How it was able to do that if the file is corrupted? So I think that BTCrecover may be is able to extract private keys. But, as you said, It cant do that with bitcoin core wallet.dat. I dont know why not.

I have used  --dump-privkeys with --correct-wallet-password and --wallet args, but BTCrecover said "This wallet type does not currently support dumping the decrypted private keys"  :'( :'( :'(

Thank you



Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: BitMaxz on August 15, 2023, 04:59:20 PM
I was asking to use BTCrecover because It was able to identify the correct password that I already know that is correct. How it was able to do that if the file is corrupted?

Have you read our previous posts for a corrupted wallet.dat file above?
Please test it first and report back here.

If it doesn't work, is it possible that the "wallet.dat" file you're attempting to recover is an altcoin backup wallet rather than a Bitcoin backup wallet?


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: frankescoin on August 15, 2023, 05:29:28 PM
Yes I have read them, but I have already tried everything with pywallet and bitcoin core console and nothing works.

It is a bitcoin core wallet. This is the only program that I use.

With bitcoin core)

loadwallet wallet.dat

Wallet file verification failed. Failed to load database path '/home/.bitcoin/wallet.dat'. Data is not in recognized format. (code -18)

With pywallet)

python3 pywallet.py --dumpwallet  --wallet=/home/pywallet/wallet.dat --passphrase=mypassword

22, 'Invalid argument -- BDB0210 /home/pywallet/wallet.dat: metadata page checksum error'

So It clear that there is something wrong with the file, but no totally wrong because BTCrecover is able to identify the correct password.

Thank you




Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: frankescoin on August 15, 2023, 10:04:22 PM
Finally I have been able to recover a copy of the wallet from a very old usb. It works!!!!

Always always always make copies of your wallet.dat!!!!

I was pretty scared because I thought that I have lost my BTC.

thank for your help


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: Cricktor on August 27, 2023, 07:11:40 PM
I wonder why you couldn't dump or export the private keys which should be done only if you understand the risks of doing so and have a suitable and secure offline working environment.

AFAIR Bitcoin Core 0.16.0 from beginning of 2018 started to create HD wallets by default. It did read older wallet.dat files, of course. Is your wallet from 2018 a HD wallet? If yes, then private keys and addresses are derived deterministically and frequent backups can't cause an issue if a wallet backup file has to be restaured (under certain conditions restaured wallet file backups of older legacy wallet.dat files, those that contained only random private keys which weren't derived by any determinism, could lead to a loss of coins when the key pool size of backup and replaced wallet differed).

Do you have an idea what might have corrupted your wallet.dat?


Title: Re: Export private keys of wallet.dat using BTCrecover
Post by: nc50lc on August 28, 2023, 06:58:01 AM
(under certain conditions restaured wallet file backups of older legacy wallet.dat files, those that contained only random private keys which weren't derived by any determinism, could lead to a loss of coins when the key pool size of backup and replaced wallet differed).
The good thing about pre-HD wallets after version 0.15 (Q4 2017) which OP's wallet fall into category, is the keypool size is set to a generous amount of 1000keys.
So unless OP exhausted all of those reserved after he made the backup, his coins should still be safe.