Skip to main content

cln_rpc/
notifications.rs

1// This file is autogenerated by `msggen`
2// Do not edit it manually, your changes will be overwritten
3
4
5
6use crate::primitives::*;
7use serde::{Serialize, Deserialize};
8#[derive(Clone, Debug, Deserialize, Serialize)]
9pub enum Notification {
10    #[serde(rename = "balance_snapshot")]
11    BalanceSnapshot(BalanceSnapshotNotification),
12    #[serde(rename = "block_added")]
13    BlockAdded(BlockAddedNotification),
14    #[serde(rename = "channel_open_failed")]
15    ChannelOpenFailed(ChannelOpenFailedNotification),
16    #[serde(rename = "channel_opened")]
17    ChannelOpened(ChannelOpenedNotification),
18    #[serde(rename = "channel_state_changed")]
19    ChannelStateChanged(ChannelStateChangedNotification),
20    #[serde(rename = "connect")]
21    Connect(ConnectNotification),
22    #[serde(rename = "coin_movement")]
23    CoinMovement(CoinMovementNotification),
24    #[serde(rename = "custommsg")]
25    CustomMsg(CustomMsgNotification),
26    #[serde(rename = "deprecated_oneshot")]
27    DeprecatedOneshot(DeprecatedOneshotNotification),
28    #[serde(rename = "disconnect")]
29    Disconnect(DisconnectNotification),
30    #[serde(rename = "forward_event")]
31    ForwardEvent(ForwardEventNotification),
32    #[serde(rename = "invoice_creation")]
33    InvoiceCreation(InvoiceCreationNotification),
34    #[serde(rename = "invoice_payment")]
35    InvoicePayment(InvoicePaymentNotification),
36    #[serde(rename = "log")]
37    Log(LogNotification),
38    #[serde(rename = "onionmessage_forward_fail")]
39    OnionMessageForwardFail(OnionMessageForwardFailNotification),
40    #[serde(rename = "openchannel_peer_sigs")]
41    OpenChannelPeerSigs(OpenChannelPeerSigsNotification),
42    #[serde(rename = "plugin_started")]
43    PluginStarted(PluginStartedNotification),
44    #[serde(rename = "plugin_stopped")]
45    PluginStopped(PluginStoppedNotification),
46    #[serde(rename = "sendpay_failure")]
47    SendPayFailure(SendPayFailureNotification),
48    #[serde(rename = "sendpay_success")]
49    SendPaySuccess(SendPaySuccessNotification),
50    #[serde(rename = "shutdown")]
51    Shutdown(ShutdownNotification),
52    #[serde(rename = "warning")]
53    Warning(WarningNotification),
54    #[serde(rename = "pay_part_end")]
55    PayPartEnd(PayPartEndNotification),
56    #[serde(rename = "pay_part_start")]
57    PayPartStart(PayPartStartNotification),
58}
59
60
61#[derive(Clone, Debug, Deserialize, Serialize)]
62pub struct BalanceSnapshotAccounts {
63    pub account_id: String,
64    pub balance_msat: Amount,
65    pub coin_type: String,
66}
67
68#[derive(Clone, Debug, Deserialize, Serialize)]
69pub struct BalanceSnapshotNotification {
70    pub accounts: Vec<BalanceSnapshotAccounts>,
71    pub blockheight: u32,
72    pub node_id: PublicKey,
73    pub timestamp: u32,
74}
75
76#[derive(Clone, Debug, Deserialize, Serialize)]
77pub struct BlockAddedNotification {
78    pub hash: Sha256,
79    pub height: u32,
80}
81
82#[derive(Clone, Debug, Deserialize, Serialize)]
83pub struct ChannelOpenFailedNotification {
84    pub channel_id: Sha256,
85}
86
87#[derive(Clone, Debug, Deserialize, Serialize)]
88pub struct ChannelOpenedNotification {
89    pub channel_ready: bool,
90    pub funding_msat: Amount,
91    pub funding_txid: String,
92    pub id: PublicKey,
93}
94
95/// ['The cause of the state change.']
96#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
97#[allow(non_camel_case_types)]
98pub enum ChannelStateChangedCause {
99    #[serde(rename = "unknown")]
100    UNKNOWN = 0,
101    #[serde(rename = "local")]
102    LOCAL = 1,
103    #[serde(rename = "user")]
104    USER = 2,
105    #[serde(rename = "remote")]
106    REMOTE = 3,
107    #[serde(rename = "protocol")]
108    PROTOCOL = 4,
109    #[serde(rename = "onchain")]
110    ONCHAIN = 5,
111}
112
113impl TryFrom<i32> for ChannelStateChangedCause {
114    type Error = anyhow::Error;
115    fn try_from(c: i32) -> Result<ChannelStateChangedCause, anyhow::Error> {
116        match c {
117    0 => Ok(ChannelStateChangedCause::UNKNOWN),
118    1 => Ok(ChannelStateChangedCause::LOCAL),
119    2 => Ok(ChannelStateChangedCause::USER),
120    3 => Ok(ChannelStateChangedCause::REMOTE),
121    4 => Ok(ChannelStateChangedCause::PROTOCOL),
122    5 => Ok(ChannelStateChangedCause::ONCHAIN),
123            o => Err(anyhow::anyhow!("Unknown variant {} for enum ChannelStateChangedCause", o)),
124        }
125    }
126}
127
128impl ToString for ChannelStateChangedCause {
129    fn to_string(&self) -> String {
130        match self {
131            ChannelStateChangedCause::UNKNOWN => "UNKNOWN",
132            ChannelStateChangedCause::LOCAL => "LOCAL",
133            ChannelStateChangedCause::USER => "USER",
134            ChannelStateChangedCause::REMOTE => "REMOTE",
135            ChannelStateChangedCause::PROTOCOL => "PROTOCOL",
136            ChannelStateChangedCause::ONCHAIN => "ONCHAIN",
137        }.to_string()
138    }
139}
140
141#[derive(Clone, Debug, Deserialize, Serialize)]
142pub struct ChannelStateChangedNotification {
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub message: Option<String>,
145    #[serde(skip_serializing_if = "Option::is_none")]
146    pub old_state: Option<ChannelState>,
147    #[serde(skip_serializing_if = "Option::is_none")]
148    pub short_channel_id: Option<ShortChannelId>,
149    // Path `channel_state_changed.cause`
150    pub cause: ChannelStateChangedCause,
151    // Path `channel_state_changed.new_state`
152    pub new_state: ChannelState,
153    pub channel_id: Sha256,
154    pub peer_id: PublicKey,
155    pub timestamp: String,
156}
157
158/// ['Direction of the connection']
159#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
160#[allow(non_camel_case_types)]
161pub enum PeerConnectDirection {
162    #[serde(rename = "in")]
163    IN = 0,
164    #[serde(rename = "out")]
165    OUT = 1,
166}
167
168impl TryFrom<i32> for PeerConnectDirection {
169    type Error = anyhow::Error;
170    fn try_from(c: i32) -> Result<PeerConnectDirection, anyhow::Error> {
171        match c {
172    0 => Ok(PeerConnectDirection::IN),
173    1 => Ok(PeerConnectDirection::OUT),
174            o => Err(anyhow::anyhow!("Unknown variant {} for enum PeerConnectDirection", o)),
175        }
176    }
177}
178
179impl ToString for PeerConnectDirection {
180    fn to_string(&self) -> String {
181        match self {
182            PeerConnectDirection::IN => "IN",
183            PeerConnectDirection::OUT => "OUT",
184        }.to_string()
185    }
186}
187
188/// ['Type of connection (*torv2*/*torv3* only if **direction** is *out*)']
189#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
190#[allow(non_camel_case_types)]
191pub enum PeerConnectAddressType {
192    #[serde(rename = "local socket")]
193    LOCAL_SOCKET = 0,
194    #[serde(rename = "ipv4")]
195    IPV4 = 1,
196    #[serde(rename = "ipv6")]
197    IPV6 = 2,
198    #[serde(rename = "torv2")]
199    TORV2 = 3,
200    #[serde(rename = "torv3")]
201    TORV3 = 4,
202    #[serde(rename = "websocket")]
203    WEBSOCKET = 5,
204}
205
206impl TryFrom<i32> for PeerConnectAddressType {
207    type Error = anyhow::Error;
208    fn try_from(c: i32) -> Result<PeerConnectAddressType, anyhow::Error> {
209        match c {
210    0 => Ok(PeerConnectAddressType::LOCAL_SOCKET),
211    1 => Ok(PeerConnectAddressType::IPV4),
212    2 => Ok(PeerConnectAddressType::IPV6),
213    3 => Ok(PeerConnectAddressType::TORV2),
214    4 => Ok(PeerConnectAddressType::TORV3),
215    5 => Ok(PeerConnectAddressType::WEBSOCKET),
216            o => Err(anyhow::anyhow!("Unknown variant {} for enum PeerConnectAddressType", o)),
217        }
218    }
219}
220
221impl ToString for PeerConnectAddressType {
222    fn to_string(&self) -> String {
223        match self {
224            PeerConnectAddressType::LOCAL_SOCKET => "LOCAL_SOCKET",
225            PeerConnectAddressType::IPV4 => "IPV4",
226            PeerConnectAddressType::IPV6 => "IPV6",
227            PeerConnectAddressType::TORV2 => "TORV2",
228            PeerConnectAddressType::TORV3 => "TORV3",
229            PeerConnectAddressType::WEBSOCKET => "WEBSOCKET",
230        }.to_string()
231    }
232}
233
234#[derive(Clone, Debug, Deserialize, Serialize)]
235pub struct ConnectAddress {
236    #[serde(skip_serializing_if = "Option::is_none")]
237    pub address: Option<String>,
238    #[serde(skip_serializing_if = "Option::is_none")]
239    pub port: Option<u16>,
240    #[serde(skip_serializing_if = "Option::is_none")]
241    pub socket: Option<String>,
242    // Path `connect.address.type`
243    #[serde(rename = "type")]
244    pub item_type: PeerConnectAddressType,
245}
246
247#[derive(Clone, Debug, Deserialize, Serialize)]
248pub struct ConnectNotification {
249    // Path `connect.direction`
250    pub direction: PeerConnectDirection,
251    pub address: ConnectAddress,
252    pub id: PublicKey,
253}
254
255/// ['The primary movement tag.']
256#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
257#[allow(non_camel_case_types)]
258pub enum CoinMovementPrimaryTag {
259    #[serde(rename = "deposit")]
260    DEPOSIT = 0,
261    #[serde(rename = "withdrawal")]
262    WITHDRAWAL = 1,
263    #[serde(rename = "penalty")]
264    PENALTY = 2,
265    #[serde(rename = "channel_open")]
266    CHANNEL_OPEN = 3,
267    #[serde(rename = "channel_close")]
268    CHANNEL_CLOSE = 4,
269    #[serde(rename = "delayed_to_us")]
270    DELAYED_TO_US = 5,
271    #[serde(rename = "htlc_tx")]
272    HTLC_TX = 6,
273    #[serde(rename = "htlc_timeout")]
274    HTLC_TIMEOUT = 7,
275    #[serde(rename = "htlc_fulfill")]
276    HTLC_FULFILL = 8,
277    #[serde(rename = "to_wallet")]
278    TO_WALLET = 9,
279    #[serde(rename = "anchor")]
280    ANCHOR = 10,
281    #[serde(rename = "to_them")]
282    TO_THEM = 11,
283    #[serde(rename = "penalized")]
284    PENALIZED = 12,
285    #[serde(rename = "stolen")]
286    STOLEN = 13,
287    #[serde(rename = "ignored")]
288    IGNORED = 14,
289    #[serde(rename = "to_miner")]
290    TO_MINER = 15,
291    #[serde(rename = "invoice")]
292    INVOICE = 16,
293    #[serde(rename = "routed")]
294    ROUTED = 17,
295    #[serde(rename = "pushed")]
296    PUSHED = 18,
297    #[serde(rename = "lease_fee")]
298    LEASE_FEE = 19,
299    #[serde(rename = "channel_proposed")]
300    CHANNEL_PROPOSED = 20,
301    #[serde(rename = "penalty_adj")]
302    PENALTY_ADJ = 21,
303    #[serde(rename = "journal_entry")]
304    JOURNAL_ENTRY = 22,
305}
306
307impl TryFrom<i32> for CoinMovementPrimaryTag {
308    type Error = anyhow::Error;
309    fn try_from(c: i32) -> Result<CoinMovementPrimaryTag, anyhow::Error> {
310        match c {
311    0 => Ok(CoinMovementPrimaryTag::DEPOSIT),
312    1 => Ok(CoinMovementPrimaryTag::WITHDRAWAL),
313    2 => Ok(CoinMovementPrimaryTag::PENALTY),
314    3 => Ok(CoinMovementPrimaryTag::CHANNEL_OPEN),
315    4 => Ok(CoinMovementPrimaryTag::CHANNEL_CLOSE),
316    5 => Ok(CoinMovementPrimaryTag::DELAYED_TO_US),
317    6 => Ok(CoinMovementPrimaryTag::HTLC_TX),
318    7 => Ok(CoinMovementPrimaryTag::HTLC_TIMEOUT),
319    8 => Ok(CoinMovementPrimaryTag::HTLC_FULFILL),
320    9 => Ok(CoinMovementPrimaryTag::TO_WALLET),
321    10 => Ok(CoinMovementPrimaryTag::ANCHOR),
322    11 => Ok(CoinMovementPrimaryTag::TO_THEM),
323    12 => Ok(CoinMovementPrimaryTag::PENALIZED),
324    13 => Ok(CoinMovementPrimaryTag::STOLEN),
325    14 => Ok(CoinMovementPrimaryTag::IGNORED),
326    15 => Ok(CoinMovementPrimaryTag::TO_MINER),
327    16 => Ok(CoinMovementPrimaryTag::INVOICE),
328    17 => Ok(CoinMovementPrimaryTag::ROUTED),
329    18 => Ok(CoinMovementPrimaryTag::PUSHED),
330    19 => Ok(CoinMovementPrimaryTag::LEASE_FEE),
331    20 => Ok(CoinMovementPrimaryTag::CHANNEL_PROPOSED),
332    21 => Ok(CoinMovementPrimaryTag::PENALTY_ADJ),
333    22 => Ok(CoinMovementPrimaryTag::JOURNAL_ENTRY),
334            o => Err(anyhow::anyhow!("Unknown variant {} for enum CoinMovementPrimaryTag", o)),
335        }
336    }
337}
338
339impl ToString for CoinMovementPrimaryTag {
340    fn to_string(&self) -> String {
341        match self {
342            CoinMovementPrimaryTag::DEPOSIT => "DEPOSIT",
343            CoinMovementPrimaryTag::WITHDRAWAL => "WITHDRAWAL",
344            CoinMovementPrimaryTag::PENALTY => "PENALTY",
345            CoinMovementPrimaryTag::CHANNEL_OPEN => "CHANNEL_OPEN",
346            CoinMovementPrimaryTag::CHANNEL_CLOSE => "CHANNEL_CLOSE",
347            CoinMovementPrimaryTag::DELAYED_TO_US => "DELAYED_TO_US",
348            CoinMovementPrimaryTag::HTLC_TX => "HTLC_TX",
349            CoinMovementPrimaryTag::HTLC_TIMEOUT => "HTLC_TIMEOUT",
350            CoinMovementPrimaryTag::HTLC_FULFILL => "HTLC_FULFILL",
351            CoinMovementPrimaryTag::TO_WALLET => "TO_WALLET",
352            CoinMovementPrimaryTag::ANCHOR => "ANCHOR",
353            CoinMovementPrimaryTag::TO_THEM => "TO_THEM",
354            CoinMovementPrimaryTag::PENALIZED => "PENALIZED",
355            CoinMovementPrimaryTag::STOLEN => "STOLEN",
356            CoinMovementPrimaryTag::IGNORED => "IGNORED",
357            CoinMovementPrimaryTag::TO_MINER => "TO_MINER",
358            CoinMovementPrimaryTag::INVOICE => "INVOICE",
359            CoinMovementPrimaryTag::ROUTED => "ROUTED",
360            CoinMovementPrimaryTag::PUSHED => "PUSHED",
361            CoinMovementPrimaryTag::LEASE_FEE => "LEASE_FEE",
362            CoinMovementPrimaryTag::CHANNEL_PROPOSED => "CHANNEL_PROPOSED",
363            CoinMovementPrimaryTag::PENALTY_ADJ => "PENALTY_ADJ",
364            CoinMovementPrimaryTag::JOURNAL_ENTRY => "JOURNAL_ENTRY",
365        }.to_string()
366    }
367}
368
369/// ['Whether this is a channel or chain movement.']
370#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
371#[allow(non_camel_case_types)]
372pub enum CoinMovementType {
373    #[serde(rename = "channel_mvt")]
374    CHANNEL_MVT = 0,
375    #[serde(rename = "chain_mvt")]
376    CHAIN_MVT = 1,
377}
378
379impl TryFrom<i32> for CoinMovementType {
380    type Error = anyhow::Error;
381    fn try_from(c: i32) -> Result<CoinMovementType, anyhow::Error> {
382        match c {
383    0 => Ok(CoinMovementType::CHANNEL_MVT),
384    1 => Ok(CoinMovementType::CHAIN_MVT),
385            o => Err(anyhow::anyhow!("Unknown variant {} for enum CoinMovementType", o)),
386        }
387    }
388}
389
390impl ToString for CoinMovementType {
391    fn to_string(&self) -> String {
392        match self {
393            CoinMovementType::CHANNEL_MVT => "CHANNEL_MVT",
394            CoinMovementType::CHAIN_MVT => "CHAIN_MVT",
395        }.to_string()
396    }
397}
398
399#[derive(Clone, Debug, Deserialize, Serialize)]
400pub struct CoinMovementNotification {
401    #[deprecated]
402    #[serde(skip_serializing_if = "Option::is_none")]
403    pub txid: Option<String>,
404    #[deprecated]
405    #[serde(skip_serializing_if = "Option::is_none")]
406    pub utxo_txid: Option<String>,
407    #[deprecated]
408    #[serde(skip_serializing_if = "Option::is_none")]
409    pub vout: Option<u32>,
410    #[deprecated]
411    #[serde(skip_serializing_if = "crate::is_none_or_empty")]
412    pub tags: Option<Vec<String>>,
413    #[serde(skip_serializing_if = "Option::is_none")]
414    pub blockheight: Option<u32>,
415    #[serde(skip_serializing_if = "Option::is_none")]
416    pub created_index: Option<u64>,
417    #[serde(skip_serializing_if = "Option::is_none")]
418    pub fees_msat: Option<Amount>,
419    #[serde(skip_serializing_if = "Option::is_none")]
420    pub group_id: Option<u64>,
421    #[serde(skip_serializing_if = "Option::is_none")]
422    pub originating_account: Option<String>,
423    #[serde(skip_serializing_if = "Option::is_none")]
424    pub output_count: Option<u32>,
425    #[serde(skip_serializing_if = "Option::is_none")]
426    pub output_msat: Option<Amount>,
427    #[serde(skip_serializing_if = "Option::is_none")]
428    pub part_id: Option<u64>,
429    #[serde(skip_serializing_if = "Option::is_none")]
430    pub payment_hash: Option<Sha256>,
431    #[serde(skip_serializing_if = "Option::is_none")]
432    pub peer_id: Option<PublicKey>,
433    #[serde(skip_serializing_if = "Option::is_none")]
434    pub primary_tag: Option<CoinMovementPrimaryTag>,
435    #[serde(skip_serializing_if = "Option::is_none")]
436    pub spending_txid: Option<String>,
437    #[serde(skip_serializing_if = "Option::is_none")]
438    pub utxo: Option<Outpoint>,
439    #[serde(skip_serializing_if = "crate::is_none_or_empty")]
440    pub extra_tags: Option<Vec<String>>,
441    // Path `coin_movement.type`
442    #[serde(rename = "type")]
443    pub item_type: CoinMovementType,
444    pub account_id: String,
445    pub coin_type: String,
446    pub credit_msat: Amount,
447    pub debit_msat: Amount,
448    pub node_id: PublicKey,
449    pub timestamp: u64,
450    pub version: u32,
451}
452
453#[derive(Clone, Debug, Deserialize, Serialize)]
454pub struct CustomMsgNotification {
455    pub payload: String,
456    pub peer_id: PublicKey,
457}
458
459#[derive(Clone, Debug, Deserialize, Serialize)]
460pub struct DeprecatedOneshotNotification {
461    pub deprecated_ok: bool,
462}
463
464#[derive(Clone, Debug, Deserialize, Serialize)]
465pub struct DisconnectNotification {
466    pub id: PublicKey,
467}
468
469/// ['The onion format used for the forward, if known.']
470#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
471#[allow(non_camel_case_types)]
472pub enum ForwardEventStyle {
473    #[serde(rename = "legacy")]
474    LEGACY = 0,
475    #[serde(rename = "tlv")]
476    TLV = 1,
477}
478
479impl TryFrom<i32> for ForwardEventStyle {
480    type Error = anyhow::Error;
481    fn try_from(c: i32) -> Result<ForwardEventStyle, anyhow::Error> {
482        match c {
483    0 => Ok(ForwardEventStyle::LEGACY),
484    1 => Ok(ForwardEventStyle::TLV),
485            o => Err(anyhow::anyhow!("Unknown variant {} for enum ForwardEventStyle", o)),
486        }
487    }
488}
489
490impl ToString for ForwardEventStyle {
491    fn to_string(&self) -> String {
492        match self {
493            ForwardEventStyle::LEGACY => "LEGACY",
494            ForwardEventStyle::TLV => "TLV",
495        }.to_string()
496    }
497}
498
499/// ['The current forwarding status.']
500#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
501#[allow(non_camel_case_types)]
502pub enum ForwardEventStatus {
503    #[serde(rename = "offered")]
504    OFFERED = 0,
505    #[serde(rename = "settled")]
506    SETTLED = 1,
507    #[serde(rename = "local_failed")]
508    LOCAL_FAILED = 2,
509    #[serde(rename = "failed")]
510    FAILED = 3,
511}
512
513impl TryFrom<i32> for ForwardEventStatus {
514    type Error = anyhow::Error;
515    fn try_from(c: i32) -> Result<ForwardEventStatus, anyhow::Error> {
516        match c {
517    0 => Ok(ForwardEventStatus::OFFERED),
518    1 => Ok(ForwardEventStatus::SETTLED),
519    2 => Ok(ForwardEventStatus::LOCAL_FAILED),
520    3 => Ok(ForwardEventStatus::FAILED),
521            o => Err(anyhow::anyhow!("Unknown variant {} for enum ForwardEventStatus", o)),
522        }
523    }
524}
525
526impl ToString for ForwardEventStatus {
527    fn to_string(&self) -> String {
528        match self {
529            ForwardEventStatus::OFFERED => "OFFERED",
530            ForwardEventStatus::SETTLED => "SETTLED",
531            ForwardEventStatus::LOCAL_FAILED => "LOCAL_FAILED",
532            ForwardEventStatus::FAILED => "FAILED",
533        }.to_string()
534    }
535}
536
537#[derive(Clone, Debug, Deserialize, Serialize)]
538pub struct ForwardEventNotification {
539    #[serde(skip_serializing_if = "Option::is_none")]
540    pub failcode: Option<u32>,
541    #[serde(skip_serializing_if = "Option::is_none")]
542    pub failreason: Option<String>,
543    #[serde(skip_serializing_if = "Option::is_none")]
544    pub fee_msat: Option<Amount>,
545    #[serde(skip_serializing_if = "Option::is_none")]
546    pub out_channel: Option<ShortChannelId>,
547    #[serde(skip_serializing_if = "Option::is_none")]
548    pub out_msat: Option<Amount>,
549    #[serde(skip_serializing_if = "Option::is_none")]
550    pub resolved_time: Option<f64>,
551    #[serde(skip_serializing_if = "Option::is_none")]
552    pub style: Option<ForwardEventStyle>,
553    // Path `forward_event.status`
554    pub status: ForwardEventStatus,
555    pub in_channel: ShortChannelId,
556    pub in_msat: Amount,
557    pub payment_hash: Sha256,
558    pub received_time: f64,
559}
560
561#[derive(Clone, Debug, Deserialize, Serialize)]
562pub struct InvoiceCreationNotification {
563    #[serde(skip_serializing_if = "Option::is_none")]
564    pub msat: Option<Amount>,
565    pub label: String,
566    pub preimage: Secret,
567}
568
569#[derive(Clone, Debug, Deserialize, Serialize)]
570pub struct InvoicePaymentNotification {
571    #[serde(skip_serializing_if = "Option::is_none")]
572    pub outpoint: Option<Outpoint>,
573    pub label: String,
574    pub msat: Amount,
575    pub preimage: Secret,
576}
577
578/// ['The log level of the emitted message.']
579#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
580#[allow(non_camel_case_types)]
581pub enum LogLevel {
582    #[serde(rename = "io")]
583    IO = 0,
584    #[serde(rename = "trace")]
585    TRACE = 1,
586    #[serde(rename = "debug")]
587    DEBUG = 2,
588    #[serde(rename = "info")]
589    INFO = 3,
590    #[serde(rename = "unusual")]
591    UNUSUAL = 4,
592    #[serde(rename = "broken")]
593    BROKEN = 5,
594}
595
596impl TryFrom<i32> for LogLevel {
597    type Error = anyhow::Error;
598    fn try_from(c: i32) -> Result<LogLevel, anyhow::Error> {
599        match c {
600    0 => Ok(LogLevel::IO),
601    1 => Ok(LogLevel::TRACE),
602    2 => Ok(LogLevel::DEBUG),
603    3 => Ok(LogLevel::INFO),
604    4 => Ok(LogLevel::UNUSUAL),
605    5 => Ok(LogLevel::BROKEN),
606            o => Err(anyhow::anyhow!("Unknown variant {} for enum LogLevel", o)),
607        }
608    }
609}
610
611impl ToString for LogLevel {
612    fn to_string(&self) -> String {
613        match self {
614            LogLevel::IO => "IO",
615            LogLevel::TRACE => "TRACE",
616            LogLevel::DEBUG => "DEBUG",
617            LogLevel::INFO => "INFO",
618            LogLevel::UNUSUAL => "UNUSUAL",
619            LogLevel::BROKEN => "BROKEN",
620        }.to_string()
621    }
622}
623
624#[derive(Clone, Debug, Deserialize, Serialize)]
625pub struct LogNotification {
626    // Path `log.level`
627    pub level: LogLevel,
628    pub log: String,
629    pub source: String,
630    pub time: String,
631    pub timestamp: String,
632}
633
634#[derive(Clone, Debug, Deserialize, Serialize)]
635pub struct OnionMessageForwardFailNotification {
636    #[serde(skip_serializing_if = "Option::is_none")]
637    pub next_node_id: Option<PublicKey>,
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub next_short_channel_id_dir: Option<ShortChannelIdDir>,
640    #[serde(skip_serializing_if = "Option::is_none")]
641    pub outgoing: Option<String>,
642    pub incoming: String,
643    pub path_key: PublicKey,
644    pub source: PublicKey,
645}
646
647#[derive(Clone, Debug, Deserialize, Serialize)]
648pub struct OpenChannelPeerSigsNotification {
649    pub channel_id: Sha256,
650    pub signed_psbt: String,
651}
652
653#[derive(Clone, Debug, Deserialize, Serialize)]
654pub struct PluginStartedNotification {
655    pub methods: Vec<String>,
656    pub plugin_name: String,
657    pub plugin_path: String,
658}
659
660#[derive(Clone, Debug, Deserialize, Serialize)]
661pub struct PluginStoppedNotification {
662    pub methods: Vec<String>,
663    pub plugin_name: String,
664    pub plugin_path: String,
665}
666
667/// ['The terminal status for a failed sendpay notification.']
668#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
669#[allow(non_camel_case_types)]
670pub enum SendpayFailureDataStatus {
671    #[serde(rename = "failed")]
672    FAILED = 0,
673    #[serde(rename = "pending")]
674    PENDING = 1,
675    #[serde(rename = "complete")]
676    COMPLETE = 2,
677}
678
679impl TryFrom<i32> for SendpayFailureDataStatus {
680    type Error = anyhow::Error;
681    fn try_from(c: i32) -> Result<SendpayFailureDataStatus, anyhow::Error> {
682        match c {
683    0 => Ok(SendpayFailureDataStatus::FAILED),
684    1 => Ok(SendpayFailureDataStatus::PENDING),
685    2 => Ok(SendpayFailureDataStatus::COMPLETE),
686            o => Err(anyhow::anyhow!("Unknown variant {} for enum SendpayFailureDataStatus", o)),
687        }
688    }
689}
690
691impl ToString for SendpayFailureDataStatus {
692    fn to_string(&self) -> String {
693        match self {
694            SendpayFailureDataStatus::FAILED => "FAILED",
695            SendpayFailureDataStatus::PENDING => "PENDING",
696            SendpayFailureDataStatus::COMPLETE => "COMPLETE",
697        }.to_string()
698    }
699}
700
701#[derive(Clone, Debug, Deserialize, Serialize)]
702pub struct SendpayFailureData {
703    #[serde(skip_serializing_if = "Option::is_none")]
704    pub amount_msat: Option<Amount>,
705    #[serde(skip_serializing_if = "Option::is_none")]
706    pub amount_sent_msat: Option<Amount>,
707    #[serde(skip_serializing_if = "Option::is_none")]
708    pub bolt11: Option<String>,
709    #[serde(skip_serializing_if = "Option::is_none")]
710    pub bolt12: Option<String>,
711    #[serde(skip_serializing_if = "Option::is_none")]
712    pub completed_at: Option<u64>,
713    #[serde(skip_serializing_if = "Option::is_none")]
714    pub created_at: Option<u64>,
715    #[serde(skip_serializing_if = "Option::is_none")]
716    pub created_index: Option<u64>,
717    #[serde(skip_serializing_if = "Option::is_none")]
718    pub description: Option<String>,
719    #[serde(skip_serializing_if = "Option::is_none")]
720    pub destination: Option<PublicKey>,
721    #[serde(skip_serializing_if = "Option::is_none")]
722    pub erring_channel: Option<ShortChannelId>,
723    #[serde(skip_serializing_if = "Option::is_none")]
724    pub erring_direction: Option<u32>,
725    #[serde(skip_serializing_if = "Option::is_none")]
726    pub erring_index: Option<u32>,
727    #[serde(skip_serializing_if = "Option::is_none")]
728    pub erring_node: Option<PublicKey>,
729    #[serde(skip_serializing_if = "Option::is_none")]
730    pub erroronion: Option<String>,
731    #[serde(skip_serializing_if = "Option::is_none")]
732    pub failcode: Option<u32>,
733    #[serde(skip_serializing_if = "Option::is_none")]
734    pub failcodename: Option<String>,
735    #[serde(skip_serializing_if = "Option::is_none")]
736    pub groupid: Option<u64>,
737    #[serde(skip_serializing_if = "Option::is_none")]
738    pub id: Option<u64>,
739    #[serde(skip_serializing_if = "Option::is_none")]
740    pub label: Option<String>,
741    #[serde(skip_serializing_if = "Option::is_none")]
742    pub onionreply: Option<String>,
743    #[serde(skip_serializing_if = "Option::is_none")]
744    pub partid: Option<u64>,
745    #[serde(skip_serializing_if = "Option::is_none")]
746    pub payment_hash: Option<Sha256>,
747    #[serde(skip_serializing_if = "Option::is_none")]
748    pub payment_preimage: Option<Secret>,
749    #[serde(skip_serializing_if = "Option::is_none")]
750    pub raw_message: Option<String>,
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub status: Option<SendpayFailureDataStatus>,
753    #[serde(skip_serializing_if = "Option::is_none")]
754    pub updated_index: Option<u64>,
755}
756
757#[derive(Clone, Debug, Deserialize, Serialize)]
758pub struct SendPayFailureNotification {
759    pub code: i64,
760    pub data: SendpayFailureData,
761    pub message: String,
762}
763
764/// ['The terminal status for a successful sendpay notification.']
765#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
766#[allow(non_camel_case_types)]
767pub enum SendpaySuccessStatus {
768    #[serde(rename = "complete")]
769    COMPLETE = 0,
770}
771
772impl TryFrom<i32> for SendpaySuccessStatus {
773    type Error = anyhow::Error;
774    fn try_from(c: i32) -> Result<SendpaySuccessStatus, anyhow::Error> {
775        match c {
776    0 => Ok(SendpaySuccessStatus::COMPLETE),
777            o => Err(anyhow::anyhow!("Unknown variant {} for enum SendpaySuccessStatus", o)),
778        }
779    }
780}
781
782impl ToString for SendpaySuccessStatus {
783    fn to_string(&self) -> String {
784        match self {
785            SendpaySuccessStatus::COMPLETE => "COMPLETE",
786        }.to_string()
787    }
788}
789
790#[derive(Clone, Debug, Deserialize, Serialize)]
791pub struct SendPaySuccessNotification {
792    #[serde(skip_serializing_if = "Option::is_none")]
793    pub amount_msat: Option<Amount>,
794    #[serde(skip_serializing_if = "Option::is_none")]
795    pub bolt11: Option<String>,
796    #[serde(skip_serializing_if = "Option::is_none")]
797    pub bolt12: Option<String>,
798    #[serde(skip_serializing_if = "Option::is_none")]
799    pub completed_at: Option<u64>,
800    #[serde(skip_serializing_if = "Option::is_none")]
801    pub description: Option<String>,
802    #[serde(skip_serializing_if = "Option::is_none")]
803    pub destination: Option<PublicKey>,
804    #[serde(skip_serializing_if = "Option::is_none")]
805    pub erroronion: Option<String>,
806    #[serde(skip_serializing_if = "Option::is_none")]
807    pub label: Option<String>,
808    #[serde(skip_serializing_if = "Option::is_none")]
809    pub partid: Option<u64>,
810    #[serde(skip_serializing_if = "Option::is_none")]
811    pub payment_preimage: Option<Secret>,
812    #[serde(skip_serializing_if = "Option::is_none")]
813    pub updated_index: Option<u64>,
814    // Path `sendpay_success.status`
815    pub status: SendpaySuccessStatus,
816    pub amount_sent_msat: Amount,
817    pub created_at: u64,
818    pub created_index: u64,
819    pub groupid: u64,
820    pub id: u64,
821    pub payment_hash: Sha256,
822}
823
824#[derive(Clone, Debug, Deserialize, Serialize)]
825pub struct ShutdownNotification {
826}
827
828/// ['The log level of the warning notification.']
829#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
830#[allow(non_camel_case_types)]
831pub enum WarningLevel {
832    #[serde(rename = "warn")]
833    WARN = 0,
834    #[serde(rename = "error")]
835    ERROR = 1,
836}
837
838impl TryFrom<i32> for WarningLevel {
839    type Error = anyhow::Error;
840    fn try_from(c: i32) -> Result<WarningLevel, anyhow::Error> {
841        match c {
842    0 => Ok(WarningLevel::WARN),
843    1 => Ok(WarningLevel::ERROR),
844            o => Err(anyhow::anyhow!("Unknown variant {} for enum WarningLevel", o)),
845        }
846    }
847}
848
849impl ToString for WarningLevel {
850    fn to_string(&self) -> String {
851        match self {
852            WarningLevel::WARN => "WARN",
853            WarningLevel::ERROR => "ERROR",
854        }.to_string()
855    }
856}
857
858#[derive(Clone, Debug, Deserialize, Serialize)]
859pub struct WarningNotification {
860    // Path `warning.level`
861    pub level: WarningLevel,
862    pub log: String,
863    pub source: String,
864    pub time: String,
865    pub timestamp: String,
866}
867
868/// ['Whether the payment part succeeded or failed.']
869#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
870#[allow(non_camel_case_types)]
871pub enum PayPartEndStatus {
872    #[serde(rename = "success")]
873    SUCCESS = 0,
874    #[serde(rename = "failure")]
875    FAILURE = 1,
876}
877
878impl TryFrom<i32> for PayPartEndStatus {
879    type Error = anyhow::Error;
880    fn try_from(c: i32) -> Result<PayPartEndStatus, anyhow::Error> {
881        match c {
882    0 => Ok(PayPartEndStatus::SUCCESS),
883    1 => Ok(PayPartEndStatus::FAILURE),
884            o => Err(anyhow::anyhow!("Unknown variant {} for enum PayPartEndStatus", o)),
885        }
886    }
887}
888
889impl ToString for PayPartEndStatus {
890    fn to_string(&self) -> String {
891        match self {
892            PayPartEndStatus::SUCCESS => "SUCCESS",
893            PayPartEndStatus::FAILURE => "FAILURE",
894        }.to_string()
895    }
896}
897
898#[derive(Clone, Debug, Deserialize, Serialize)]
899pub struct PayPartEndNotification {
900    #[serde(skip_serializing_if = "Option::is_none")]
901    pub error_code: Option<u32>,
902    #[serde(skip_serializing_if = "Option::is_none")]
903    pub error_message: Option<String>,
904    #[serde(skip_serializing_if = "Option::is_none")]
905    pub failed_direction: Option<u32>,
906    #[serde(skip_serializing_if = "Option::is_none")]
907    pub failed_msg: Option<String>,
908    #[serde(skip_serializing_if = "Option::is_none")]
909    pub failed_node_id: Option<PublicKey>,
910    #[serde(skip_serializing_if = "Option::is_none")]
911    pub failed_short_channel_id: Option<ShortChannelId>,
912    // Path `pay_part_end.status`
913    pub status: PayPartEndStatus,
914    pub duration: f64,
915    pub groupid: u64,
916    pub partid: u64,
917    pub payment_hash: Sha256,
918}
919
920#[derive(Clone, Debug, Deserialize, Serialize)]
921pub struct PayPartStartHops {
922    pub channel_in_msat: Amount,
923    pub channel_out_msat: Amount,
924    pub direction: u32,
925    pub next_node: PublicKey,
926    pub short_channel_id: ShortChannelId,
927}
928
929#[derive(Clone, Debug, Deserialize, Serialize)]
930pub struct PayPartStartNotification {
931    pub attempt_msat: Amount,
932    pub groupid: u64,
933    pub hops: Vec<PayPartStartHops>,
934    pub partid: u64,
935    pub payment_hash: Sha256,
936    pub total_payment_msat: Amount,
937}
938
939pub mod requests{
940use serde::{Serialize, Deserialize};
941
942    #[derive(Clone, Debug, Deserialize, Serialize)]
943    pub struct StreamBalanceSnapshotRequest {
944    }
945
946    #[derive(Clone, Debug, Deserialize, Serialize)]
947    pub struct StreamBlockAddedRequest {
948    }
949
950    #[derive(Clone, Debug, Deserialize, Serialize)]
951    pub struct StreamChannelOpenFailedRequest {
952    }
953
954    #[derive(Clone, Debug, Deserialize, Serialize)]
955    pub struct StreamChannelOpenedRequest {
956    }
957
958    #[derive(Clone, Debug, Deserialize, Serialize)]
959    pub struct StreamChannelStateChangedRequest {
960    }
961
962    #[derive(Clone, Debug, Deserialize, Serialize)]
963    pub struct StreamConnectRequest {
964    }
965
966    #[derive(Clone, Debug, Deserialize, Serialize)]
967    pub struct StreamCoinMovementRequest {
968    }
969
970    #[derive(Clone, Debug, Deserialize, Serialize)]
971    pub struct StreamCustomMsgRequest {
972    }
973
974    #[derive(Clone, Debug, Deserialize, Serialize)]
975    pub struct StreamDeprecatedOneshotRequest {
976    }
977
978    #[derive(Clone, Debug, Deserialize, Serialize)]
979    pub struct StreamDisconnectRequest {
980    }
981
982    #[derive(Clone, Debug, Deserialize, Serialize)]
983    pub struct StreamForwardEventRequest {
984    }
985
986    #[derive(Clone, Debug, Deserialize, Serialize)]
987    pub struct StreamInvoiceCreationRequest {
988    }
989
990    #[derive(Clone, Debug, Deserialize, Serialize)]
991    pub struct StreamInvoicePaymentRequest {
992    }
993
994    #[derive(Clone, Debug, Deserialize, Serialize)]
995    pub struct StreamLogRequest {
996    }
997
998    #[derive(Clone, Debug, Deserialize, Serialize)]
999    pub struct StreamOnionMessageForwardFailRequest {
1000    }
1001
1002    #[derive(Clone, Debug, Deserialize, Serialize)]
1003    pub struct StreamOpenChannelPeerSigsRequest {
1004    }
1005
1006    #[derive(Clone, Debug, Deserialize, Serialize)]
1007    pub struct StreamPluginStartedRequest {
1008    }
1009
1010    #[derive(Clone, Debug, Deserialize, Serialize)]
1011    pub struct StreamPluginStoppedRequest {
1012    }
1013
1014    #[derive(Clone, Debug, Deserialize, Serialize)]
1015    pub struct StreamSendPayFailureRequest {
1016    }
1017
1018    #[derive(Clone, Debug, Deserialize, Serialize)]
1019    pub struct StreamSendPaySuccessRequest {
1020    }
1021
1022    #[derive(Clone, Debug, Deserialize, Serialize)]
1023    pub struct StreamShutdownRequest {
1024    }
1025
1026    #[derive(Clone, Debug, Deserialize, Serialize)]
1027    pub struct StreamWarningRequest {
1028    }
1029
1030    #[derive(Clone, Debug, Deserialize, Serialize)]
1031    pub struct StreamPayPartEndRequest {
1032    }
1033
1034    #[derive(Clone, Debug, Deserialize, Serialize)]
1035    pub struct StreamPayPartStartRequest {
1036    }
1037
1038}