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