[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / NodeAnnouncementInfo.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  * Information received in the latest node_announcement from this node.
11  */
12 public class NodeAnnouncementInfo : CommonBase {
13         internal NodeAnnouncementInfo(object _dummy, long ptr) : base(ptr) { }
14         ~NodeAnnouncementInfo() {
15                 if (ptr != 0) { bindings.NodeAnnouncementInfo_free(ptr); }
16         }
17
18         /**
19          * Protocol features the node announced support for
20          */
21         public NodeFeatures get_features() {
22                 long ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * Protocol features the node announced support for
32          */
33         public void set_features(org.ldk.structs.NodeFeatures val) {
34                 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr);
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37                 if (this != null) { this.ptrs_to.AddLast(val); };
38         }
39
40         /**
41          * When the last known update to the node state was issued.
42          * Value is opaque, as set in the announcement.
43          */
44         public int get_last_update() {
45                 int ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * When the last known update to the node state was issued.
52          * Value is opaque, as set in the announcement.
53          */
54         public void set_last_update(int val) {
55                 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * Color assigned to the node
62          */
63         public byte[] get_rgb() {
64                 long ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
68                 return ret_conv;
69         }
70
71         /**
72          * Color assigned to the node
73          */
74         public void set_rgb(byte[] val) {
75                 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 3)));
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * Moniker assigned to the node.
82          * May be invalid or malicious (eg control chars),
83          * should not be exposed to the user.
84          */
85         public NodeAlias get_alias() {
86                 long ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
87                 GC.KeepAlive(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Moniker assigned to the node.
96          * May be invalid or malicious (eg control chars),
97          * should not be exposed to the user.
98          */
99         public void set_alias(org.ldk.structs.NodeAlias val) {
100                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val == null ? 0 : val.ptr);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(val);
103                 if (this != null) { this.ptrs_to.AddLast(val); };
104         }
105
106         /**
107          * An initial announcement of the node
108          * Mostly redundant with the data we store in fields explicitly.
109          * Everything else is useful only for sending out for initial routing sync.
110          * Not stored if contains excess data to prevent DoS.
111          * 
112          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
113          */
114         public NodeAnnouncement get_announcement_message() {
115                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
116                 GC.KeepAlive(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * An initial announcement of the node
125          * Mostly redundant with the data we store in fields explicitly.
126          * Everything else is useful only for sending out for initial routing sync.
127          * Not stored if contains excess data to prevent DoS.
128          * 
129          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
130          */
131         public void set_announcement_message(org.ldk.structs.NodeAnnouncement val) {
132                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
133                 GC.KeepAlive(this);
134                 GC.KeepAlive(val);
135                 if (this != null) { this.ptrs_to.AddLast(val); };
136         }
137
138         /**
139          * Constructs a new NodeAnnouncementInfo given each field
140          * 
141          * Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
142          */
143         public static NodeAnnouncementInfo of(org.ldk.structs.NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, org.ldk.structs.NodeAlias alias_arg, org.ldk.structs.NodeAnnouncement announcement_message_arg) {
144                 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr, last_update_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(rgb_arg, 3)), alias_arg == null ? 0 : alias_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr);
145                 GC.KeepAlive(features_arg);
146                 GC.KeepAlive(last_update_arg);
147                 GC.KeepAlive(rgb_arg);
148                 GC.KeepAlive(alias_arg);
149                 GC.KeepAlive(announcement_message_arg);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
153                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(alias_arg); };
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(announcement_message_arg); };
156                 return ret_hu_conv;
157         }
158
159         internal long clone_ptr() {
160                 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
161                 GC.KeepAlive(this);
162                 return ret;
163         }
164
165         /**
166          * Creates a copy of the NodeAnnouncementInfo
167          */
168         public NodeAnnouncementInfo clone() {
169                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
170                 GC.KeepAlive(this);
171                 if (ret >= 0 && ret <= 4096) { return null; }
172                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
173                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
174                 return ret_hu_conv;
175         }
176
177         /**
178          * Checks if two NodeAnnouncementInfos contain equal inner contents.
179          * This ignores pointers and is_owned flags and looks at the values in fields.
180          * Two objects with NULL inner values will be considered "equal" here.
181          */
182         public bool eq(org.ldk.structs.NodeAnnouncementInfo b) {
183                 bool ret = bindings.NodeAnnouncementInfo_eq(this.ptr, b == null ? 0 : b.ptr);
184                 GC.KeepAlive(this);
185                 GC.KeepAlive(b);
186                 if (this != null) { this.ptrs_to.AddLast(b); };
187                 return ret;
188         }
189
190         public override bool Equals(object o) {
191                 if (!(o is NodeAnnouncementInfo)) return false;
192                 return this.eq((NodeAnnouncementInfo)o);
193         }
194         /**
195          * Internet-level addresses via which one can connect to the node
196          */
197         public SocketAddress[] addresses() {
198                 long ret = bindings.NodeAnnouncementInfo_addresses(this.ptr);
199                 GC.KeepAlive(this);
200                 if (ret >= 0 && ret <= 4096) { return null; }
201                 int ret_conv_15_len = InternalUtils.getArrayLength(ret);
202                 SocketAddress[] ret_conv_15_arr = new SocketAddress[ret_conv_15_len];
203                 for (int p = 0; p < ret_conv_15_len; p++) {
204                         long ret_conv_15 = InternalUtils.getU64ArrayElem(ret, p);
205                         org.ldk.structs.SocketAddress ret_conv_15_hu_conv = org.ldk.structs.SocketAddress.constr_from_ptr(ret_conv_15);
206                         if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.AddLast(this); };
207                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
208                 }
209                 bindings.free_buffer(ret);
210                 return ret_conv_15_arr;
211         }
212
213         /**
214          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
215          */
216         public byte[] write() {
217                 long ret = bindings.NodeAnnouncementInfo_write(this.ptr);
218                 GC.KeepAlive(this);
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
221                 return ret_conv;
222         }
223
224         /**
225          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
226          */
227         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
228                 long ret = bindings.NodeAnnouncementInfo_read(InternalUtils.encodeUint8Array(ser));
229                 GC.KeepAlive(ser);
230                 if (ret >= 0 && ret <= 4096) { return null; }
231                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
232                 return ret_hu_conv;
233         }
234
235 }
236 } } }