fedimint_walletv2_client/
events.rs1use bitcoin::address::NetworkUnchecked;
2use bitcoin::{Address, Txid};
3use fedimint_core::core::{Account, ModuleKind, OperationId};
4use fedimint_eventlog::{Event, EventKind, EventPersistence};
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
9pub struct SendPaymentEvent {
10 pub operation_id: OperationId,
11 pub address: Address<NetworkUnchecked>,
12 pub value: bitcoin::Amount,
13 pub fee: bitcoin::Amount,
14 #[serde(default = "Account::primary")]
18 pub account: Account,
19}
20
21impl Event for SendPaymentEvent {
22 const MODULE: Option<ModuleKind> = Some(fedimint_walletv2_common::KIND);
23 const KIND: EventKind = EventKind::from_static("payment-send");
24 const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
25}
26
27#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
29pub enum SendPaymentStatus {
30 Success(Txid),
32 Aborted,
34}
35
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
38pub struct SendPaymentUpdateEvent {
39 pub operation_id: OperationId,
40 pub status: SendPaymentStatus,
41 #[serde(default = "Account::primary")]
46 pub account: Account,
47}
48
49impl Event for SendPaymentUpdateEvent {
50 const MODULE: Option<ModuleKind> = Some(fedimint_walletv2_common::KIND);
51 const KIND: EventKind = EventKind::from_static("payment-send-update");
52 const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
53}
54
55#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
57pub struct ReceivePaymentEvent {
58 pub operation_id: OperationId,
59 pub value: bitcoin::Amount,
60 pub fee: bitcoin::Amount,
61 pub address: Address<NetworkUnchecked>,
62 pub outpoint: Option<bitcoin::OutPoint>,
63 #[serde(default = "Account::primary")]
66 pub account: Account,
67}
68
69impl Event for ReceivePaymentEvent {
70 const MODULE: Option<ModuleKind> = Some(fedimint_walletv2_common::KIND);
71 const KIND: EventKind = EventKind::from_static("payment-receive");
72 const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
73}
74
75#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
77pub enum ReceivePaymentStatus {
78 Success,
80 Aborted,
82}
83
84#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
86pub struct ReceivePaymentUpdateEvent {
87 pub operation_id: OperationId,
88 pub status: ReceivePaymentStatus,
89 #[serde(default = "Account::primary")]
94 pub account: Account,
95}
96
97impl Event for ReceivePaymentUpdateEvent {
98 const MODULE: Option<ModuleKind> = Some(fedimint_walletv2_common::KIND);
99 const KIND: EventKind = EventKind::from_static("payment-receive-update");
100 const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
101}