Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Atrax on November 27, 2017, 09:48:09 PM



Title: Getting Private Keys out of mobile Bitcoin Wallet
Post by: Atrax on November 27, 2017, 09:48:09 PM
Hi all,

I am running the Bitcoin Wallet (github.com/bitcoin-wallet/bitcoin-wallet) vrsion 5.40 on an Android mobile. I assume that it is made on the base of core (it sas that it was programmed by the "Bitcoin Wallet developers - but who am I to know...).

However, I try to get hold of my private keys of this wallet. Only question: How?

I can get an encrypted wallet - but this is not accepted by Bitcoin Core on my desktop. I can get an Extended Public Key, but no idea how I can get my private keys with it. If anybody could kick me a bit in the right direction as where to look here, I'd appreciate...

Thanks


Title: Re: Getting Private Keys out of mobile Bitcoin Wallet
Post by: TryNinja on November 27, 2017, 09:53:43 PM
I'm not sure if this would work but you could try using this tool[1] to export your seed and derivation path. Then, you would be able to import them in Electrum/Electron Cash.

Please share if this works.

[1] https://github.com/jleni/wallet-decrypt


Title: Re: Getting Private Keys out of mobile Bitcoin Wallet
Post by: achow101 on November 29, 2017, 06:09:17 AM
I assume that it is made on the base of core (it sas that it was programmed by the "Bitcoin Wallet developers - but who am I to know...).
That assumption is wrong. Core does not have an Android app and never has had one. Your wallet is written by different developers and uses different technology. The wallet file is completely incompatible with Bitcoin Core.

However, I try to get hold of my private keys of this wallet. Only question: How?
Bitcoin Wallet for Android uses Bitcoinj. If you are comfortable using the command line and installing JDK and maven packages, then you can use the bitcoinj wallet-tool to extract the data from your wallet file. The wallet-tool is part of the Bitcoinj repository here: https://github.com/bitcoinj/bitcoinj


Title: Re: Getting Private Keys out of mobile Bitcoin Wallet
Post by: HCP on November 29, 2017, 09:37:43 AM
Or... you can use decrypt_bitcoinj_seed (https://github.com/gurnec/decrypt_bitcoinj_seed)...

It will extract the 12 word seed from the Bitcoin Wallet backup file. You can then import that seed mnemonic into any BIP39 compatible wallet.


Title: Re: Getting Private Keys out of mobile Bitcoin Wallet
Post by: Atrax on December 01, 2017, 09:02:19 PM
I'm not sure if this would work but you could try using this tool[1] to export your seed and derivation path. Then, you would be able to import them in Electrum/Electron Cash.

Please share if this works.

[1] https://github.com/jleni/wallet-decrypt

Thanks for the hint - worked like a charme.


Title: Re: Getting Private Keys out of mobile Bitcoin Wallet
Post by: Atrax on December 01, 2017, 09:16:45 PM
I assume that it is made on the base of core (it sas that it was programmed by the "Bitcoin Wallet developers - but who am I to know...).
That assumption is wrong. Core does not have an Android app and never has had one. Your wallet is written by different developers and uses different technology. The wallet file is completely incompatible with Bitcoin Core.

However, I try to get hold of my private keys of this wallet. Only question: How?
Bitcoin Wallet for Android uses Bitcoinj. If you are comfortable using the command line and installing JDK and maven packages, then you can use the bitcoinj wallet-tool to extract the data from your wallet file. The wallet-tool is part of the Bitcoinj repository here: https://github.com/bitcoinj/bitcoinj

Thanks.

Tried bitcoinj, but failed miserably :(
After executing this code:

./wallet-tool dump --dump-privkeys --wallet=[path to my wallet] > wallet.txt

I got an empty file wallet.txt and the following error:

Code:
Failed to load wallet '/path/to/my/Wallet: Could not parse input stream to protobuf
org.bitcoinj.wallet.UnreadableWalletException: Could not parse input stream to protobuf
at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:440)
at org.bitcoinj.tools.WalletTool.main(WalletTool.java:333)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:99)
at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:515)
at com.google.protobuf.GeneratedMessage.parseUnknownField(GeneratedMessage.java:205)
at org.bitcoinj.wallet.Protos$Wallet.<init>(Protos.java:14696)
at org.bitcoinj.wallet.Protos$Wallet.<init>(Protos.java:14653)
at org.bitcoinj.wallet.Protos$Wallet$1.parsePartialFrom(Protos.java:14859)
at org.bitcoinj.wallet.Protos$Wallet$1.parsePartialFrom(Protos.java:14854)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:89)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:95)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at org.bitcoinj.wallet.Protos$Wallet.parseFrom(Protos.java:15710)
at org.bitcoinj.wallet.WalletProtobufSerializer.parseToProto(WalletProtobufSerializer.java:626)
at org.bitcoinj.wallet.WalletProtobufSerializer.readWallet(WalletProtobufSerializer.java:433)
... 1 more

Although I was able to extract the seed with wallet-decrypt, I'm wondering what went wrong here.