[C#] Update auto-generated C# bindings
[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                 if (this != null) { this.ptrs_to.AddLast(val); };
157         }
158
159         /**
160          * An initial announcement of the channel
161          * Mostly redundant with the data we store in fields explicitly.
162          * Everything else is useful only for sending out for initial routing sync.
163          * Not stored if contains excess data to prevent DoS.
164          * 
165          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
166          */
167         public ChannelAnnouncement get_announcement_message() {
168                 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
169                 GC.KeepAlive(this);
170                 if (ret >= 0 && ret <= 4096) { return null; }
171                 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
172                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
173                 return ret_hu_conv;
174         }
175
176         /**
177          * An initial announcement of the channel
178          * Mostly redundant with the data we store in fields explicitly.
179          * Everything else is useful only for sending out for initial routing sync.
180          * Not stored if contains excess data to prevent DoS.
181          * 
182          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
183          */
184         public void set_announcement_message(org.ldk.structs.ChannelAnnouncement val) {
185                 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
186                 GC.KeepAlive(this);
187                 GC.KeepAlive(val);
188                 if (this != null) { this.ptrs_to.AddLast(val); };
189         }
190
191         internal long clone_ptr() {
192                 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
193                 GC.KeepAlive(this);
194                 return ret;
195         }
196
197         /**
198          * Creates a copy of the ChannelInfo
199          */
200         public ChannelInfo clone() {
201                 long ret = bindings.ChannelInfo_clone(this.ptr);
202                 GC.KeepAlive(this);
203                 if (ret >= 0 && ret <= 4096) { return null; }
204                 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
205                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
206                 return ret_hu_conv;
207         }
208
209         /**
210          * Checks if two ChannelInfos contain equal inner contents.
211          * This ignores pointers and is_owned flags and looks at the values in fields.
212          * Two objects with NULL inner values will be considered "equal" here.
213          */
214         public bool eq(org.ldk.structs.ChannelInfo b) {
215                 bool ret = bindings.ChannelInfo_eq(this.ptr, b == null ? 0 : b.ptr);
216                 GC.KeepAlive(this);
217                 GC.KeepAlive(b);
218                 if (this != null) { this.ptrs_to.AddLast(b); };
219                 return ret;
220         }
221
222         public override bool Equals(object o) {
223                 if (!(o is ChannelInfo)) return false;
224                 return this.eq((ChannelInfo)o);
225         }
226         /**
227          * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
228          * 
229          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
230          */
231         public ChannelUpdateInfo get_directional_info(byte channel_flags) {
232                 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
233                 GC.KeepAlive(this);
234                 GC.KeepAlive(channel_flags);
235                 if (ret >= 0 && ret <= 4096) { return null; }
236                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
237                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
238                 return ret_hu_conv;
239         }
240
241         /**
242          * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
243          */
244         public byte[] write() {
245                 long ret = bindings.ChannelInfo_write(this.ptr);
246                 GC.KeepAlive(this);
247                 if (ret >= 0 && ret <= 4096) { return null; }
248                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
249                 return ret_conv;
250         }
251
252         /**
253          * Read a ChannelInfo from a byte array, created by ChannelInfo_write
254          */
255         public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
256                 long ret = bindings.ChannelInfo_read(InternalUtils.encodeUint8Array(ser));
257                 GC.KeepAlive(ser);
258                 if (ret >= 0 && ret <= 4096) { return null; }
259                 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);
260                 return ret_hu_conv;
261         }
262
263 }
264 } } }