voltage_tonic_lnd/lib.rs
1//! Async Rust client for the [LND gRPC API](https://github.com/lightningnetwork/lnd) using [`tonic`](https://docs.rs/tonic/) and [`prost`](https://docs.rs/prost/).
2//!
3//! # Overview
4//!
5//! This crate provides convenient, async access to the Lightning Network Daemon (LND) via gRPC, with vendored proto files for all major LND RPC APIs. It is designed for ergonomic integration with Rust async codebases, and supports feature flags for fine-grained control of enabled APIs and TLS implementations.
6//!
7//! ## Supported LND APIs (Features)
8//!
9//! Each LND RPC API is behind a Cargo feature flag. **All features are enabled by default** for a complete client, but you can select a subset for slimmer builds. See the `[features]` section in `Cargo.toml` for details.
10//!
11//! - `lightningrpc` (core Lightning API)
12//! - `walletrpc` (WalletKit, depends on `signrpc`)
13//! - `signrpc` (Signer)
14//! - `peersrpc` (Peers)
15//! - `routerrpc` (Router)
16//! - `invoicesrpc` (Invoices)
17//! - `staterpc` (State)
18//! - `versionrpc` (Versioner)
19//! - `all` (enables all RPCs)
20//! - TLS backend selection: `ring` (default), `aws-lc`
21//! - TLS root CA selection: `tls-native-roots`, `tls-webpki-roots`, `tls`
22//!
23//! **Default features:** `all`, `ring`, `tls`
24//!
25//! At least one TLS backend is required. The default is `ring`.
26//!
27//! ## Example
28//!
29//! Connect to LND using file paths for cert and macaroon:
30//!
31//! ```rust,no_run
32//! use voltage_tonic_lnd::Client;
33//!
34//! #[tokio::main]
35//! async fn main() -> Result<(), voltage_tonic_lnd::Error> {
36//! let client = Client::builder()
37//! .address("https://localhost:10009")
38//! .macaroon_path("/path/to/admin.macaroon")
39//! .cert_path("/path/to/tls.cert")
40//! .build()
41//! .await?;
42//! // Use client.lightning(), client.wallet(), etc.
43//! Ok(())
44//! }
45//! ```
46//!
47//! Or using in-memory credentials:
48//!
49//! ```rust,no_run
50//! use voltage_tonic_lnd::Client;
51//!
52//! #[tokio::main]
53//! async fn main() -> Result<(), voltage_tonic_lnd::Error> {
54//! let client = Client::builder()
55//! .address("https://localhost:10009")
56//! .macaroon_contents(HEX_MACAROON_STRING)
57//! .cert_contents(PEM_CERT_STRING)
58//! .build()
59//! .await?;
60//! Ok(())
61//! }
62//! ```
63//!
64//! See the crate README and `ClientBuilder` docs for more usage details.
65//!
66//! ### Example: Custom Timeout, No Cert
67//!
68//! You can set a timeout and skip the cert (using system roots or insecure connection, depending on your TLS features):
69//!
70//! ```rust,no_run
71//! use voltage_tonic_lnd::Client;
72//! use std::time::Duration;
73//!
74//! #[tokio::main]
75//! async fn main() -> Result<(), voltage_tonic_lnd::Error> {
76//! let client = Client::builder()
77//! .address("https://localhost:10009")
78//! .macaroon_path("/path/to/admin.macaroon")
79//! .timeout(Duration::from_secs(10))
80//! .build()
81//! .await?;
82//! Ok(())
83//! }
84//! ```
85
86#![allow(clippy::large_enum_variant)]
87#![allow(clippy::doc_lazy_continuation)]
88#![allow(clippy::doc_overindented_list_items)]
89
90mod client;
91mod error;
92mod protos;
93
94pub use client::*;
95pub use error::*;
96pub use protos::*;
97pub use tonic;