Manually recovering private keys from Blockchain.info HD wallet conversion disaster

If you’re reading this, you may be one of the few unlucky souls who inadvertently converted their legacy-style Blockchain.info wallet to the new HD-style Blockchain.info wallet. If you just so happened to have > 1000 addresses in your legacy-style wallet, the conversion process will render your entire wallet unusable due to some limits set in the BC.info internal API.

If it seems Blockchain.info support is unwilling to help you recover the keys to your legacy wallet, you’re not alone. I just helped someone recover quite a few coins that would have been seemingly lost otherwise. Read on to reclaim your coins…

Once logged into the bricked Blockchain.info wallet, the following steps can be taken from inside the javascript debug console in any browser (I used Firefox) to extract private keys for a given address to import elsewhere.

Step 1: dump all active addresses in the wallet:

console.log(Blockchain.MyWallet.wallet._addresses);

Run the command above in the debug console to return an object of all the addresses, including legacy, in the wallet, with the following structure:

Find the appropriate address and locate the value inside the _priv field (the private key). This is likely a base58 encoded representation of the address’s private key.

Step 2: confirm what format the private key is in using the following command:

Blockchain.Helpers.detectPrivateKeyFormat("_THE_PRIVATE_KEY_FROM_STEP_1");

This will output a value into the console, typically base58.

Step 3: run the following command to convert the private key into wallet import format:

var key = Blockchain.Helpers.privateKeyStringToKey("_THE_PRIVATE_KEY_FROM_STEP_1", "base58"); var uWIF = key.toWIF(); console.log(uWIF);

Note if you got a different value than base58 for step 2, replace base58 with the appropriate value. This will output the private key for the address in wallet import format.

You can then import this into Bitcoin Core using:

bitcoin-cli importprivkey {the output of step 3} “from blockchain.info” false
Note: if you have more than one private key to import, you will save a lot of time by attaching false onto the end of each importprivkey call, only setting the blockchain rescan flag to true after the last key has been imported.

You can also encode this private key into a QR code and import it into Mycelium for easy sweeping.

Hope this saves some headaches for some others out there!

 

3 thoughts on “Manually recovering private keys from Blockchain.info HD wallet conversion disaster

  1. > bitcoin-cli importprivkey {the output of step 3} 1

    Better would be:

    > bitcoin-cli importprivkey {the output of step 3} “from blockchain.info” false

    That speeds the import up a lot, because it skips rescanning the whole blockchain.

    Presumably you have a lot of privkeys to import. Put ‘false’ as the last parameter for all except the last one, and use ‘true’ for the last one. It will save you a lot of time.

    Note that the 2nd parameter (’1′ in your example) is the label to use for the imported address.

     /  Reply

  2. Doug Drake

    Hi – stumbled upon this link when looking for some technical advise re my Blockchain basic wallet which now defaults immediately to a Watch wallet when I put in the required PW and of course I can’t send any funds from there – I have contacted Blockchain.info support but the early exchanges don’t seem promising – any clues how to stop the defaulting ? – thanks – Doug

     /  Reply

Leave a Reply to Doug Drake Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *