core-lightning/cln-rpc/examples/getinfo.rs
Vincenzo Palazzo 7e6893af9e rust: fixed compiler warning in the example
Changelog-None: rust: fixed compiler warning in the example

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-03-29 10:07:25 +10:30

20 lines
561 B
Rust

use anyhow::Context;
use cln_rpc::{model::GetinfoRequest, ClnRpc, Request};
use std::env::args;
use std::path::Path;
use tokio;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// initialize the log inside the library
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(())
}