1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#![allow(non_camel_case_types)]
// This file is autogenerated by `msggen`
// Do not edit it manually, your changes will be overwritten



use crate::primitives::*;
use serde::{Serialize, Deserialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Notification {
    #[serde(rename = "block_added")]
    BlockAdded(BlockAddedNotification),
    #[serde(rename = "channel_open_failed")]
    ChannelOpenFailed(ChannelOpenFailedNotification),
    #[serde(rename = "channel_opened")]
    ChannelOpened(ChannelOpenedNotification),
    #[serde(rename = "connect")]
    Connect(ConnectNotification),
    #[serde(rename = "custommsg")]
    CustomMsg(CustomMsgNotification),
}


#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BlockAddedNotification {
    pub hash: Sha256,
    pub height: u32,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ChannelOpenFailedNotification {
    pub channel_id: Sha256,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ChannelOpenedNotification {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<PublicKey>,
    pub channel_ready: bool,
    pub funding_msat: Amount,
    pub funding_txid: String,
}

#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum ConnectDirection {
    #[serde(rename = "in")]
    IN = 0,
    #[serde(rename = "out")]
    OUT = 1,
}

impl TryFrom<i32> for ConnectDirection {
    type Error = anyhow::Error;
    fn try_from(c: i32) -> Result<ConnectDirection, anyhow::Error> {
        match c {
    0 => Ok(ConnectDirection::IN),
    1 => Ok(ConnectDirection::OUT),
            o => Err(anyhow::anyhow!("Unknown variant {} for enum ConnectDirection", o)),
        }
    }
}

impl ToString for ConnectDirection {
    fn to_string(&self) -> String {
        match self {
            ConnectDirection::IN => "IN",
            ConnectDirection::OUT => "OUT",
        }.to_string()
    }
}

/// Type of connection (*torv2*/*torv3* only if **direction** is *out*)
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum ConnectAddressType {
    #[serde(rename = "local socket")]
    LOCAL_SOCKET = 0,
    #[serde(rename = "ipv4")]
    IPV4 = 1,
    #[serde(rename = "ipv6")]
    IPV6 = 2,
    #[serde(rename = "torv2")]
    TORV2 = 3,
    #[serde(rename = "torv3")]
    TORV3 = 4,
}

impl TryFrom<i32> for ConnectAddressType {
    type Error = anyhow::Error;
    fn try_from(c: i32) -> Result<ConnectAddressType, anyhow::Error> {
        match c {
    0 => Ok(ConnectAddressType::LOCAL_SOCKET),
    1 => Ok(ConnectAddressType::IPV4),
    2 => Ok(ConnectAddressType::IPV6),
    3 => Ok(ConnectAddressType::TORV2),
    4 => Ok(ConnectAddressType::TORV3),
            o => Err(anyhow::anyhow!("Unknown variant {} for enum ConnectAddressType", o)),
        }
    }
}

impl ToString for ConnectAddressType {
    fn to_string(&self) -> String {
        match self {
            ConnectAddressType::LOCAL_SOCKET => "LOCAL_SOCKET",
            ConnectAddressType::IPV4 => "IPV4",
            ConnectAddressType::IPV6 => "IPV6",
            ConnectAddressType::TORV2 => "TORV2",
            ConnectAddressType::TORV3 => "TORV3",
        }.to_string()
    }
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConnectAddress {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub port: Option<u16>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub socket: Option<String>,
    // Path `connect.address.type`
    #[serde(rename = "type")]
    pub item_type: ConnectAddressType,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ConnectNotification {
    // Path `connect.direction`
    pub direction: ConnectDirection,
    pub address: ConnectAddress,
    pub id: PublicKey,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CustomMsgNotification {
    pub payload: String,
    pub peer_id: PublicKey,
}

pub mod requests{
use serde::{Serialize, Deserialize};

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct StreamBlockAddedRequest {
    }

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct StreamChannelOpenFailedRequest {
    }

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct StreamChannelOpenedRequest {
    }

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct StreamConnectRequest {
    }

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct StreamCustomMsgRequest {
    }

}