fc0554c270e259ae8b5120e4d35ee6471fa5d2c2
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelInfo.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Details about a channel (both directions).
11  * Received within a channel announcement.
12  */
13 public class ChannelInfo : CommonBase {
14         internal ChannelInfo(object _dummy, long ptr) : base(ptr) { }
15         ~ChannelInfo() {
16                 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
17         }
18
19         /**
20          * Protocol features of a channel communicated during its announcement
21          */
22         public ChannelFeatures get_features() {
23                 long ret = bindings.ChannelInfo_get_features(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
28                 return ret_hu_conv;
29         }
30
31         /**
32          * Protocol features of a channel communicated during its announcement
33          */
34         public void set_features(org.ldk.structs.ChannelFeatures val) {
35                 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr);
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 if (this != null) { this.ptrs_to.AddLast(val); };
39         }
40
41         /**
42          * Source node of the first direction of a channel
43          */
44         public NodeId get_node_one() {
45                 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Source node of the first direction of a channel
55          */
56         public void set_node_one(org.ldk.structs.NodeId val) {
57                 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60                 if (this != null) { this.ptrs_to.AddLast(val); };
61         }
62
63         /**
64          * Details about the first direction of a channel
65          * 
66          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
67          */
68         public ChannelUpdateInfo get_one_to_two() {
69                 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
70                 GC.KeepAlive(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Details about the first direction of a channel
79          * 
80          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
81          */
82         public void set_one_to_two(org.ldk.structs.ChannelUpdateInfo val) {
83                 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr);
84                 GC.KeepAlive(this);
85                 GC.KeepAlive(val);
86                 if (this != null) { this.ptrs_to.AddLast(val); };
87         }
88
89         /**
90          * Source node of the second direction of a channel
91          */
92         public NodeId get_node_two() {
93                 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
94                 GC.KeepAlive(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Source node of the second direction of a channel
103          */
104         public void set_node_two(org.ldk.structs.NodeId val) {
105                 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr);
106                 GC.KeepAlive(this);
107                 GC.KeepAlive(val);
108                 if (this != null) { this.ptrs_to.AddLast(val); };
109         }
110
111         /**
112          * Details about the second direction of a channel
113          * 
114          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
115          */
116         public ChannelUpdateInfo get_two_to_one() {
117                 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
118                 GC.KeepAlive(this);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
122                 return ret_hu_conv;
123         }
124
125         /**
126          * Details about the second direction of a channel
127          * 
128          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
129          */
130         public void set_two_to_one(org.ldk.structs.ChannelUpdateInfo val) {
131                 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr);
132                 GC.KeepAlive(this);
133                 GC.KeepAlive(val);
134                 if (this != null) { this.ptrs_to.AddLast(val); };
135         }
136
137         /**
138          * The channel capacity as seen on-chain, if chain lookup is available.
139          */
140         public Option_u64Z get_capacity_sats() {
141                 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
142                 GC.KeepAlive(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * The channel capacity as seen on-chain, if chain lookup is available.
151          */
152         public void set_capacity_sats(org.ldk.structs.Option_u64Z val) {
153                 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
154                 GC.KeepAlive(this);
155                 GC.KeepAlive(val);
156         }
157
158         /**
159          * An initial announcement of the channel
160          * Mostly redundant with the data we store in fields explicitly.
161          * Everything else is useful only for sending out for initial routing sync.
162          * Not stored if contains excess data to prevent DoS.
163          * 
164          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
165          */
166         public ChannelAnnouncement get_announcement_message() {
167                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
168                 GC.KeepAlive(this);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
171                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
172                 return ret_hu_conv;
173         }
174
175         /**
176          * An initial announcement of the channel
177          * Mostly redundant with the data we store in fields explicitly.
178          * Everything else is useful only for sending out for initial routing sync.
179          * Not stored if contains excess data to prevent DoS.
180          * 
181          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
182          */
183         public void set_announcement_message(org.ldk.structs.ChannelAnnouncement val) {
184                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
185                 GC.KeepAlive(this);
186                 GC.KeepAlive(val);
187                 if (this != null) { this.ptrs_to.AddLast(val); };
188         }
189
190         internal long clone_ptr() {
191                 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
192                 GC.KeepAlive(this);
193                 return ret;
194         }
195
196         /**
197          * Creates a copy of the ChannelInfo
198          */
199         public ChannelInfo clone() {
200                 long ret = bindings.ChannelInfo_clone(this.ptr);
201                 GC.KeepAlive(this);
202                 if (ret >= 0 && ret <= 4096) { return null; }
203                 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
205                 return ret_hu_conv;
206         }
207
208         /**
209          * Checks if two ChannelInfos contain equal inner contents.
210          * This ignores pointers and is_owned flags and looks at the values in fields.
211          * Two objects with NULL inner values will be considered "equal" here.
212          */
213         public bool eq(org.ldk.structs.ChannelInfo b) {
214                 bool ret = bindings.ChannelInfo_eq(this.ptr, b == null ? 0 : b.ptr);
215                 GC.KeepAlive(this);
216                 GC.KeepAlive(b);
217                 if (this != null) { this.ptrs_to.AddLast(b); };
218                 return ret;
219         }
220
221         public override bool Equals(object o) {
222                 if (!(o is ChannelInfo)) return false;
223                 return this.eq((ChannelInfo)o);
224         }
225         /**
226          * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
227          * 
228          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
229          */
230         public ChannelUpdateInfo get_directional_info(byte channel_flags) {
231                 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
232                 GC.KeepAlive(this);
233                 GC.KeepAlive(channel_flags);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
242          */
243         public byte[] write() {
244                 byte[] ret = bindings.ChannelInfo_write(this.ptr);
245                 GC.KeepAlive(this);
246                 return ret;
247         }
248
249         /**
250          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
251          */
252         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
253                 long ret = bindings.ChannelInfo_read(ser);
254                 GC.KeepAlive(ser);
255                 if (ret >= 0 && ret <= 4096) { return null; }
256                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
257                 return ret_hu_conv;
258         }
259
260 }
261 } } }