## Is there a known way to export my wallet private key from the "Bitcoin Android" app (com.bitcoinandroid)?

9

2

A while back, I installed the Bitcoin Android app and moved 5 BTC on it. Fast forward to now, new phone, new ROM, and the app seems completely unwilling to update its blockchain, meaning I have no way to move my BTCs elsewhere.

Looking at the source, it's built on an early version of BitcoinJ, where the wallet file is essentially a serialized Wallet class.

A look at the wallet file itself isn't too friendly, although I'm sure the private key is somewhere in there in a relatively straightforward form.

So, that leaves me with the following possibilities:

• write a little Java app that links against the same version of BitcoinJ, load the Wallet file, grab the private key and print it.

• write a really dumb script that extracts every 32 bytes sequence from the wallet file, treat it as a private key, map it to a public key, check blockexplorer.com for any activity associated with it. Or just import every one of those sequences into a bitcoin client and let it suffer.

Before I embark on my Quest For Five Bitcoins, is there already something out there that can parse BitcoinJ wallet files and export keys from them?

(1) updating the blockchain is not a prerequisite for being able to send away the coins already there, (2) it's slightly unclear what you did: you backupped that application and its data, and re-installed it in the new phone? – o0'. – 2012-03-21T10:08:02.177

Many clients will not send transactions unless the client knows it has the requisite amount of coins; I suspect that is the case here. – BinaryMage – 2012-03-21T17:54:44.100

@Lohoris I didn't realize that. Both coin sending and blockchain updating are failing, and I drew a causation link where none existed, both likely failing instead due to a third factor. – Metal – 2012-03-23T21:39:52.993

Note that the link to this app (in the question above) is broken. If someone could fix it, that would be great. – Highly Irregular – 2013-02-12T01:07:44.823

2

I wrote up a detailed answer to this some ago. Essentially, you will need to root your phone and extract the wallet file with apd.

After you've got that you can decode it by looking within the serialized wallet with a Java debugger attached looking for an ECKey reference. Then, once you have the private key you can simply hand it over to MtGox who will do the decode for you and then you can transfer the bitcoins wherever you like.

Also, the BitCoinJ project contains several useful example tools in the source tree. Perhaps using one of those will help you with the deserialization.

2WARNING: rooting the phone without using exploits wipes its memory. So, unless he's running an already rooted phone, or an exploitable android version, he can't do that. – o0'. – 2012-03-21T10:05:23.180

@Lohoris Quite so. However, the OP does seem to indicate that the phone is an older ROM, possibly running 2.1, 2.2 which are exploitable. The linked article does provide a tested rooting approach that did not erase the internal memory. – Gary Rowe – 2012-03-21T10:37:46.803

2Thanks, this is probably the closest we are to a ready-made recovery solution. (my phones are rooted, so getting/backing up the wallet is not an issue.) – Metal – 2012-03-23T21:17:09.293

1DumpWallet did the trick. I just had to remove "00" from my priv: key field to get Mt.Gox to like my private key. Thanks again! – Metal – 2012-03-24T00:31:10.890

@Metal No worries - glad to have helped – Gary Rowe – 2012-03-24T18:29:14.317

Here's a tool that dumps the protobuf format without resorting to a java debugger: https://github.com/lloeki/bitcoinj-wallet-dump

– Lloeki – 2016-04-05T14:43:52.623

4

[Obsolete answer, see below]

As an update: current versions of the Bitcoin app have a "Back up Keys" feature. This writes a backup of all the keys in the wallet to a file named bitcoin-wallet-keys-YYYY-MM-DD (using the current date) in the phone's storage, which you can then copy or transfer wherever you want. The file is encrypted with a password you supply; it can be decrypted manually using OpenSSL, by running

openssl enc -d -aes-256-cbc -a -in bitcoin-wallet-keys-YYYY-MM-DD

After decryption, the file is just a list of private keys, one per line, in the standard base 58 compressed format (starting with K). You can import those keys into some other wallet. In bitcoin-qt, you'd use the importprivkey console command.

Further Update: As of Bitcoin Wallet 3.53, the "Back Up Keys" feature described above apparently no longer exists.

1This worked great for me with some oldish Litecoin and Dogecoin wallets backed up from Android. The Bitcoin backup created around the same time does decrypt (output starts with a 0x0A 0x16 header followed by a plaintext org.bitcoin.production) but the remainder is binary. – Lloeki – 2016-04-05T09:56:49.047

Also, in Bitcoin Wallet 4.49, backup is done via Safety menu entry. – Lloeki – 2016-04-05T09:57:32.347

what openssl outputs now is in protobuff format. See https://bitcoin.stackexchange.com/questions/29518/problems-decrypting-my-bitcoin-wallet-on-android

– Ovidiu Buligan – 2017-08-11T15:32:57.137

4

I would try option 1 first, if you can find the right version of the library. I'd be willing to try making a general purpose tool to do it, but don't have an Android phone. Is there any way you can make a new, empty wallet and put a copy online somewhere along with a corresponding bitcoin address or two?

If you're attempting option 2, you probably know at least one of the addresses in the wallet, and so wouldn't need to hit blockexplorer for every guess. You would expect the private keys to be evenly spread through the wallet, so once you've found a few you can make smarter guesses about where the rest are.

Yes.. option 1 is the least crazy of the 2. At this point, I've probably spent more time hoping something already exists than I would have spent doing it myself, so I guess I'll just stop being lazy. :) – Metal – 2012-03-23T22:00:28.800

0

This script seems to do the work

https://github.com/jleni/wallet-decrypt

You just need to create a backup and it will give you back a mnemonic that you can use in electrum or electrum cash.