<p>BitcoinJ has its own wallet format, and official bitcoin client its own.</p>

CC BY-SA 3.0
2013-03-18T13:16:38.967Z
Ok, thank you for your answer. Is it the same for the block chain ? Could I use the block chain downloaded by bitcoin-qt in bitcoinj ?
Baptiste Pernet
CC BY-SA 3.0
2013-03-18T20:43:30.073Z
The blockchains are different too.
jim618
CC BY-SA 3.0
2013-03-18T13:04:33.580Z
2013-03-18T13:04:33.580Z
mrmx
<p>I try to open the bitcoin-qt wallet with bitcoinj, I write this code:</p>

<pre><code>private static final File WALLET_FILE = new File("C:\\Users\\Bapt\\AppData\\Roaming\\Bitcoin\\wallet.dat");

public static void main(String[] args) {
    NetworkParameters networkParameters = NetworkParameters.prodNet();

    Wallet wallet;
    try {
        wallet = Wallet.loadFromFile(WALLET_FILE);
    } catch (IOException e) {
        System.out.println("Couldn't open wallet: " + e);
        return;
    }

    System.out.println("Balance: " + wallet.getBalance());
}
</code></pre>

<p>But I have an error: </p>

<pre><code>Couldn't open wallet: com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
</code></pre>

<p>So I have two questions:</p>

<ul>
<li>Is is possible to do what I want ?</li>
<li>If yes, what do you think could happen here ?</li>
</ul>

<p>Thanks for your answer.</p>

<bitcoin-core><bitcoinj>
Open bitcoin-qt wallet with bitcoinj
Baptiste Pernet
# Open bitcoin-qt wallet with bitcoinj

(Asked by: username_0 on 2013-03-18)

I try to open the bitcoin-qt wallet with bitcoinj, I write this code:

```
private static final File WALLET_FILE = new File("C:\\Users\\Bapt\\AppData\\Roaming\\Bitcoin\\wallet.dat");

public static void main(String[] args) {
    NetworkParameters networkParameters = NetworkParameters.prodNet();

    Wallet wallet;
    try {
        wallet = Wallet.loadFromFile(WALLET_FILE);
    } catch (IOException e) {
        System.out.println("Couldn't open wallet: " + e);
        return;
    }

    System.out.println("Balance: " + wallet.getBalance());
}

```

But I have an error:

```
Couldn't open wallet: com.google.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).

```

So I have two questions:

* Is is possible to do what I want ?
* If yes, what do you think could happen here ?

Thanks for your answer.

**Tags:** bitcoin-core, bitcoinj


---

## 1 answers

### Answer by username_1 on 2013-03-18. Score: 2 | Accepted answer

BitcoinJ has its own wallet format, and official bitcoin client its own.

> **Comments:**
> **username_0**: Ok, thank you for your answer. Is it the same for the block chain ? Could I use the block chain downloaded by bitcoin-qt in bitcoinj ?  
> **username_2**: The blockchains are different too.  

---

