[C#] Update auto-generated files
[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 == null ? 0 : 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 == null ? 0 : 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                 byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
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.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 == null ? 0 : val.ptr);
123                 GC.KeepAlive(this);
124                 GC.KeepAlive(val);
125                 if (this != null) { this.ptrs_to.AddLast(val); };
126         }
127
128         /**
129          * List of addresses on which this node is reachable
130          * 
131          * Returns a copy of the field.
132          */
133         public NetAddress[] get_addresses() {
134                 long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
135                 GC.KeepAlive(this);
136                 int ret_conv_12_len = ret.Length;
137                 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
138                 for (int m = 0; m < ret_conv_12_len; m++) {
139                         long ret_conv_12 = ret[m];
140                         org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
141                         if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
142                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
143                 }
144                 return ret_conv_12_arr;
145         }
146
147         /**
148          * List of addresses on which this node is reachable
149          */
150         public void set_addresses(NetAddress[] val) {
151                 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_12 => val_conv_12.ptr) : null);
152                 GC.KeepAlive(this);
153                 GC.KeepAlive(val);
154                 foreach (NetAddress val_conv_12 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_12); }; };
155         }
156
157         internal long clone_ptr() {
158                 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
159                 GC.KeepAlive(this);
160                 return ret;
161         }
162
163         /**
164          * Creates a copy of the UnsignedNodeAnnouncement
165          */
166         public UnsignedNodeAnnouncement clone() {
167                 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
168                 GC.KeepAlive(this);
169                 if (ret >= 0 && ret <= 4096) { return null; }
170                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
171                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
172                 return ret_hu_conv;
173         }
174
175         /**
176          * Checks if two UnsignedNodeAnnouncements contain equal inner contents.
177          * This ignores pointers and is_owned flags and looks at the values in fields.
178          * Two objects with NULL inner values will be considered "equal" here.
179          */
180         public bool eq(org.ldk.structs.UnsignedNodeAnnouncement b) {
181                 bool ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
182                 GC.KeepAlive(this);
183                 GC.KeepAlive(b);
184                 if (this != null) { this.ptrs_to.AddLast(b); };
185                 return ret;
186         }
187
188         public override bool Equals(object o) {
189                 if (!(o is UnsignedNodeAnnouncement)) return false;
190                 return this.eq((UnsignedNodeAnnouncement)o);
191         }
192         /**
193          * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
194          */
195         public byte[] write() {
196                 byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
197                 GC.KeepAlive(this);
198                 return ret;
199         }
200
201         /**
202          * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
203          */
204         public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
205                 long ret = bindings.UnsignedNodeAnnouncement_read(ser);
206                 GC.KeepAlive(ser);
207                 if (ret >= 0 && ret <= 4096) { return null; }
208                 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
209                 return ret_hu_conv;
210         }
211
212 }
213 } } }