Tonic LND client

Rust implementation of LND RPC client using async GRPC library tonic.

About

Warning: this crate is in early development and may have unknown problems! Review it before using with mainnet funds!

This crate implements LND GRPC using tonic and prost. Apart from being up-to-date at the time of writing (:D) it also allows async usage. It contains vendored lightning.proto file so LND source code is not required but accepts an environment variable LND_REPO_DIR which overrides the vendored lightning.proto file. This can be used to test new features in non-released lnd. (Actually, the motivating project using this library was that case. :))

Usage

There's no setup needed beyond adding the crate to your Cargo.toml. If you need to change the lightning.proto input set the environment variable LND_REPO_DIR to the directory with cloned lnd during build.

Here's an example of retrieving information from LND (getinfo call). You can find the same example in crate root for your convenience.

```rust // This program accepts four arguments: host, port, cert file, macaroon file

[tokio::main]

async fn main() { let mut args = std::env::argsos(); args.next().expect("not even zeroth arg given"); let host = args .next() .expect("missing arguments: host, port, cert file, macaroon file"); let port = args .next() .expect("missing arguments: port, cert file, macaroon file"); let certfile = args .next() .expect("missing arguments: cert file, macaroon file"); let macaroonfile = args.next().expect("missing argument: macaroon file"); let host: String = host.intostring().expect("host is not UTF-8"); let port: u32 = port .intostring() .expect("port is not UTF-8") .parse() .expect("port is not u32"); let certfile: String = certfile.intostring().expect("certfile is not UTF-8"); let macaroonfile: String = macaroonfile .intostring() .expect("macaroon_file is not UTF-8");

// Connecting to LND requires only host, port, cert file, macaroon file
let mut client = tonic_openssl_lnd::connect(host, port, cert_file, macaroon_file)
    .await
    .expect("failed to connect");

let info = client
    // All calls require at least empty parameter
    .get_info(tonic_openssl_lnd::rpc::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);

} ```

MSRV

1.48.0

License

MITNFA