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