Crates.io | clightningrpc-common |
lib.rs | clightningrpc-common |
version | 0.3.0-beta.4 |
source | src |
created_at | 2022-05-23 21:12:13.124201 |
updated_at | 2023-06-13 09:31:35.321454 |
description | Crate that provides an Generic RPC binding from rust code to the core lightning daemon |
homepage | https://github.com/laanwj/rust-clightning-rpc |
repository | https://github.com/laanwj/rust-clightning-rpc.git |
max_upload_size | |
id | 592163 |
size | 18,064 |
This crate provides a generic interface to the core lightning daemon through RPC.
This crate provides a generic interface to the core lightning daemon through RPC.
From the crate clightningrpc you can find this quote
Be aware that the API (of rust-clighting-rpc, but also that of c-lightning itself) is not finalized. This means that it is likely to change between versions and may break your compile, sorry!
This crate solve the versioning with core lightning by offering a strongly type library with a generic interface, an example can be:
extern crate clightningrpc_common;
use serde::{Deserialize, Serialize};
use std::env;
use clightningrpc_common::client;
use clightningrpc_common::types::Response;
/// Example of type definition
#[derive(Debug, Clone, Deserialize, Serialize)]
struct GetInfoResponse {
pub id: String,
}
/// Example of type definition
#[derive(Debug, Clone, Deserialize, Serialize)]
struct GetInfoRequest {}
fn main() {
let sock = env::home_dir().unwrap().join(".lightning/lightning-rpc");
println!("Using socket {}", sock.display());
let client = client::Client::new(&sock);
let method = "getinfo";
let params = GetInfoRequest {};
match client
.send_request(method, params)
.and_then(|res: Response<GetInfoResponse>| res.into_result())
{
Ok(d) => {
println!("Ok! {:?}", d);
}
Err(e) => {
println!("Error! {}", e);
}
}
}
make fmt
before committingIf you want support this library consider to donate with the following methods
This library is based on Andrew Poelstra's rust-jsonrpc.