switchgear_components/pool/
mod.rs1mod client_pool;
2pub mod cln;
3pub mod error;
4pub mod lnd;
5
6use crate::pool::cln::grpc::config::ClnGrpcDiscoveryBackendImplementation;
7use crate::pool::lnd::grpc::config::LndGrpcDiscoveryBackendImplementation;
8use async_trait::async_trait;
9use serde::{Deserialize, Serialize};
10
11pub use client_pool::LnClientPool;
12
13#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15#[serde(tag = "type")]
16pub enum DiscoveryBackendImplementation {
17 ClnGrpc(ClnGrpcDiscoveryBackendImplementation),
18 LndGrpc(LndGrpcDiscoveryBackendImplementation),
19}
20
21#[async_trait]
22pub trait LnRpcClient {
23 type Error: std::error::Error + Send + Sync + 'static;
24
25 async fn get_invoice<'a>(
26 &self,
27 amount_msat: Option<u64>,
28 description: Bolt11InvoiceDescription<'a>,
29 expiry_secs: Option<u64>,
30 ) -> Result<String, Self::Error>;
31
32 async fn get_metrics(&self) -> Result<LnMetrics, Self::Error>;
33
34 fn get_features(&self) -> Option<&LnFeatures>;
35}
36
37#[derive(Eq, PartialEq, Debug, Clone, Ord, PartialOrd)]
38pub enum Bolt11InvoiceDescription<'a> {
39 Direct(&'a str),
40 DirectIntoHash(&'a str),
41 Hash(&'a [u8; 32]),
42}
43
44#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
45pub struct LnFeatures {
46 pub invoice_from_desc_hash: bool,
47}
48
49#[derive(Eq, PartialEq, Debug, Clone, Ord, PartialOrd)]
50pub struct LnMetrics {
51 pub healthy: bool,
52 pub node_effective_inbound_msat: u64,
53}