I'm trying to create a BitcoinJ-based app that watches an existing wallet (created in Electrum) and does things when transactions come through against that wallet.

As I understand it, I need to create a BitcoinJ wallet by feeding it my Electrum wallet's "Watching Key", and it appears that, to do this, I need to somehow load my Electrum wallet into BitcoinJ so that I can call getWatchingKey() on it.

The problem is that I cannot sort out how to import my Electrum wallet into BitcoinJ - I have BIP32-formatted public and private keystrings (from testnet, so they start with tpub and tpriv respectively), but I simply cannot sort out how to convert these strings into a Wallet object in BitcoinJ. Any help would be greatly appreciated.


Alternatively, I could import the Key by using the Seed...but I'm supposed to supply the Seed's creation time (in Unix form)...what is that information used for? I don't have it, so I've been working under the assumption that I cannot use the Seed.


As stated in https://bitcoinj.github.io/working-with-the-wallet:

"The “watching key” in this case is the public form of the BIP32 account zero key i.e. it’s the first key derived from the master."

I also thought it was the master public key, but it is the first (or 0th) derived key.

Hope this helps.


To answer your last question, the seed's creation time is used as a hint to BitcoinJ as to when it should start searching for transactions. If you have access to your first transaction on your Electrum wallet, use that approximate time.

  • Is there a way to get this Zero Key from Electrum? Your answer, while helpful, does not actually answer my question (not trying to be rude, I truly appreciate the help) – Cody S Oct 13 '17 at 0:51
  • Sorry. I don't know the answer to that one. – ecavero Oct 13 '17 at 1:11

I face up the same problem(still I can not reach my balance) when I was trying to have access to my wallet through a BitcoinJ application.

Despite the fact that my bitcoin address had created successfully from my private key, still I was not able to have access to my funds. I do not know why.

Here is my code, hope it will help you:

 //create my ECKey
        DumpedPrivateKey dumpPrivKey = null;
        try {
            dumpPrivKey = new DumpedPrivateKey(params, "your private key. You can reach it by calling the dumpprivkey RPC command in Bitcoin-Core console");
        } catch (AddressFormatException e1) {
            // TODO Auto-generated catch block

        ECKey myKey=dumpPrivKey.getKey();
        Address bitcoinAddress=myKey.toAddress(params);

       System.out.println("My bitcoin address is : " +bitcoinAddress); //the 
    Main network address 
    Coin coin =wallet.getBalance();
    System.out.println("My bitcoin balance is: " +coin); //the balance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.