How do I extract my private keys from a protobuf wallet? Recent changes to Andreas Schildbach's Bitcoin client for Android have removed the option to export private keys. This has been replaced by an option to back up the entire wallet. Unfortunately, the wallet data of the Schildbach client is stored in an arcane format called protobuf (short presumably for Protocol Buffers). The Schildbach client can restore a protobuf wallet from its AES-encoded backup file. But the protobuf wallet cannot be imported into a different Bitcoin client such as the Bitcoin Core (QT) client.

For emphasis, I'm aware of the command line method of decoding the back-ups created by Schildbach's client, which in the past allowed the private keys to be saved in AES encrypted format to /sdcard/Download. The following command worked in the past to produce a human readable copy of my Bitcoin private keys:

openssl enc -d -aes-256-cbc -a -in encrypted-wallet-keys -out decrypted-wallet-keys


This no longer works. The following command instead produces a non-AES-encrypted protobuf wallet.

openssl enc -d -aes-256-cbc -a -in bitcoin-wallet-backup-2014-07-19 -out bitcoin-wallet-backup-2014-07-19-decrypted


The -out file is not an ASCII copy of my private keys but a copy of the protobuf wallet used internally by the Schildbach Bitcoin client (found at /data/data/de.schildbach.wallet/files/wallet-protobuf).
Since "when you're a developer it's easy" is probably not sufficient for most people, here is the full step-by-step from a Android Bitcoin Wallet to importing the private keys in Electrum which (finally...) worked for me. This solution uses bitcoinj. The approach using the .proto definition file and opening the wallet in Python was also tested, but seems more error-prone.

Requirements:


Android Bitcoin Wallet in a new version (to my knowledge, some older versions do not allow a backup).
Bash shell: tested with the Windows Bash, but should work on native Linux or OS X. Basic knowledge (cd etc.) helps.
On my system, maven and openjfx were required. Install them with sudo apt-get install maven, sudo apt-get install openjfx
Electrum (current: 2.9.2)


Step by step:


Backup: save the encrypted wallet (Safety -> Back up wallet) and move the backup file to your computer (e.g. via file transfer, Dropbox, e-mail...).
Decrypt: open the bash, move to your data directory and use openssl enc -d -aes-256-cbc -a -in bitcoin-wallet-backup &gt; bitcoin_decrypted as stated above, which will ask for the encryption password.
Install bitcoinj:


git clone https://github.com/bitcoinj/bitcoinj.git
cd bitcoinj
git fetch --all
git checkout v0.14.4
mvn install (fails at GroupTest in Windows bash, but works anyway)
cd tools
./wallet-tool

load the decrypted wallet and dump the private keys:


./wallet-tool dump --wallet=/mnt/d/path/to/wallet/bitcoin_decrypted --dump-privkeys &gt; /mnt/d/path/to/wallet/bitcoin_decrypted_dump.

Please note that this saves the unencrypted private keys in the file "bitcoin_decrypted_dump". Move this file to a save location (e.g. TrueCrypt/VeraCrypt container) or delete it after use.


Create a new wallet with the private keys in Electrum: File - New/Restore - filename - 'Standard wallet' - 'Use public or private keys', then list the 'priv WIF' keys from the dump file.


On handling the BTC/BCH question with Electrum and Electron Cash, please read the notes on the Electrum webpage.

If there are any questions, feel free to ask. Good luck!

Sources:


This page
https://github.com/bitcoin-wallet/bitcoin-wallet/blob/master/wallet/README.recover.md