Skip to content

aviad/clj-btc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-btc

Clojure bindings for the original (C++) Bitcoin Client json-rpc API.

This release was tested with *version 0.11.2*.

For the full list of calls, see: Bitcoin Core APIs.

Installation

add this to your project.clj’s :dependencies:

[clj-btc "0.11.2"]
<dependency>
  <groupId>clj-btc</groupId>
  <artifactId>clj-btc</artifactId>
  <version>0.11.2</version>
</dependency>

Usage

To call the method (for example) getinfo on a bitcoind according to the local default bitcoin.conf file:

user=> (require '[clj-btc.core :as btc])
;;=> nil
user=> (btc/getinfo)
;;=> {"timeoffset" 0, "protocolversion" 70001, "blocks" 111908, "errors" "",
      "testnet" true, "proxy" "", "connections" 4, "version" 80500,
      "keypoololdest" 1380388750, "paytxfee" 0E-8M,
      "difficulty" 4642.44443532M, "keypoolsize" 101, "balance" 0E-8M,
      "walletversion" 60000}

By default, any call on an rpc-method will read the (default) local configuration file. However, since this is somewhat less than efficient, it is possible to specify a configuration manually. The configuration must contain the keys :rpcpassword :rpcuser :testnet :rpcport and :rpchost.

user=> (def config {:rpcpassword "PASSWORD", :rpcuser "USR", :testnet true,
                    :rpcport 18332, :rpchost "http://127.0.0.1"})
;;=> #'user/config
user=> (btc/getbalace :config config)  ; no file is read to get configs
;;=> 2.718281M

It is also possible to use a different configuration file by passing its path to clj-btc.config/parse-config:

user=> (require '[clj-btc.config :only (parse-config)])
;;=> nil
user=> (def config (parse-config "/path/to/my.conf"))
;;=> #'user/config
user=> (btc/getbalace :config config)  ; no file is read to get configs
;;=> 777M

Future Work

  • [ ] Add tests for all the rpc methods.
  • [ ] Replace transactions in tests with some of the first ones on testnet - for test performance and stability.
  • [ ] Add types with core.typed.
  • [ ] Improve documentation with more examples.

Changes

See CHANGES.org at the root of this repo.

Contact

You can contact the maintainer of this library, and other developpers/users at github, or [email protected].

License

Copyright 2013-2016 Aviad Reich.

The use and distribution terms for this software are covered by the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt), which can be found in the file LICENSE at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

About

Clojure bindings for the original (C++) Bitcoin Client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •