Expand description
Async Rust client for the LND gRPC API using tonic and prost.
§Overview
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.
§Supported LND APIs (Features)
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.
lightningrpc(core Lightning API)walletrpc(WalletKit, depends onsignrpc)signrpc(Signer)peersrpc(Peers)routerrpc(Router)invoicesrpc(Invoices)staterpc(State)versionrpc(Versioner)all(enables all RPCs)- TLS backend selection:
ring(default),aws-lc - TLS root CA selection:
tls-native-roots,tls-webpki-roots,tls
Default features: all, ring, tls
At least one TLS backend is required. The default is ring.
§Example
Connect to LND using file paths for cert and macaroon:
use voltage_tonic_lnd::Client;
#[tokio::main]
async fn main() -> Result<(), voltage_tonic_lnd::Error> {
let client = Client::builder()
.address("https://localhost:10009")
.macaroon_path("/path/to/admin.macaroon")
.cert_path("/path/to/tls.cert")
.build()
.await?;
// Use client.lightning(), client.wallet(), etc.
Ok(())
}Or using in-memory credentials:
use voltage_tonic_lnd::Client;
#[tokio::main]
async fn main() -> Result<(), voltage_tonic_lnd::Error> {
let client = Client::builder()
.address("https://localhost:10009")
.macaroon_contents(HEX_MACAROON_STRING)
.cert_contents(PEM_CERT_STRING)
.build()
.await?;
Ok(())
}See the crate README and ClientBuilder docs for more usage details.
§Example: Custom Timeout, No Cert
You can set a timeout and skip the cert (using system roots or insecure connection, depending on your TLS features):
use voltage_tonic_lnd::Client;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), voltage_tonic_lnd::Error> {
let client = Client::builder()
.address("https://localhost:10009")
.macaroon_path("/path/to/admin.macaroon")
.timeout(Duration::from_secs(10))
.build()
.await?;
Ok(())
}Re-exports§
pub use tonic;
Modules§
- invoicesrpc
- lnrpc
- Messages and other types generated by
tonic/prost - peersrpc
- routerrpc
- signrpc
- verrpc
- walletrpc
Structs§
- Client
- The client returned by
connectfunction - Client
Builder - A builder for configuring and constructing a
Clientto connect to LND via gRPC. - Macaroon
Interceptor - Supplies requests with macaroon
Enums§
Functions§
- connect
Deprecated - Connects to LND using given address and credentials
- connect_
from_ memory Deprecated - connect_from_memory connects to LND using in-memory cert and macaroon instead of from file paths.
cert`` is a PEM encoded stringmacaroon`` is a hex-encoded string These credentials can get out of date! Make sure you are pulling fresh credentials when using this function. - connect_
from_ memory_ with_ system_ certs Deprecated - connect_from_memory_with_system_certs connects to LND using in-memory macaroon and system certs. `macaroon`` is a hex-encoded string These credentials can get out of date! Make sure you are pulling fresh credentials when using this function.
Type Aliases§
- Invoices
Client - Convenience type alias for invoices client.
- Lightning
Client - Convenience type alias for lightning client.
- Peers
Client - Convenience type alias for peers service client.
- Result
- Router
Client - Convenience type alias for router client.
- Signer
Client - Convenience type alias for signer client.
- State
Client - Convenience type alias for state service client.
- Versioner
Client - Convenience type alias for versioner service client.
- Wallet
KitClient - Convenience type alias for wallet client.