use std::fs;
#[tokio::main]
async fn main() {
let cert_bytes = fs::read("path/to/tlscert").expect("FailedToReadTlsCertFile");
let mac_bytes = fs::read("path/to/macaroon").expect("FailedToReadMacaroonFile");
let cert = buffer_as_hex(cert_bytes);
let macaroon = buffer_as_hex(mac_bytes);
let socket = "localhost:10001".to_string();
let mut client = lnd_grpc_rust::connect(cert, macaroon, socket)
.await
.expect("failed to connect");
let info = client
.lightning()
.get_info(lnd_grpc_rust::lnrpc::GetInfoRequest {})
.await
.expect("failed to get info");
println!("{:#?}", info);
}
fn buffer_as_hex(bytes: Vec<u8>) -> String {
let hex_str = bytes
.iter()
.map(|b| format!("{:02x}", b))
.collect::<String>();
hex_str
}