Bitcoin Forum
December 08, 2016, 09:57:18 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: BitcoinJ Maven  (Read 2801 times)
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 10, 2012, 08:43:21 AM
 #1

Does anyone know how to set this up so it'll work? Followed the instructions in the wiki but it won't collect dependencies...

Code:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany</groupId>
  <artifactId>connectcoinm</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>connectcoinm</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

 <repositories>
   <repository>
     <id>bitcoinj-release</id>
     <releases/>
     <url>http://nexus.bitcoinj.org/content/repositories/releases</url>
   </repository>
   <repository>
     <id>bitcoinj-snapshot</id>
     <snapshots/>
     <url>http://nexus.bitcoinj.org/content/repositories/snapshots</url>
   </repository>
 </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  <!-- Depend on BitCoinJ -->
  <dependency>
    <groupId>com.google</groupId>
    <artifactId>bitcoinj</artifactId>
    <version>0.3</version>
    <scope>compile</scope>
  </dependency>
  </dependencies>
</project>

This is what I get:
Code:
Failed to execute goal on project connectcoinm: Could not resolve dependencies for project com.mycompany:connectcoinm:jar:1.0-SNAPSHOT: Failed to collect dependencies for [junit:junit:jar:3.8.1 (test), com.google:bitcoinj:jar:0.3 (compile)]: Failed to read artifact descriptor for com.google:bitcoinj:jar:0.3: Could not transfer artifact com.google:bitcoinj:pom:0.3 from/to bitcoinj-release (http://nexus.bitcoinj.org/content/repositories/releases): Failed to transfer file: http://nexus.bitcoinj.org/content/repositories/releases/com/google/bitcoinj/0.3/bitcoinj-0.3.pom. Return code is: 502, ReasonPhrase:Bad Gateway. -> [Help 1]
1481191038
Hero Member
*
Offline Offline

Posts: 1481191038

View Profile Personal Message (Offline)

Ignore
1481191038
Reply with quote  #2

1481191038
Report to moderator
1481191038
Hero Member
*
Offline Offline

Posts: 1481191038

View Profile Personal Message (Offline)

Ignore
1481191038
Reply with quote  #2

1481191038
Report to moderator
1481191038
Hero Member
*
Offline Offline

Posts: 1481191038

View Profile Personal Message (Offline)

Ignore
1481191038
Reply with quote  #2

1481191038
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 10, 2012, 08:53:11 AM
 #2

Tried putting the libraries together manually:

Code:
Exception in thread "main" java.lang.ExceptionInInitializerError
at myproject.Myproject.main(Myproject.java:33)
Caused by: java.lang.NullPointerException
at com.google.bitcoin.core.ECKey.<clinit>(ECKey.java:53)
... 1 more
Java Result: 1

Myproject.java:33
Code:
ECKey key = new ECKey();

Any help would be much appreciated.
apetersson
Hero Member
*****
Offline Offline

Activity: 666


mycelium.com


View Profile WWW
April 10, 2012, 09:29:51 AM
 #3

your error message means that
Code:
SECNamedCurves.getByName("secp256k1")
returned null.

Propably you have the wrong BouncyCastle lib installed. the version used in BitcoinJ is 1.46 (see pom.xml)
jim618
Legendary
*
Offline Offline

Activity: 1708



View Profile WWW
April 10, 2012, 09:51:16 AM
 #4

MultiBit uses bitcoinj via Maven so you should be able to use the POM for the dependencies:

https://github.com/jim618/multibit/tree/v0.3

Note also that bitcoinj runs it's own repo so you need to have a couple of entries in for that.

There is quite a lot of 'packaging cruft' in that POM so let me know if you have any problems.

I have multibit pointing at the last stable release (0.4) but you might want to sit on the bleeding edge and go to 0.5-SNAPSHOT.

MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 10, 2012, 09:53:41 AM
 #5

your error message means that
Code:
SECNamedCurves.getByName("secp256k1")
returned null.

Propably you have the wrong BouncyCastle lib installed. the version used in BitcoinJ is 1.46 (see pom.xml)

you Sir are correct. Thanks a bunch!

MultiBit uses bitcoinj via Maven so you should be able to use the POM for the dependencies:

https://github.com/jim618/multibit/tree/v0.3

Note also that bitcoinj runs it's own repo so you need to have a couple of entries in for that.

There is quite a lot of 'packaging cruft' in that POM so let me know if you have any problems.

I have multibit pointing at the last stable release (0.4) but you might want to sit on the bleeding edge and go to 0.5-SNAPSHOT.

Will check it out, thank you so much!
jim618
Legendary
*
Offline Offline

Activity: 1708



View Profile WWW
April 10, 2012, 10:10:44 AM
 #6

Hi vuce,

I see from your previous posts that you are working on a prototype for commitcoin.

Feel free to reuse any of the multibit code for the bitcoinj side of things if it saves you time. It is all MIT licence.
You might be interested in the MultiBitService for a bit of network abstraction or the various actions (it should be fairly clear from the name what they do. The ones with the Submit in are the ones that actually perform the task).

Jim

MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 10, 2012, 06:35:49 PM
 #7

Hi vuce,

I see from your previous posts that you are working on a prototype for commitcoin.

Feel free to reuse any of the multibit code for the bitcoinj side of things if it saves you time. It is all MIT licence.
You might be interested in the MultiBitService for a bit of network abstraction or the various actions (it should be fairly clear from the name what they do. The ones with the Submit in are the ones that actually perform the task).

Jim

Went through the code, it will certainly come in handy. Cheers!
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 12, 2012, 08:58:35 AM
 #8

Jim, just one more question, does the testnet work at all (I'm using bitcoinj 0.4, that's what's in the multibit pom also)? I get stuck with 7539 blocks to go... I'm guessing the change in the testnet difficulty rules might have something to do with that?
jim618
Legendary
*
Offline Offline

Activity: 1708



View Profile WWW
April 12, 2012, 09:30:11 AM
 #9

Hi vuce,

I do not know the status of testnet actually.  I do all my dev against the production network moving millis around.   You probably end up waiting longer for blocks to confirm but get your code exposed earlier to the vagaries of the network.

There is a pretty responsive google group for bitcoinj that might know.
https://groups.google.com/forum/?fromgroups#!forum/bitcoinj

Jim


MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
apetersson
Hero Member
*****
Offline Offline

Activity: 666


mycelium.com


View Profile WWW
April 12, 2012, 10:01:59 AM
 #10

testnet rules from bitcoin-QT (satoshi client) have changed and those rules are only in 0.5-SNAPSHOT or in one of the upcoming 0.5 releases
vuce
Sr. Member
****
Offline Offline

Activity: 476


View Profile
April 12, 2012, 02:35:33 PM
 #11

testnet rules from bitcoin-QT (satoshi client) have changed and those rules are only in 0.5-SNAPSHOT or in one of the upcoming 0.5 releases

Thanks for the help, tried that, but it still won't work (at least not consistently). Looks like it depends on the peer it connects to, sometimes it downloads 50k+ blocks and sometimes only 47k. Meh, I think I'll go with the way Jim uses.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!