0

I have a private key bigInt of type bigInteger and I would like to generate the address corresponding to this private key. I implemented the following function

public String get_address () {
Address address = new Address(NetworkParameters.prodNet(), Utils.sha256hash160(new ECKey(bigInt).getPubKey()));
return address.toString();
}

When compiling, I have

Exception in thread "main" java.lang.NoClassDefFoundError: org/spongycastle/util/encoders/Hex
at com.google.bitcoin.core.NetworkParameters.<clinit>(NetworkParameters.java:49)
at bitcoin.get_address(bitcoin.java:40)
at main.main(main.java:11)
Caused by: java.lang.ClassNotFoundException: org.spongycastle.util.encoders.Hex
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 3 more

I guess that I need to import the library org.spongycastle but I don't know how to do that in Eclipse.

Who can help me with this?

Thanks a lot.

1

You need to resolve the dependency org.spongycastle.util.encoders.Hex, more than likely you need to add this dependency to your pom.xml file if you are using Maven. If you are not using maven, you will have download the JAR file from somewhere and I add it to your build path in Eclipse.

From a quick Google search this appears this is the dependency that you want.

1
  • Thanks! The link is what I was looking for. In order to get it working, I downloaded the following dependencies: sc-light-jdk15on-1.47.0.3.jar, slf4j-simple-1.7.7.jar, slf4j-api-1.7.7.jar, guava-18.0.jar. – Ashley Oct 31 '14 at 17:42

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.