bitcoin-s/bitcoind-rpc
2019-04-10 13:37:46 -05:00
..
src/main/scala/org/bitcoins/rpc Fix bug in how addresses are passed to bitcoind (#404) 2019-04-10 13:37:46 -05:00
README.md Add support for Bitcoin Core 0.17 (#384) 2019-03-26 12:41:05 -05:00

Download

Note: bitcoin-s-bitcoind-rpc requires you to have bitcoind (Bitcoin Core daemon) installed. Grab this at bitcoincore.org

Usage

The Bitcoin Core RPC client in Bitcoin-S currently supports the Bitcoin Core 0.16 and 0.17 version lines. It can be set up to work with both local and remote Bitcoin Core servers.

Basic example

import org.bitcoins.rpc
import rpc.client.common._
import rpc.config.BitcoindInstance
import akka.actor.ActorSystem

// data directory defaults to ~/.bitcoin on Linux and
// ~/Library/Application Support/Bitcoin on macOS
val bitcoindInstance = BitcoindInstance.fromDatadir() 

// alternative: 
import java.io.File
val dataDir = new File("/my/bitcoin/data/dir")
val otherInstance = BitcoindInstance.fromDatadir(dataDir)

implicit val actorSystem: ActorSystem = ActorSystem.create()

val client = new BitcoindRpcClient(bitcoindInstance)

for {
  _ <- client.start()
  balance <- client.getBalance
} yield balance

Advanced example

TODO: How to connect to remote bitcoind

Testing

To test the Bitcoin-S RPC project you need both version 0.16 and 0.17 of Bitcoin Core. A list of current and previous releases can be found here.

You then need to set environment variables to indicate where Bitcoin-S can find the different versions:

$ export BITCOIND_V16_PATH=/path/to/v16/bitcoind
$ export BITCOIND_V17_PATH=/path/to/v17/bitcoind

If you just run tests testing common functionality it's enough to have either version 0.16 or 0.17 on your PATH.

To run all RPC related tests:

$ bash sbt bitcoindRpcTest/test