<p>for address prv key </p>

<pre><code>  void key(){
        ECKey key = new ECKey();
        Address pubAddress = new Address(NetworkParameters.prodNet(), key.getPubKeyHash());
        DumpedPrivateKey privKey = key.getPrivateKeyEncoded(NetworkParameters.prodNet());
        System.out.println("Public address: " + pubAddress.toBase58() + "; Private key: " + privKey.toBase58());
}
</code></pre>

<p>if you want master private key then do something like this</p>

<pre><code>        NetworkParameters params = NetworkParameters.prodNet();
        Wallet wallet= new Wallet(params);

        DeterministicKey watchingKey = wallet.getWatchingKey();

        // Get the standardised base58 encoded serialization
        System.out.println("Watching key data: " + watchingKey.serializePubB58(params));
        System.out.println("Watching key birthday: " + watchingKey.getCreationTimeSeconds());
</code></pre>

CC BY-SA 4.0
2018-10-03T06:00:46.073Z
I want private keys of all my generated addresses. Please help if you know.
Bandish
CC BY-SA 4.0
2018-10-03T09:01:21.663Z
@BandishMehta please accept the answer if it satisfied your question, because otherwise it remains "unanswered" on the site :)
Zombie
CC BY-SA 4.0
2018-09-13T21:16:38.760Z
2018-09-20T22:11:49.360Z
2018-09-20T22:11:49.360Z
Zombie
<p>I'm using bitcoinj for transferring bitcoin.</p>

<p>Now I want to export private key of my wallet.</p>

<p>So how can I get the private key from bitcoinj?</p>

<bitcoinj><android>
Get private-keys from wallet using bitcoinj
Bandish
# Get private-keys from wallet using bitcoinj

(Asked by: username_0 on 2018-09-06)

I'm using bitcoinj for transferring bitcoin.

Now I want to export private key of my wallet.

So how can I get the private key from bitcoinj?

**Tags:** bitcoinj, android


---

## 1 answers

### Answer by username_1 on 2018-09-13. Score: 0 | Accepted answer

for address prv key

```
  void key(){
        ECKey key = new ECKey();
        Address pubAddress = new Address(NetworkParameters.prodNet(), key.getPubKeyHash());
        DumpedPrivateKey privKey = key.getPrivateKeyEncoded(NetworkParameters.prodNet());
        System.out.println("Public address: " + pubAddress.toBase58() + "; Private key: " + privKey.toBase58());
}

```

if you want master private key then do something like this

```
        NetworkParameters params = NetworkParameters.prodNet();
        Wallet wallet= new Wallet(params);

        DeterministicKey watchingKey = wallet.getWatchingKey();

        // Get the standardised base58 encoded serialization
        System.out.println("Watching key data: " + watchingKey.serializePubB58(params));
        System.out.println("Watching key birthday: " + watchingKey.getCreationTimeSeconds());

```

> **Comments:**
> **username_0**: I want private keys of all my generated addresses. Please help if you know.  
> **username_1**: @BandishMehta please accept the answer if it satisfied your question, because otherwise it remains "unanswered" on the site :)  

---

