ln_gateway::lightning

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

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 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.

source

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,

source

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.

source

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.

source

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.

source

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§

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.

Implementations§

source§

impl dyn ILnRpcClient

source

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.

source

pub async fn parsed_node_info( &self, ) -> Result<(PublicKey, String, Network, u32, bool)>

Retrieves the basic information about the Gateway’s connected Lightning node.

Implementors§