#protocol #rpc #bitcoin #lightning

clightningrpc

Crate that provides an RPC binding from rust code to the c-lightning daemon

1 unstable release

0.1.0 Sep 5, 2018

#90 in Cryptocurrencies

Download history 8/week @ 2018-09-05

2 downloads per month

CC0 license Custom license

50KB
1K SLoC

Rust c-lightning client

Status

This crate provides an interface from rust to the c-lightning daemon through RPC.

extern crate clightningrpc;

use clightningrpc::LightningRPC;

fn main() {
    let mut client = LightningRPC::new("/home/user/.lightning/lightning-rpc".to_string());

    println!("getinfo result: {:?}", client.getinfo().unwrap());
}

See examples directory for more usage examples.

Currently implemented (this covers all non-dev commands as of c-lightning v0.6.1rc1):

  • getinfo
  • feerates
  • listnodes
  • listchannels
  • help
  • getlog
  • listconfigs
  • listpeers
  • listinvoices
  • invoice
  • delinvoice
  • delexpiredinvoice
  • autocleaninvoice
  • waitanyinvoice
  • waitinvoice
  • pay
  • sendpay
  • waitsendpay
  • listpayments
  • decodepay
  • getroute
  • connect
  • disconnect
  • fundchannel
  • close
  • ping
  • listfunds
  • withdraw
  • newaddr
  • stop

Be aware that the API (of rust-clighting-rpc, but also that of c-lightning itself) is not finalized. This means that it may change from version to version and break your compile, sorry!

To do

  • verify use of i64 versus u64 in API
  • fundchannel, withdraw: allow passing all for satoshi
  • document low and high level handling
  • document error handling
  • reproducible functional test that exercises against actual lightning instances (regtest?)
  • a better way to get at the data for failed payments
"code" : 205, "message" : "Could not find a route", "data" : ...

data could be parsed into a structure, but this depends on the kind of error

  • the API could make more use of enums where the possible values are known; for example the addresstype parameter to newaddr, but also in returned structures. This has to be weighted agains flexibility, though, in case the API is extended later.

  • decide on &str versus String on high-level API (but at least make sure it is consistent)

Style guidelines

  • Four spaces
  • Call rustfmt src/*.rs before committing

Credits

This library is based on Andrew Poelstra's rust-jsonrpc.

Dependencies

~1.5MB
~30K SLoC