pub trait IGatewayClientV1:
Debug
+ Send
+ Sync {
// Required methods
fn verify_preimage_authentication<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
preimage_auth: Hash,
contract: OutgoingContractAccount,
) -> Pin<Box<dyn Future<Output = Result<(), OutgoingPaymentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn verify_pruned_invoice<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_routing_fees<'life0, 'async_trait>(
&'life0 self,
federation_id: FederationId,
) -> Pin<Box<dyn Future<Output = Option<RoutingFees>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_client<'life0, 'life1, 'async_trait>(
&'life0 self,
federation_id: &'life1 FederationId,
) -> Pin<Box<dyn Future<Output = Option<Spanned<ClientHandleArc>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_client_for_invoice<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
) -> Pin<Box<dyn Future<Output = Option<Spanned<ClientHandleArc>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn pay<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
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 outbound_payment_exists<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc_response: InterceptPaymentResponse,
) -> Pin<Box<dyn Future<Output = Result<(), LightningRpcError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_lnv2_direct_swap<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
amount: Amount,
) -> Pin<Box<dyn Future<Output = Result<Option<(IncomingContract, ClientHandleArc)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
An interface between module implementation and the general Gateway
To abstract away and decouple the core gateway from the modules, the interface between them is expressed as a trait. The gateway handles operations that require Lightning node access or database access.
Required Methods§
Sourcefn verify_preimage_authentication<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
preimage_auth: Hash,
contract: OutgoingContractAccount,
) -> Pin<Box<dyn Future<Output = Result<(), OutgoingPaymentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_preimage_authentication<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
preimage_auth: Hash,
contract: OutgoingContractAccount,
) -> Pin<Box<dyn Future<Output = Result<(), OutgoingPaymentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Verifies that the supplied preimage_auth is the same as the
preimage_auth that initiated the payment.
If it is not, then this will return an error because this client is not authorized to receive the preimage.
Sourcefn verify_pruned_invoice<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_pruned_invoice<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Verify that the lightning node supports private payments if a pruned invoice is supplied.
Sourcefn get_routing_fees<'life0, 'async_trait>(
&'life0 self,
federation_id: FederationId,
) -> Pin<Box<dyn Future<Output = Option<RoutingFees>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_routing_fees<'life0, 'async_trait>(
&'life0 self,
federation_id: FederationId,
) -> Pin<Box<dyn Future<Output = Option<RoutingFees>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the federation’s routing fees from the federation’s config.
Sourcefn get_client<'life0, 'life1, 'async_trait>(
&'life0 self,
federation_id: &'life1 FederationId,
) -> Pin<Box<dyn Future<Output = Option<Spanned<ClientHandleArc>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_client<'life0, 'life1, 'async_trait>(
&'life0 self,
federation_id: &'life1 FederationId,
) -> Pin<Box<dyn Future<Output = Option<Spanned<ClientHandleArc>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a client given a federation ID, used for swapping ecash between federations.
fn get_client_for_invoice<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
) -> Pin<Box<dyn Future<Output = Option<Spanned<ClientHandleArc>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn pay<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
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<'life0, 'async_trait>(
&'life0 self,
payment_data: PaymentData,
max_delay: u64,
max_fee: Amount,
) -> Pin<Box<dyn Future<Output = Result<PayInvoiceResponse, LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pay a Lightning invoice using the gateway’s lightning node.
Sourcefn outbound_payment_exists<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn outbound_payment_exists<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns whether the gateway’s Lightning node has any record of an
outbound payment for payment_hash, whatever its state.
The pay state machine consults this when it resumes after a restart:
a payment the node already knows was dispatched before the crash and
must be resolved through IGatewayClientV1::pay’s idempotent resume
path rather than cancelled by pre-dispatch checks. A wrong false
cancels a contract whose payment may still settle, so implementations
must absorb transient node failures and only answer once the node’s
payment store could actually be consulted.
Sourcefn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc_response: InterceptPaymentResponse,
) -> Pin<Box<dyn Future<Output = Result<(), LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn complete_htlc<'life0, 'async_trait>(
&'life0 self,
htlc_response: InterceptPaymentResponse,
) -> Pin<Box<dyn Future<Output = Result<(), LightningRpcError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Uses the gateway’s lightning node to complete (settle or cancel) a previously intercepted HTLC.
By the time the gateway settles the upstream HTLC it has already funded
the incoming contract, so a transient failure here must not strand it
out of pocket. Implementations must absorb and retry every transient
node or connectivity failure, returning Err only when Lightning has
reached a permanent state that makes the requested outcome impossible.
The future may block while retrying and must remain cancellation-safe.
The completion state machine persists any returned error as a terminal
failure.
Sourcefn is_lnv2_direct_swap<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
amount: Amount,
) -> Pin<Box<dyn Future<Output = Result<Option<(IncomingContract, ClientHandleArc)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_lnv2_direct_swap<'life0, 'async_trait>(
&'life0 self,
payment_hash: Hash,
amount: Amount,
) -> Pin<Box<dyn Future<Output = Result<Option<(IncomingContract, ClientHandleArc)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the gateway satisfy the LNv1 payment by funding an LNv2
IncomingContract