// This example only fetches and prints the node info to the standard output similarly to // `lncli getinfo`. // // The program accepts three arguments: address, cert file, macaroon file // The address must start with `https://`! // // Example run: `cargo run --features=lightningrpc --example get_info
` #[tokio::main] #[cfg(feature = "lightningrpc")] async fn main() { let mut args = std::env::args_os(); args.next().expect("not even zeroth arg given"); let address = args .next() .expect("missing arguments: address, cert file, macaroon file"); let cert_file = args .next() .expect("missing arguments: cert file, macaroon file"); let macaroon_file = args.next().expect("missing argument: macaroon file"); let address = address.into_string().expect("address is not UTF-8"); // Connecting to LND requires only address, cert file, and macaroon file let mut client = fedimint_tonic_lnd::connect(address, cert_file, macaroon_file) .await .expect("failed to connect"); let info = client .lightning() // All calls require at least empty parameter .get_info(fedimint_tonic_lnd::lnrpc::GetInfoRequest {}) .await .expect("failed to get info"); // We only print it here, note that in real-life code you may want to call `.into_inner()` on // the response to get the message. println!("{:#?}", info); }