Bitcoin Core RPC client
Find a file
kilianmh e514e73085 Chore: change package qualifier
Needed due to changes in jsonrpc
2024-06-16 12:26:21 +02:00
src Chore: change package qualifier 2024-06-16 12:26:21 +02:00
test Initial commit 2024-02-13 08:27:26 +01:00
.gitignore Initial commit 2024-02-13 08:27:26 +01:00
bitcoin-core-rpc.asd Initial commit 2024-02-13 08:27:26 +01:00
LICENSE Initial commit 2024-02-13 08:27:26 +01:00
README.org Initial commit 2024-02-13 08:27:26 +01:00

BITCOIN-CORE-RPC

This is the (hopefully) complete Bitcoin core RPC Client (as of version 0.26) implemented in Common Lisp. Detailed information about the rpc can be gathered from the official documentation. Or the bitcoin-core-openrpc project.

Features

  • Argument type checking
  • All rpc methods supported (as of bitcoin core version 0.26)
  • method names are `lispified`, e.g. getrawmempool -> get-raw-memory-pool
  • (Arrays of) Objects are converted to native (arrays of) CLOS instances

    • For unconverted results you can switch to the bitcoin-core-rpc/methods package
  • method arguments can be supplied as native lisp data structures
  • Authentication settings can be saved in a file so no need to initialize every time

Warning

  • This software is still ALPHA quality. The APIs will be likely to change.

Installation

First you need to make sure that Bitcoin Core is running and the RPC is activated.

Loading the system

First loading (only required if some dependencies are missing)

  (ql:quickoad :bitcoin-core-rpc)

After all dependencies are present, you can load with:

  (asdf:load-system :bitcoin-core-rpc)

Connect to Node

After loading, you need to initialize the authentication since bitcoin core requires that for every call. This can be done with the `initialize-authorization` function.

If there is an rpcuser and rpcpassword specified in the bitcoin.conf file, and it looks like this:

rpcuser=someuser
rpcpassword=somepass

then you can supply the rpcuser and rpcpassword to the `user-password` keyword e.g. as list:

  (bitcoin-core-rpc:node-connect :user-password (list "someuser" "somepass"))

or as concatenated string with ":" (colon) in the middle:

  (bitcoin-core-rpc:node-connect :user-password "someuser:somepass")

Alternatively, you can supply the path to the bitcoin.conf / .cookie folder / file. The path can be supplied to the `configuration-path` keyword

  (bitcoin-core-rpc:node-connect :configuration-path "/home/user/Bitcoin/")
  ;; folder where bitcoin.conf or .cookie has to be present.

,the path to the bitcoin.conf directly,

  (bitcoin-core-rpc:node-connect :configuration-path "/home/user/Bitcoin/bitcoin.conf")

or the path to the .cookie file (when no rpcuser and rpcpassword specified in the bitcoin.conf file)

  (bitcoin-core-rpc:node-connect :configuration-path (list "/home/user/Bitcoin/.cookie"))

Usage

The method names are lispified (param-cased and abbreviations mostly replaced by the full form). You can test the connection with

  (bitcoin-core-rpc:get-best-block-hash)

Extensive testing can be performed with.

  (asdf:test-system :bitcoin-core-rpc)

In the test-suite you can also see examples how to use the library.

Call for collaboration

Feel free to contribute by opening issues, pull request, feature requests etc. Your help is much appreciated.

Copyright

(C) 2023 Kilian M. Haemmerle (kilian.haemmerle@protonmail.com)

License

Licensed under the AGPLv3+ License.