Skip to main content

fedimint_ln_client/pay/
lightningpay.rs

1use fedimint_core::OutPoint;
2use fedimint_core::encoding::{Decodable, Encodable};
3
4use super::{
5    LightningPayCreatedOutgoingLnContract, LightningPayFunded, LightningPayRefund,
6    LightningPayRefundable,
7};
8
9/// State machine that requests the lightning gateway to pay an invoice on
10/// behalf of a federation client.
11///
12/// ```mermaid
13/// graph LR
14/// classDef virtual fill:#fff,stroke-dasharray: 5 5
15///
16///  CreatedOutgoingLnContract -- await transaction failed --> Canceled
17///  CreatedOutgoingLnContract -- await transaction acceptance --> Funded
18///  Funded -- await gateway payment success  --> Success
19///  Funded -- await gateway cancel payment --> Refund
20///  Funded -- await payment timeout --> Refund
21///  Funded -- unrecoverable payment error --> Failure
22///  Refundable -- gateway issued refunded --> Refund
23///  Refundable -- transaction timeout --> Refund
24/// ```
25#[allow(clippy::large_enum_variant)]
26#[derive(Debug, Clone, Eq, PartialEq, Hash, Decodable, Encodable)]
27pub enum LightningPayStates {
28    CreatedOutgoingLnContract(LightningPayCreatedOutgoingLnContract),
29    FundingRejected,
30    Funded(LightningPayFunded),
31    Success(String),
32    #[deprecated(
33        since = "0.4.0",
34        note = "Pay State Machine skips over this state and will retry payments until cancellation or timeout"
35    )]
36    Refundable(LightningPayRefundable),
37    Refund(LightningPayRefund),
38    #[deprecated(
39        since = "0.4.0",
40        note = "Pay State Machine does not need to wait for the refund tx to be accepted"
41    )]
42    Refunded(Vec<OutPoint>),
43    Failure(String),
44}