clj-btc
clj-btc copied to clipboard
Clojure bindings for the original (C++) Bitcoin Client
-
clj-btc Clojure bindings for the original (C++) Bitcoin Client json-rpc API.
This release was tested with [[https://bitcoin.org/en/release/v0.11.2][version 0.11.2]].
For the full list of calls, see: [[https://bitcoin.org/en/developer-reference#bitcoin-core-apis][Bitcoin Core APIs]].
-
Installation
** [[https://github.com/technomancy/leiningen][leiningen]] add this to your =project.clj='s =:dependencies=:
#+BEGIN_EXAMPLE [clj-btc "0.11.2"] #+END_EXAMPLE
** [[http://maven.apache.org/][Maven]]
#+BEGIN_EXAMPLE
-
Usage
To call the method (for example) =getinfo= on a bitcoind according to the local default =bitcoin.conf= file: #+BEGIN_EXAMPLE 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} #+END_EXAMPLE
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=. #+BEGIN_EXAMPLE 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 #+END_EXAMPLE
It is also possible to use a different configuration file by passing its path to =clj-btc.config/parse-config=: #+BEGIN_EXAMPLE 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 #+END_EXAMPLE
-
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 [[https://github.com/clojure/core.typed][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 [[https://github.com/aviad/clj-btc][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.