Trait ln_gateway::lightning::ILnRpcClient

source ·
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 mut 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;

    // 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§

source

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

source

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

source

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

source

fn route_htlcs<'a, 'life0, 'async_trait>( self: Box<Self>, task_group: &'life0 mut 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.

source

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.

Provided Methods§

source

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.

source

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.

Implementors§