ln_gateway/gateway_module_v2/
events.rs1use std::time::SystemTime;
2
3use fedimint_core::config::FederationId;
4use fedimint_core::core::ModuleKind;
5use fedimint_core::Amount;
6use fedimint_eventlog::{Event, EventKind};
7use fedimint_lnv2_common::contracts::{Commitment, OutgoingContract, PaymentImage};
8use serde::{Deserialize, Serialize};
9use serde_millis;
10
11use super::send_sm::Cancelled;
12
13#[derive(Serialize, Deserialize)]
15pub struct OutgoingPaymentStarted {
16 #[serde(with = "serde_millis")]
19 pub operation_start: SystemTime,
20
21 pub outgoing_contract: OutgoingContract,
23
24 pub min_contract_amount: Amount,
27
28 pub invoice_amount: Amount,
30
31 pub max_delay: u64,
33}
34
35impl Event for OutgoingPaymentStarted {
36 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
37
38 const KIND: EventKind = EventKind::from_static("outgoing-payment-started");
39}
40
41#[derive(Serialize, Deserialize)]
43pub struct OutgoingPaymentSucceeded {
44 pub payment_image: PaymentImage,
46
47 pub target_federation: Option<FederationId>,
49}
50
51impl Event for OutgoingPaymentSucceeded {
52 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
53
54 const KIND: EventKind = EventKind::from_static("outgoing-payment-succeeded");
55}
56
57#[derive(Serialize, Deserialize)]
59pub struct OutgoingPaymentFailed {
60 pub payment_image: PaymentImage,
62
63 pub error: Cancelled,
65}
66
67impl Event for OutgoingPaymentFailed {
68 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
69
70 const KIND: EventKind = EventKind::from_static("outgoing-payment-failed");
71}
72
73#[derive(Serialize, Deserialize)]
76pub struct IncomingPaymentStarted {
77 #[serde(with = "serde_millis")]
80 pub operation_start: SystemTime,
81
82 pub incoming_contract_commitment: Commitment,
84
85 pub invoice_amount: Amount,
87}
88
89impl Event for IncomingPaymentStarted {
90 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
91
92 const KIND: EventKind = EventKind::from_static("incoming-payment-started");
93}
94
95#[derive(Serialize, Deserialize)]
98pub struct IncomingPaymentSucceeded {
99 pub payment_image: PaymentImage,
101}
102
103impl Event for IncomingPaymentSucceeded {
104 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
105
106 const KIND: EventKind = EventKind::from_static("incoming-payment-succeeded");
107}
108
109#[derive(Serialize, Deserialize)]
111pub struct IncomingPaymentFailed {
112 pub payment_image: PaymentImage,
114
115 pub error: String,
117}
118
119impl Event for IncomingPaymentFailed {
120 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
121
122 const KIND: EventKind = EventKind::from_static("incoming-payment-failed");
123}
124
125#[derive(Serialize, Deserialize)]
129pub struct CompleteLightningPaymentSucceeded {
130 pub payment_image: PaymentImage,
132}
133
134impl Event for CompleteLightningPaymentSucceeded {
135 const MODULE: Option<ModuleKind> = Some(fedimint_lnv2_common::KIND);
136
137 const KIND: EventKind = EventKind::from_static("complete-lightning-payment-succeeded");
138}