core-lightning/cln-rpc/examples/getinfo.rs
Christian Decker f5e1829117 cln-plugin: Implement logging facade adapter for cln plugins
We wrap emitted messages into a JSON-RPC notification envelope and
write them to stdout. We use an indirection over an mpsc channel in
order to avoid deadlocks if we emit logs while holding the writer lock
on stdout.
2022-03-10 10:21:41 +10:30

19 lines
530 B
Rust

use anyhow::Context;
use cln_rpc::{model::GetinfoRequest, ClnRpc, Request};
use log::info;
use std::env::args;
use std::path::Path;
use tokio;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
env_logger::init();
let rpc_path = args().nth(1).context("missing argument: socket path")?;
let p = Path::new(&rpc_path);
let mut rpc = ClnRpc::new(p).await?;
let response = rpc.call(Request::Getinfo(GetinfoRequest {})).await?;
println!("{}", serde_json::to_string_pretty(&response)?);
Ok(())
}