7239193561f929d6e056c97ff116dfed924db2ba
[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                 byte[] ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
65                 GC.KeepAlive(this);
66                 return ret;
67         }
68
69         /**
70          * Color assigned to the node
71          */
72         public void set_rgb(byte[] val) {
73                 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * Moniker assigned to the node.
80          * May be invalid or malicious (eg control chars),
81          * should not be exposed to the user.
82          */
83         public NodeAlias get_alias() {
84                 long ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Moniker assigned to the node.
94          * May be invalid or malicious (eg control chars),
95          * should not be exposed to the user.
96          */
97         public void set_alias(org.ldk.structs.NodeAlias val) {
98                 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val == null ? 0 : val.ptr);
99                 GC.KeepAlive(this);
100                 GC.KeepAlive(val);
101                 if (this != null) { this.ptrs_to.AddLast(val); };
102         }
103
104         /**
105          * Internet-level addresses via which one can connect to the node
106          * 
107          * Returns a copy of the field.
108          */
109         public NetAddress[] get_addresses() {
110                 long[] ret = bindings.NodeAnnouncementInfo_get_addresses(this.ptr);
111                 GC.KeepAlive(this);
112                 int ret_conv_12_len = ret.Length;
113                 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
114                 for (int m = 0; m < ret_conv_12_len; m++) {
115                         long ret_conv_12 = ret[m];
116                         org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
117                         if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
118                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
119                 }
120                 return ret_conv_12_arr;
121         }
122
123         /**
124          * Internet-level addresses via which one can connect to the node
125          */
126         public void set_addresses(NetAddress[] val) {
127                 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_12 => val_conv_12.ptr) : null);
128                 GC.KeepAlive(this);
129                 GC.KeepAlive(val);
130         }
131
132         /**
133          * An initial announcement of the node
134          * Mostly redundant with the data we store in fields explicitly.
135          * Everything else is useful only for sending out for initial routing sync.
136          * Not stored if contains excess data to prevent DoS.
137          * 
138          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
139          */
140         public NodeAnnouncement get_announcement_message() {
141                 long ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
142                 GC.KeepAlive(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.NodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncement(null, ret); }
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * An initial announcement of the node
151          * Mostly redundant with the data we store in fields explicitly.
152          * Everything else is useful only for sending out for initial routing sync.
153          * Not stored if contains excess data to prevent DoS.
154          * 
155          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
156          */
157         public void set_announcement_message(org.ldk.structs.NodeAnnouncement val) {
158                 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
159                 GC.KeepAlive(this);
160                 GC.KeepAlive(val);
161                 if (this != null) { this.ptrs_to.AddLast(val); };
162         }
163
164         /**
165          * Constructs a new NodeAnnouncementInfo given each field
166          */
167         public static NodeAnnouncementInfo of(org.ldk.structs.NodeFeatures features_arg, int last_update_arg, byte[] rgb_arg, org.ldk.structs.NodeAlias alias_arg, NetAddress[] addresses_arg, org.ldk.structs.NodeAnnouncement announcement_message_arg) {
168                 long ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr, last_update_arg, InternalUtils.check_arr_len(rgb_arg, 3), alias_arg == null ? 0 : alias_arg.ptr, addresses_arg != null ? InternalUtils.mapArray(addresses_arg, addresses_arg_conv_12 => addresses_arg_conv_12.ptr) : null, announcement_message_arg == null ? 0 : announcement_message_arg.ptr);
169                 GC.KeepAlive(features_arg);
170                 GC.KeepAlive(last_update_arg);
171                 GC.KeepAlive(rgb_arg);
172                 GC.KeepAlive(alias_arg);
173                 GC.KeepAlive(addresses_arg);
174                 GC.KeepAlive(announcement_message_arg);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
178                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(alias_arg); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(announcement_message_arg); };
181                 return ret_hu_conv;
182         }
183
184         internal long clone_ptr() {
185                 long ret = bindings.NodeAnnouncementInfo_clone_ptr(this.ptr);
186                 GC.KeepAlive(this);
187                 return ret;
188         }
189
190         /**
191          * Creates a copy of the NodeAnnouncementInfo
192          */
193         public NodeAnnouncementInfo clone() {
194                 long ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
195                 GC.KeepAlive(this);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.NodeAnnouncementInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAnnouncementInfo(null, ret); }
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Checks if two NodeAnnouncementInfos contain equal inner contents.
204          * This ignores pointers and is_owned flags and looks at the values in fields.
205          * Two objects with NULL inner values will be considered "equal" here.
206          */
207         public bool eq(org.ldk.structs.NodeAnnouncementInfo b) {
208                 bool ret = bindings.NodeAnnouncementInfo_eq(this.ptr, b == null ? 0 : b.ptr);
209                 GC.KeepAlive(this);
210                 GC.KeepAlive(b);
211                 if (this != null) { this.ptrs_to.AddLast(b); };
212                 return ret;
213         }
214
215         public override bool Equals(object o) {
216                 if (!(o is NodeAnnouncementInfo)) return false;
217                 return this.eq((NodeAnnouncementInfo)o);
218         }
219         /**
220          * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read
221          */
222         public byte[] write() {
223                 byte[] ret = bindings.NodeAnnouncementInfo_write(this.ptr);
224                 GC.KeepAlive(this);
225                 return ret;
226         }
227
228         /**
229          * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write
230          */
231         public static Result_NodeAnnouncementInfoDecodeErrorZ read(byte[] ser) {
232                 long ret = bindings.NodeAnnouncementInfo_read(ser);
233                 GC.KeepAlive(ser);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);
236                 return ret_hu_conv;
237         }
238
239 }
240 } } }