I exploit Java and bitcoinj. I’ve a personal key
String str="5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf";
I attempt to get compress and decompress 2 adresses on this format:
1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
I do step one, attempt get ECKey:
NetworkParameters params = MainNetParams.get();
ECKey key;
if (str.size() == 51 || str.size() == 52) {
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, str);
key = dumpedPrivateKey.getKey(); //ERROR
} else {
BigInteger privKey = Base58.decodeToBigInteger(str);
key = ECKey.fromPrivate(privKey);
}
.
.
.
and I get an exception:
Exception in thread "important" java.lang.IllegalArgumentException
at com.google.widespread.base.Preconditions.checkArgument(Preconditions.java:128)
at org.bitcoinj.core.ECKey.<init>(ECKey.java:195)
at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:243)
at org.bitcoinj.core.ECKey.fromPrivate(ECKey.java:259)
at org.bitcoinj.core.DumpedPrivateKey.getKey(DumpedPrivateKey.java:101)
at com.instance.demo2.controllers.AdressFromKey.important(AdressFromKey.java:35)
What am I doing flawed?