Giter Site home page Giter Site logo

fullnodej's Introduction

Bitcoind Json Rpc Client for Java

A Java library for the Json Rpc interface of a Bitcoin Fullnode.

Fire up a bitcoin fullnode in command-line -server configuration, configure your ports and passwords in Fullnode, and you are ready to pull data from the blockchain, maybe even send some data. Advisable to develop on the testnet network until "the time comes".

Running bitcoind with default settings, retrieve the current height of the last mined block:

Fullnode.createRpc(new RpcParams("your_rpc_password")).getblockcount();

An attempt has been made to be feature-to-feature compatible with most commands listed in the Bitcoin RPC Reference.
This library has been tested against Bitcoind 0.11.2 (Classic and Core) but does not yet support 0.12.0 (soon).

Listeners

The library can receive messages from the bitcoin node when the node detects transactions that have an affect on the wallet, when new blocks are mined, or when alerts are broadcast. Both bitcoind and fullnodej need to be configured properly:

#####1. Configure Bitcoind

Select a port for Fullnodej to use, let's say :7931. Bitcoind needs command-line options to match:

/usr/bin/bitcoind -server -testnet
	-blocknotify="echo '%s' | nc 127.0.0.1 7931" \ 
	-walletnotify="echo '%s' | nc 127.0.0.1 7931" \
	-alertnotify="echo '%s' | nc 127.0.0.1 7931"

Note: You may also want to add additional command-line options here: -txindex for a more complete database, -rescan to ensure an up-to-date wallet and explicitly define your -rpcport=18332.

#####2. Configure Fullnode

Next, use this library to open and listen on that port, create an instance of Notify, and pass it to the Notifications system:

Notifications listener = fullnode.getNotifications();
lisener.setListenerPort(7931);
MyBlockListener blocks = new Notify() { @Override... };
listener.attach(blocks);

You should be picking up new blocks and/or wallet transactions now.

Be sure to Notifications.detach() your Notify instances and/or call Notifications.shutdown() to free the port.

You may connect to multiple Bitcoin nodes and notification interfaces. More configurations can be seen in the accompanying test artifacts which include one scenario with 2 nodes sending funds between them while their confirmation listeners notify a referee.

Build

mvn clean install

NOTE: Building this project requires the java-agent lombok on the classpath.
More info at: Project Lombok (github)

A De-Lombok'ed version of this library is available:

https://github.com/jeffmasty/fullnode-dj

Usage

Not currently in Maven Central, the dependency will be:

<dependency>
  <groupId>org.fullnodej</groupId>
  <artifactId>fullnodej</artifactId>
  <version>0.12.1</version>
</dependency>

Testing

JUnit tests were developed alongside this project, available:

https://github.com/jeffmasty/fullnodej-test

The Rpc interface in this library may be useful but you will find the associated tests and framework even more exciting.

Acknowledgements

This project was inspired by Johann Barbie and the BitcoindClient4J project.

Donations

Bitcoin donations can be sent to:

1Es3KYL6tyB3Swpq9r81uYb8X6D3TcHkjw

Employment opportunities also requested, thanks!

License

MIT License

fullnodej's People

Contributors

jeffmasty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.