api – How can I specify the address from a private key?

From the steps in the wiki, take this example private key:


When I import this to Electrum, I find these values:



Public Key:


How can I determine the direction from the key (without using Electrum)?

I understand that the source path is a private key -> public key -> address, so I’ve found a way to generate the public key in Java using BitcoinJ:

BigInteger privkey = new BigInteger("0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D", 16);
byte[] bytes = org.bitcoinj.core.ECKey.publicKeyFromPrivate(privkey, false);
String publickey = new BigInteger(1, bytes).toString(16);
while(publickey.length() < 130){
    publickey = "0" + publickey;

It gives the correct public key as shown above, so I need to find a way to get the address.

I don't know much about different address formats, but my goal is to use the address to check the balance using some public API like blockchain.com. I'm guessing this is the P2PKH-like reference.

I tried this:

NetworkParameters params = MainNetParams.get();
ECKey key = ECKey.fromPrivate(privkey);
String address = LegacyAddress.fromKey(params, key).toString();

Which gives me this address:


But the direction is different.