8 releases (4 breaking)

0.5.1 Mar 11, 2023
0.5.0 Nov 4, 2022
0.4.0 Jul 1, 2022
0.3.0 Dec 16, 2021
0.1.1 Jul 7, 2021

#1631 in Asynchronous

Download history 131/week @ 2024-03-25 161/week @ 2024-04-01 100/week @ 2024-04-08 75/week @ 2024-04-15 87/week @ 2024-04-22 52/week @ 2024-04-29 20/week @ 2024-05-06 1/week @ 2024-05-13 1/week @ 2024-05-20 31/week @ 2024-05-27 30/week @ 2024-06-03 85/week @ 2024-06-10 34/week @ 2024-06-17 15/week @ 2024-06-24 32/week @ 2024-07-01 15/week @ 2024-07-08

103 downloads per month
Used in 2 crates

MITNFA license

290 lines

Tonic LND client

Crate Documentation

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


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

This crate supports Lightning, WalletKit, Signer, and Peer RPC APIs from LND v0.15.4-beta

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 *.proto files so LND source code is not required but accepts an environment variable LND_REPO_DIR which overrides the vendored *.proto files. This can be used to test new features in non-released lnd. (Actually, the motivating project using this library was that case. :))


There's no setup needed beyond adding the crate to your Cargo.toml. If you need to change the *.proto files from which the client is generated, set the environment variable LND_REPO_DIR to a directory with cloned lnd during build.

Here's an example of retrieving information from LND ([getinfo](https://api.lightning.community/#getinfo) call). You can find the same example in crate root for your convenience.

// This program accepts three arguments: address, cert file, macaroon file
// The address must start with `https://`!

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 = tonic_lnd::connect(address, cert_file, macaroon_file)
        .expect("failed to connect");

    let info = client
        // All calls require at least empty parameter
        .get_info(tonic_lnd::lnrpc::GetInfoRequest {})
        .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);



However some dependencies may need to be downgraded using cargo update -p <package> --precise <version>. Cargo-msrv.lock is included for reference - it is the lock file used to test the crate and contains known working versions of dependencies.

The MSRV won't be bumped sooner than Debian Bookworm release.




~382K SLoC