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?


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());
  • I want private keys of all my generated addresses. Please help if you know. – Bandish Oct 3 '18 at 6:00
  • @BandishMehta please accept the answer if it satisfied your question, because otherwise it remains "unanswered" on the site :) – Zombie Oct 3 '18 at 9:01

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.