[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / UnsignedNodeAnnouncement.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  * The unsigned part of a [`node_announcement`] message.
11  * 
12  * [`node_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-node_announcement-message
13  */
14 public class UnsignedNodeAnnouncement : CommonBase {
15         internal UnsignedNodeAnnouncement(object _dummy, long ptr) : base(ptr) { }
16         ~UnsignedNodeAnnouncement() {
17                 if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
18         }
19
20         /**
21          * The advertised features
22          */
23         public NodeFeatures get_features() {
24                 long ret = bindings.UnsignedNodeAnnouncement_get_features(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The advertised features
34          */
35         public void set_features(org.ldk.structs.NodeFeatures val) {
36                 bindings.UnsignedNodeAnnouncement_set_features(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * A strictly monotonic announcement counter, with gaps allowed
44          */
45         public int get_timestamp() {
46                 int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * A strictly monotonic announcement counter, with gaps allowed
53          */
54         public void set_timestamp(int val) {
55                 bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
62          * to this node).
63          */
64         public NodeId get_node_id() {
65                 long ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
66                 GC.KeepAlive(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
70                 return ret_hu_conv;
71         }
72
73         /**
74          * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back
75          * to this node).
76          */
77         public void set_node_id(org.ldk.structs.NodeId val) {
78                 bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, val.ptr);
79                 GC.KeepAlive(this);
80                 GC.KeepAlive(val);
81                 if (this != null) { this.ptrs_to.AddLast(val); };
82         }
83
84         /**
85          * An RGB color for UI purposes
86          */
87         public byte[] get_rgb() {
88                 long ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
89                 GC.KeepAlive(this);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
92                 return ret_conv;
93         }
94
95         /**
96          * An RGB color for UI purposes
97          */
98         public void set_rgb(byte[] val) {
99                 bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 3)));
100                 GC.KeepAlive(this);
101                 GC.KeepAlive(val);
102         }
103
104         /**
105          * An alias, for UI purposes.
106          * 
107          * This should be sanitized before use. There is no guarantee of uniqueness.
108          */
109         public NodeAlias get_alias() {
110                 long ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
111                 GC.KeepAlive(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
115                 return ret_hu_conv;
116         }
117
118         /**
119          * An alias, for UI purposes.
120          * 
121          * This should be sanitized before use. There is no guarantee of uniqueness.
122          */
123         public void set_alias(org.ldk.structs.NodeAlias val) {
124                 bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, val.ptr);
125                 GC.KeepAlive(this);
126                 GC.KeepAlive(val);
127                 if (this != null) { this.ptrs_to.AddLast(val); };
128         }
129
130         /**
131          * List of addresses on which this node is reachable
132          * 
133          * Returns a copy of the field.
134          */
135         public SocketAddress[] get_addresses() {
136                 long ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
137                 GC.KeepAlive(this);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 int ret_conv_15_len = InternalUtils.getArrayLength(ret);
140                 SocketAddress[] ret_conv_15_arr = new SocketAddress[ret_conv_15_len];
141                 for (int p = 0; p < ret_conv_15_len; p++) {
142                         long ret_conv_15 = InternalUtils.getU64ArrayElem(ret, p);
143                         org.ldk.structs.SocketAddress ret_conv_15_hu_conv = org.ldk.structs.SocketAddress.constr_from_ptr(ret_conv_15);
144                         if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.AddLast(this); };
145                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
146                 }
147                 bindings.free_buffer(ret);
148                 return ret_conv_15_arr;
149         }
150
151         /**
152          * List of addresses on which this node is reachable
153          */
154         public void set_addresses(SocketAddress[] val) {
155                 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_15 => val_conv_15.ptr)));
156                 GC.KeepAlive(this);
157                 GC.KeepAlive(val);
158                 foreach (SocketAddress val_conv_15 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_15); }; };
159         }
160
161         /**
162          * Excess address data which was signed as a part of the message which we do not (yet) understand how
163          * to decode.
164          * 
165          * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
166          * 
167          * Returns a copy of the field.
168          */
169         public byte[] get_excess_address_data() {
170                 long ret = bindings.UnsignedNodeAnnouncement_get_excess_address_data(this.ptr);
171                 GC.KeepAlive(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
174                 return ret_conv;
175         }
176
177         /**
178          * Excess address data which was signed as a part of the message which we do not (yet) understand how
179          * to decode.
180          * 
181          * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol.
182          */
183         public void set_excess_address_data(byte[] val) {
184                 bindings.UnsignedNodeAnnouncement_set_excess_address_data(this.ptr, InternalUtils.encodeUint8Array(val));
185                 GC.KeepAlive(this);
186                 GC.KeepAlive(val);
187         }
188
189         /**
190          * Excess data which was signed as a part of the message which we do not (yet) understand how
191          * to decode.
192          * 
193          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
194          * 
195          * Returns a copy of the field.
196          */
197         public byte[] get_excess_data() {
198                 long ret = bindings.UnsignedNodeAnnouncement_get_excess_data(this.ptr);
199                 GC.KeepAlive(this);
200                 if (ret >= 0 && ret <= 4096) { return null; }
201                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
202                 return ret_conv;
203         }
204
205         /**
206          * Excess data which was signed as a part of the message which we do not (yet) understand how
207          * to decode.
208          * 
209          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
210          */
211         public void set_excess_data(byte[] val) {
212                 bindings.UnsignedNodeAnnouncement_set_excess_data(this.ptr, InternalUtils.encodeUint8Array(val));
213                 GC.KeepAlive(this);
214                 GC.KeepAlive(val);
215         }
216
217         /**
218          * Constructs a new UnsignedNodeAnnouncement given each field
219          */
220         public static UnsignedNodeAnnouncement of(org.ldk.structs.NodeFeatures features_arg, int timestamp_arg, org.ldk.structs.NodeId node_id_arg, byte[] rgb_arg, org.ldk.structs.NodeAlias alias_arg, SocketAddress[] addresses_arg, byte[] excess_address_data_arg, byte[] excess_data_arg) {
221                 long ret = bindings.UnsignedNodeAnnouncement_new(features_arg.ptr, timestamp_arg, node_id_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(rgb_arg, 3)), alias_arg.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(addresses_arg, addresses_arg_conv_15 => addresses_arg_conv_15.ptr)), InternalUtils.encodeUint8Array(excess_address_data_arg), InternalUtils.encodeUint8Array(excess_data_arg));
222                 GC.KeepAlive(features_arg);
223                 GC.KeepAlive(timestamp_arg);
224                 GC.KeepAlive(node_id_arg);
225                 GC.KeepAlive(rgb_arg);
226                 GC.KeepAlive(alias_arg);
227                 GC.KeepAlive(addresses_arg);
228                 GC.KeepAlive(excess_address_data_arg);
229                 GC.KeepAlive(excess_data_arg);
230                 if (ret >= 0 && ret <= 4096) { return null; }
231                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
232                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
233                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_id_arg); };
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(alias_arg); };
236                 foreach (SocketAddress addresses_arg_conv_15 in addresses_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(addresses_arg_conv_15); }; };
237                 return ret_hu_conv;
238         }
239
240         internal long clone_ptr() {
241                 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
242                 GC.KeepAlive(this);
243                 return ret;
244         }
245
246         /**
247          * Creates a copy of the UnsignedNodeAnnouncement
248          */
249         public UnsignedNodeAnnouncement clone() {
250                 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
251                 GC.KeepAlive(this);
252                 if (ret >= 0 && ret <= 4096) { return null; }
253                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
254                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
255                 return ret_hu_conv;
256         }
257
258         /**
259          * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement.
260          */
261         public long hash() {
262                 long ret = bindings.UnsignedNodeAnnouncement_hash(this.ptr);
263                 GC.KeepAlive(this);
264                 return ret;
265         }
266
267         public override int GetHashCode() {
268                 return (int)this.hash();
269         }
270         /**
271          * Checks if two UnsignedNodeAnnouncements contain equal inner contents.
272          * This ignores pointers and is_owned flags and looks at the values in fields.
273          * Two objects with NULL inner values will be considered "equal" here.
274          */
275         public bool eq(org.ldk.structs.UnsignedNodeAnnouncement b) {
276                 bool ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b.ptr);
277                 GC.KeepAlive(this);
278                 GC.KeepAlive(b);
279                 if (this != null) { this.ptrs_to.AddLast(b); };
280                 return ret;
281         }
282
283         public override bool Equals(object o) {
284                 if (!(o is UnsignedNodeAnnouncement)) return false;
285                 return this.eq((UnsignedNodeAnnouncement)o);
286         }
287         /**
288          * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
289          */
290         public byte[] write() {
291                 long ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
292                 GC.KeepAlive(this);
293                 if (ret >= 0 && ret <= 4096) { return null; }
294                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
295                 return ret_conv;
296         }
297
298         /**
299          * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
300          */
301         public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
302                 long ret = bindings.UnsignedNodeAnnouncement_read(InternalUtils.encodeUint8Array(ser));
303                 GC.KeepAlive(ser);
304                 if (ret >= 0 && ret <= 4096) { return null; }
305                 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
306                 return ret_hu_conv;
307         }
308
309 }
310 } } }