Posts Tagged ‘Pywallet

From time to time people tend to remember that they have minded BTC, LTC, DOGE or another of the earlier cryptocoins back in the day when they suddenly find an old wallet.dat file and then the problem with recovering the private keys and the coins in the wallet arises, we often get questions on how to do that. The easiest way would of course be to just copy the wallet.dat file in a new installation of Bitcoin Core or the respective local wallet and wait for the blockchain to sync in order to have access to any coins stored in the wallet. Int he case of Bitcoin however this is a slow process requiring you to download 150 GB of data (the whole blockchain), so alternative ways are being looked into and there are some that can be easier. One such way is to use the PyWallet Bitcoin wallet importer/exporter Python script that has been available for ages and that works great for giving you all your public and private keys from a wallet.dat file.

PyWallet however is a Python script that does require you to have Python installed and it requires an older version 2.7, so it will not work with the latest 3.x releases as there are changes that will prevent you from running the script. We are going to go through a short guide on how you can export your public/private keys from a wallet.dat under Windows here, the procedure for Linux is very similar as well. So you need to download and install Python 2.7 first, this is a Windows package of Python, there are no other dependencies to run the script under Windows. Then you need to install it in an easy folder like C:\Python27 for example, copy the pywallet.py script and the wallet.dat files in the same folder and then run the following command:

python pywallet.py --dumpwallet --datadir=.

If you have used the wallet for mining you may have more than just a few addresses inside, so you can use the below code to save the output into a wallet.txt file for easy use instead of just outputting it in the console window:

python pywallet.py --dumpwallet --datadir=. > wallet.txt

Just open up the text file and you will see a list of exported public keys (addresses) and private keys that were inside the wallet.dat wallet file. If you had the wallet encrypted you will also need to provide the password you used fr the encryption in order fro the data to be decrypted first. If you do not remember that password you have used to encrypt the wallet.dat file, well that would be a serious problem as recovering any coins inside the wallet has just become much harder that you though it could be.

You can use any block explorer for the respective coin to check if it has any balance inside by pasting your address (public key), so that you can be sure if there are coins or not in an address. If there are you can then just import the public/private key in a new wallet and then do whatever you want with the coins inside. Importing the key pair can vary depending on the wallet you choose to use, so check what is the procedure and make sure that you can import a wallet using the public and private key(s) you have just obtained using the PyWallet script.

There is also a more up to date fork of PyWallet available as well that offers some useful additional features, so you may also check it out if the original one does not do what you want it to, although the original one is perfectly fine for recovering the keys.

unconfirmed-bitcoin-transaction

With the recent spike in the price of Bitcoin the number of unconfirmed transactions has increased significantly yet again and the Bitcoin blocks are getting closer and closer to being full. This essentially slows down transactions on the network and in order to ensure that your transaction is being processed faster you need to increase the fee over the standard recommended one. While this may be just fine for larger BTC transfers with fewer inputs, if you want to make a small transaction of few Bitcoin cents or a large one with a lot of inputs the network fees can get quite high. If the fee is not large enough and the waiting list is big you can easily end up with your transaction not getting confirmed and included in a block for over a day and that usually causes a problem, especially if you are paying for something in BTC. The solution would be to just cancel any unconfirmed transaction that did not go through for over 24 hours and it is not that hard to do it actually, although the process itself may require some time.

bitcoin-qt-zapwallettxes

Cancelling stuck Bitcoin transaction sent from your local BTC wallet requires you to run the qt wallet client with a special option that would remove all pending transactions that are not included in the blockchain. You need to run bitcoin-qt.exe (or the respective qt executable file depending on the OS you are using) with the -zapwallettxes parameter, but before running it make sure you backup your wallet.dat file. This will take some time as it will initiate a blockchain rescan, so be prepared to wait until the process finishes and do not forget to remove the extra parameter the next time you run your wallet as it is not needed anymore. As a result you will be able to initiate a new transaction with the unspent coins and by increasing the network fee you pay you should be able to move them faster and have the transaction confirmed this time. You will be essentially double spending your Bitcoins, but the second transaction you initiate will cancel out the earlier one. You cannot successfully double spend Bitcoins unless you control more than half of the Bitcoin network, so no worries here. The only thing you will be able to do is free up your coins that were stuck in an unconfirmed transaction for a long time and then be able to initiate a new transaction to send them successfully this time.

Do note that although we are giving this example for Bitcoin, it should work on many other altcoins as well that are based on a more recent forked Bitcoin wallet code as the option we use here is not included in the earlier version of the Bitcoin client. There are some more complex alternatives for performing the same thing described here if your wallet does not support the zapwallettxes option, so you are not out of luck in such cases either. You can do the same thing with the Python-based tool called Pywallet as an alternative to using the qt wallet method described here.


top