Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Kratomiseur on November 17, 2021, 12:48:24 PM



Title: Not able to export my public keys with pywallet
Post by: Kratomiseur on November 17, 2021, 12:48:24 PM
Hi Guys,

so I found this old wallet from 2012. Downloaded Bitcoin Core and waited patiently for the blockchain to
sync. Unfortunately Bitcoin Core was running in pruning mode so now it doesnt let me open my wallet.dat, instead
it creates a new one. Since my internet connection is terrible and I dont have enough space on my
harddrive, I wanted to try out pywallet to check, if there is any balances on the wallet.

I installed python and put the wallet.dat and the pywallet.py files in the same folder (C:\Python27\).
Problem is, when I navigate to the folder in cmd and then use the command "python pywallet.py --dumpwallet --datadir=. > wallet.txt"
it creates a .txt that only includes the pywallet options instead of my public keys.

What am I doing wrong? Also, I'm a complete python noob.

Many thanks in advance!  :)


Title: Re: Not able to export my public keys with pywallet
Post by: PawGo on November 17, 2021, 01:13:30 PM
Did not you forget to specify which file should be opened?  ;)
Code:
--datadir=DATADIR     wallet directory (defaults to bitcoin default)
--wallet=WALLETFILE   wallet filename (defaults to wallet.dat)

Something like:
Code:
python pywallet.py --dumpwallet  --datadir=DATADIR --wallet=WALLETFILE 
And do not forget about
Code:
--passphrase=PASSPHRASE
if you have one


Title: Re: Not able to export my public keys with pywallet
Post by: Kratomiseur on November 17, 2021, 01:21:45 PM
Hi and thank you so much for your fast reply! That was it, I actually forgot to define which file should be opened  ;D ::)
So now it seems to have worked as it shows me a bunch of adresses, must be about 50 or more including privates.
So  these are all my adresses? Meaning, if it shows up a balance on one of them, its one of my adresses? Sorry, have
 no idea  ??? ::)


Title: Re: Not able to export my public keys with pywallet
Post by: PawGo on November 17, 2021, 02:41:36 PM
Yes.

The best would be to export private keys and import into other client (I would suggest Electrum), to have fully functional wallet.
You may also import only addresses (no priv keys), to create read-only wallet - that way you will see balance, but you will not be able to spend.



Title: Re: Not able to export my public keys with pywallet
Post by: HCP on November 19, 2021, 10:23:41 PM
So now it seems to have worked as it shows me a bunch of adresses, must be about 50 or more including privates.
So  these are all my adresses? Meaning, if it shows up a balance on one of them, its one of my adresses?
The older (non-HD) Bitcoin Core wallet.dat's would maintain a keypool of around 100 private keys/addresses. Nowadays, the default keypool size is 1000... so it could be worse! :P ;)

And yes, they are all addresses that are generated from keys in your wallet.dat file.

As PawGo suggested, the best method to ensure you don't miss anything... is to simply export all] the private keys from your wallet.dat and then import them into another wallet. That way the wallet will be able to find all your coins for you and you won't accidentally miss one.

Note that you will need to get the private keys from your wallet.dat (the "sec" field in the pywallet output is the WIF format private key, "hexsec" and "secret" are hex format)... just importing addresses will mean that you can see the coins, but you can't spend them.