<p>You can use method toAddress</p>
<pre><code>System.out.println(key.toAddress(ScriptType.P2PKH, network));
</code></pre>

CC BY-SA 4.0
2023-08-30T15:27:54.847Z
2023-08-30T15:27:54.847Z
kirka
<p>Is there some method that can be used to get the address, private and public key for any type of supported coin in a HD wallet? I can correctly generate these for Ethereum, which I verified on <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a></p>
<pre><code>String seedCode = &quot;elevator dinosaur switch you armor vote black syrup fork onion nurse illegal trim rocket combine&quot;;

// BitcoinJ
DeterministicSeed seed = new DeterministicSeed(seedCode, null, &quot;&quot;, 1409478661L);
DeterministicKeyChain chain = DeterministicKeyChain.builder().seed(seed).build();
List&lt;ChildNumber&gt; keyPath = HDPath.parsePath(&quot;M/44H/0H/0H/0/0&quot;);
DeterministicKey key = chain.getKeyByPath(keyPath, true);
BigInteger privKey = key.getPrivKey();

System.out.println(&quot;0x&quot; + privKey.toString(16));
System.out.println(&quot;0x&quot; + key.getPublicKeyAsHex());
System.out.println(&quot;0x&quot; + Keys.getAddress(Sign.publicKeyFromPrivate(privKey)));
</code></pre>
<p>I'm not sure how to do the same for bitcoin or any other coin. Is there some other way to get the public key, private key, and address? I am currently using the bitcoinj and web3j libraries.</p>

<bip32-hd-wallets><bitcoinj><java>
Generating HD Wallet Addresses in Java Using Bitcoinj
Bob Marshall
# Generating HD Wallet Addresses in Java Using Bitcoinj

(Asked by: username_0 on 2022-01-03)

Is there some method that can be used to get the address, private and public key for any type of supported coin in a HD wallet? I can correctly generate these for Ethereum, which I verified on https://iancoleman.io/bip39/
String seedCode = "elevator dinosaur switch you armor vote black syrup fork onion nurse illegal trim rocket combine";

// BitcoinJ
DeterministicSeed seed = new DeterministicSeed(seedCode, null, "", 1409478661L);
DeterministicKeyChain chain = DeterministicKeyChain.builder().seed(seed).build();
List keyPath = HDPath.parsePath("M/44H/0H/0H/0/0");
DeterministicKey key = chain.getKeyByPath(keyPath, true);
BigInteger privKey = key.getPrivKey();

System.out.println("0x" + privKey.toString(16));
System.out.println("0x" + key.getPublicKeyAsHex());
System.out.println("0x" + Keys.getAddress(Sign.publicKeyFromPrivate(privKey)));

I'm not sure how to do the same for bitcoin or any other coin. Is there some other way to get the public key, private key, and address? I am currently using the bitcoinj and web3j libraries.

**Tags:** bip32-hd-wallets, bitcoinj, java


---

## 1 answers

### Answer by username_1 on 2023-08-30. Score: 0

You can use method toAddress
System.out.println(key.toAddress(ScriptType.P2PKH, network));


---

