ln_gateway/state_machine/
events.rs1use fedimint_core::core::{ModuleKind, OperationId};
2use fedimint_core::Amount;
3use fedimint_eventlog::{Event, EventKind};
4use fedimint_ln_common::contracts::outgoing::OutgoingContractAccount;
5use fedimint_ln_common::contracts::ContractId;
6use serde::{Deserialize, Serialize};
7
8use super::pay::OutgoingPaymentError;
9
10#[derive(Serialize, Deserialize)]
12pub struct OutgoingPaymentStarted {
13 pub contract_id: ContractId,
15
16 pub invoice_amount: Amount,
18
19 pub operation_id: OperationId,
21}
22
23impl Event for OutgoingPaymentStarted {
24 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
25
26 const KIND: EventKind = EventKind::from_static("outgoing-payment-started");
27}
28
29#[derive(Serialize, Deserialize)]
31pub struct OutgoingPaymentSucceeded {
32 pub outgoing_contract: OutgoingContractAccount,
34
35 pub contract_id: ContractId,
37
38 pub preimage: String,
40}
41
42impl Event for OutgoingPaymentSucceeded {
43 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
44
45 const KIND: EventKind = EventKind::from_static("outgoing-payment-succeeded");
46}
47
48#[derive(Serialize, Deserialize)]
50pub struct OutgoingPaymentFailed {
51 pub outgoing_contract: OutgoingContractAccount,
53
54 pub contract_id: ContractId,
56
57 pub error: OutgoingPaymentError,
59}
60
61impl Event for OutgoingPaymentFailed {
62 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
63
64 const KIND: EventKind = EventKind::from_static("outgoing-payment-failed");
65}
66
67#[derive(Serialize, Deserialize)]
69pub struct IncomingPaymentStarted {
70 pub contract_id: ContractId,
72
73 pub payment_hash: bitcoin::hashes::sha256::Hash,
75
76 pub invoice_amount: Amount,
78
79 pub contract_amount: Amount,
81
82 pub operation_id: OperationId,
84}
85
86impl Event for IncomingPaymentStarted {
87 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
88
89 const KIND: EventKind = EventKind::from_static("incoming-payment-started");
90}
91
92#[derive(Serialize, Deserialize)]
94pub struct IncomingPaymentSucceeded {
95 pub payment_hash: bitcoin::hashes::sha256::Hash,
97
98 pub preimage: String,
100}
101
102impl Event for IncomingPaymentSucceeded {
103 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
104
105 const KIND: EventKind = EventKind::from_static("incoming-payment-succeeded");
106}
107
108#[derive(Serialize, Deserialize)]
110pub struct IncomingPaymentFailed {
111 pub payment_hash: bitcoin::hashes::sha256::Hash,
113
114 pub error: String,
116}
117
118impl Event for IncomingPaymentFailed {
119 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
120
121 const KIND: EventKind = EventKind::from_static("incoming-payment-failed");
122}
123
124#[derive(Serialize, Deserialize)]
127pub struct CompleteLightningPaymentSucceeded {
128 pub payment_hash: bitcoin::hashes::sha256::Hash,
130}
131
132impl Event for CompleteLightningPaymentSucceeded {
133 const MODULE: Option<ModuleKind> = Some(fedimint_ln_common::KIND);
134
135 const KIND: EventKind = EventKind::from_static("complete-lightning-payment-succeeded");
136}