pub trait ILnRpcClient:
Debug
+ Send
+ Sync {
// Required methods
fn info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetNodeInfoResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn routehints<'life0, 'async_trait>(
&'life0 self,
num_route_hints: usize,
) -> Pin<Box<dyn Future<Output = Result<GetRouteHintsResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn pay<'life0, 'async_trait>(
&'life0 self,
invoice: PayInvoiceRequest,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn route_htlcs<'a, 'life0, 'async_trait>(
self: Box<Self>,
task_group: &'life0 TaskGroup,
) -> Pin<Box<dyn Future<Output = Result<(RouteHtlcStream<'a>, Arc<dyn ILnRpcClient>), LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait;
fn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc: InterceptHtlcResponse,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn create_invoice<'life0, 'async_trait>(
&'life0 self,
create_invoice_request: CreateInvoiceRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_funding_address<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetFundingAddressResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn open_channel<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
host: String,
channel_size_sats: u64,
push_amount_sats: u64,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn close_channels_with_peer<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
) -> Pin<Box<dyn Future<Output = Result<CloseChannelsWithPeerResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_active_channels<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelInfo>, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn pay_private<'life0, 'async_trait>(
&'life0 self,
_invoice: PrunedInvoice,
_max_delay: u64,
_max_fee: Amount,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn supports_private_payments(&self) -> bool { ... }
}
Expand description
A trait that the gateway uses to interact with a lightning node. This allows the gateway to be agnostic to the specific lightning node implementation being used.
Required Methods§
sourcefn info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetNodeInfoResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn info<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetNodeInfoResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the public key and alias of the lightning node
sourcefn routehints<'life0, 'async_trait>(
&'life0 self,
num_route_hints: usize,
) -> Pin<Box<dyn Future<Output = Result<GetRouteHintsResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn routehints<'life0, 'async_trait>(
&'life0 self,
num_route_hints: usize,
) -> Pin<Box<dyn Future<Output = Result<GetRouteHintsResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get route hints to the lightning node
sourcefn pay<'life0, 'async_trait>(
&'life0 self,
invoice: PayInvoiceRequest,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pay<'life0, 'async_trait>(
&'life0 self,
invoice: PayInvoiceRequest,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Attempt to pay an invoice using the lightning node
sourcefn route_htlcs<'a, 'life0, 'async_trait>(
self: Box<Self>,
task_group: &'life0 TaskGroup,
) -> Pin<Box<dyn Future<Output = Result<(RouteHtlcStream<'a>, Arc<dyn ILnRpcClient>), LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn route_htlcs<'a, 'life0, 'async_trait>(
self: Box<Self>,
task_group: &'life0 TaskGroup,
) -> Pin<Box<dyn Future<Output = Result<(RouteHtlcStream<'a>, Arc<dyn ILnRpcClient>), LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Consumes the current client and returns a stream of intercepted HTLCs
and a new client. complete_htlc
must be called for all successfully
intercepted HTLCs sent to the returned stream.
route_htlcs
can only be called once for a given client, since the
returned stream grants exclusive routing decisions to the caller.
For this reason, route_htlc
consumes the client and returns one
wrapped in an Arc
. This lets the compiler enforce that route_htlcs
can only be called once for a given client, since the value inside
the Arc
cannot be consumed.
sourcefn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc: InterceptHtlcResponse,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc: InterceptHtlcResponse,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Complete an HTLC that was intercepted by the gateway. Must be called for
all successfully intercepted HTLCs sent to the stream returned by
route_htlcs
.
fn create_invoice<'life0, 'async_trait>(
&'life0 self,
create_invoice_request: CreateInvoiceRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
sourcefn get_funding_address<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetFundingAddressResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_funding_address<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<GetFundingAddressResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a funding address belonging to the gateway’s lightning node wallet.
sourcefn open_channel<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
host: String,
channel_size_sats: u64,
push_amount_sats: u64,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open_channel<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
host: String,
channel_size_sats: u64,
push_amount_sats: u64,
) -> Pin<Box<dyn Future<Output = Result<EmptyResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Open a channel with a peer lightning node from the gateway’s lightning node.
sourcefn close_channels_with_peer<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
) -> Pin<Box<dyn Future<Output = Result<CloseChannelsWithPeerResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close_channels_with_peer<'life0, 'async_trait>(
&'life0 self,
pubkey: PublicKey,
) -> Pin<Box<dyn Future<Output = Result<CloseChannelsWithPeerResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close all channels with a peer lightning node from the gateway’s lightning node.
fn list_active_channels<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChannelInfo>, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
sourcefn pay_private<'life0, 'async_trait>(
&'life0 self,
_invoice: PrunedInvoice,
_max_delay: u64,
_max_fee: Amount,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pay_private<'life0, 'async_trait>(
&'life0 self,
_invoice: PrunedInvoice,
_max_delay: u64,
_max_fee: Amount,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Attempt to pay an invoice using the lightning node using a
PrunedInvoice
, increasing the user’s privacy by not sending the
invoice description to the gateway.
sourcefn supports_private_payments(&self) -> bool
fn supports_private_payments(&self) -> bool
Returns true if the lightning backend supports payments without full
invoices. If this returns true, then ILnRpcClient::pay_private
has
to be implemented.
Implementations§
source§impl dyn ILnRpcClient
impl dyn ILnRpcClient
sourcepub async fn parsed_route_hints(&self, num_route_hints: u32) -> Vec<RouteHint>
pub async fn parsed_route_hints(&self, num_route_hints: u32) -> Vec<RouteHint>
Retrieve route hints from the Lightning node, capped at
num_route_hints
. The route hints should be ordered based on liquidity
of incoming channels.