2

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?

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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