Trait AsyncPaymentsMessageHandler

Source
pub trait AsyncPaymentsMessageHandler {
    // Required methods
    fn handle_offer_paths_request(
        &self,
        message: OfferPathsRequest,
        context: AsyncPaymentsContext,
        responder: Option<Responder>,
    ) -> Option<(OfferPaths, ResponseInstruction)>;
    fn handle_offer_paths(
        &self,
        message: OfferPaths,
        context: AsyncPaymentsContext,
        responder: Option<Responder>,
    ) -> Option<(ServeStaticInvoice, ResponseInstruction)>;
    fn handle_serve_static_invoice(
        &self,
        message: ServeStaticInvoice,
        context: AsyncPaymentsContext,
        responder: Option<Responder>,
    );
    fn handle_static_invoice_persisted(
        &self,
        message: StaticInvoicePersisted,
        context: AsyncPaymentsContext,
    );
    fn handle_held_htlc_available(
        &self,
        message: HeldHtlcAvailable,
        context: AsyncPaymentsContext,
        responder: Option<Responder>,
    ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)>;
    fn handle_release_held_htlc(
        &self,
        message: ReleaseHeldHtlc,
        context: AsyncPaymentsContext,
    );

    // Provided method
    fn release_pending_messages(
        &self,
    ) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)> { ... }
}
Expand description

A handler for an OnionMessage containing an async payments message as its payload.

The AsyncPaymentsContexts provided to each method was authenticated by the OnionMessenger as coming from a blinded path that we created.

Required Methods§

Source

fn handle_offer_paths_request( &self, message: OfferPathsRequest, context: AsyncPaymentsContext, responder: Option<Responder>, ) -> Option<(OfferPaths, ResponseInstruction)>

Handle an OfferPathsRequest message. If we are a static invoice server and the message was sent over paths that we previously provided to an async recipient, an OfferPaths message should be returned.

Source

fn handle_offer_paths( &self, message: OfferPaths, context: AsyncPaymentsContext, responder: Option<Responder>, ) -> Option<(ServeStaticInvoice, ResponseInstruction)>

Handle an OfferPaths message. If this is in response to an OfferPathsRequest that we previously sent as an async recipient, we should build an Offer containing the included OfferPaths::paths and a corresponding StaticInvoice, and reply with ServeStaticInvoice.

Source

fn handle_serve_static_invoice( &self, message: ServeStaticInvoice, context: AsyncPaymentsContext, responder: Option<Responder>, )

Handle a ServeStaticInvoice message. If this is in response to an OfferPaths message we previously sent as a static invoice server, a StaticInvoicePersisted message should be sent once the message is handled.

Source

fn handle_static_invoice_persisted( &self, message: StaticInvoicePersisted, context: AsyncPaymentsContext, )

Handle a StaticInvoicePersisted message. If this is in response to a ServeStaticInvoice message we previously sent as an async recipient, then the offer we generated on receipt of a previous OfferPaths message is now ready to be used for async payments.

Source

fn handle_held_htlc_available( &self, message: HeldHtlcAvailable, context: AsyncPaymentsContext, responder: Option<Responder>, ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)>

Handle a HeldHtlcAvailable message. A ReleaseHeldHtlc should be returned to release the held funds.

Source

fn handle_release_held_htlc( &self, message: ReleaseHeldHtlc, context: AsyncPaymentsContext, )

Handle a ReleaseHeldHtlc message. If authentication of the message succeeds, an HTLC should be released to the corresponding payee.

Provided Methods§

Source

fn release_pending_messages( &self, ) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)>

Release any AsyncPaymentsMessages that need to be sent.

Typically, this is used for messages initiating an async payment flow rather than in response to another message.

Implementors§