6104a01a11a905209b85c0ba55477d1e16854a63
[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
11  */
12 public class UnsignedNodeAnnouncement : CommonBase {
13         internal UnsignedNodeAnnouncement(object _dummy, long ptr) : base(ptr) { }
14         ~UnsignedNodeAnnouncement() {
15                 if (ptr != 0) { bindings.UnsignedNodeAnnouncement_free(ptr); }
16         }
17
18         /**
19          * The advertised features
20          */
21         public NodeFeatures get_features() {
22                 long ret = bindings.UnsignedNodeAnnouncement_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          * The advertised features
32          */
33         public void set_features(org.ldk.structs.NodeFeatures val) {
34                 bindings.UnsignedNodeAnnouncement_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          * A strictly monotonic announcement counter, with gaps allowed
42          */
43         public int get_timestamp() {
44                 int ret = bindings.UnsignedNodeAnnouncement_get_timestamp(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * A strictly monotonic announcement counter, with gaps allowed
51          */
52         public void set_timestamp(int val) {
53                 bindings.UnsignedNodeAnnouncement_set_timestamp(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * The node_id this announcement originated from (don't rebroadcast the node_announcement back
60          * to this node).
61          */
62         public byte[] get_node_id() {
63                 byte[] ret = bindings.UnsignedNodeAnnouncement_get_node_id(this.ptr);
64                 GC.KeepAlive(this);
65                 return ret;
66         }
67
68         /**
69          * The node_id this announcement originated from (don't rebroadcast the node_announcement back
70          * to this node).
71          */
72         public void set_node_id(byte[] val) {
73                 bindings.UnsignedNodeAnnouncement_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * An RGB color for UI purposes
80          */
81         public byte[] get_rgb() {
82                 byte[] ret = bindings.UnsignedNodeAnnouncement_get_rgb(this.ptr);
83                 GC.KeepAlive(this);
84                 return ret;
85         }
86
87         /**
88          * An RGB color for UI purposes
89          */
90         public void set_rgb(byte[] val) {
91                 bindings.UnsignedNodeAnnouncement_set_rgb(this.ptr, InternalUtils.check_arr_len(val, 3));
92                 GC.KeepAlive(this);
93                 GC.KeepAlive(val);
94         }
95
96         /**
97          * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
98          * of uniqueness.
99          */
100         public byte[] get_alias() {
101                 byte[] ret = bindings.UnsignedNodeAnnouncement_get_alias(this.ptr);
102                 GC.KeepAlive(this);
103                 return ret;
104         }
105
106         /**
107          * An alias, for UI purposes.  This should be sanitized before use.  There is no guarantee
108          * of uniqueness.
109          */
110         public void set_alias(byte[] val) {
111                 bindings.UnsignedNodeAnnouncement_set_alias(this.ptr, InternalUtils.check_arr_len(val, 32));
112                 GC.KeepAlive(this);
113                 GC.KeepAlive(val);
114         }
115
116         /**
117          * List of addresses on which this node is reachable
118          * 
119          * Returns a copy of the field.
120          */
121         public NetAddress[] get_addresses() {
122                 long[] ret = bindings.UnsignedNodeAnnouncement_get_addresses(this.ptr);
123                 GC.KeepAlive(this);
124                 int ret_conv_12_len = ret.Length;
125                 NetAddress[] ret_conv_12_arr = new NetAddress[ret_conv_12_len];
126                 for (int m = 0; m < ret_conv_12_len; m++) {
127                         long ret_conv_12 = ret[m];
128                         org.ldk.structs.NetAddress ret_conv_12_hu_conv = org.ldk.structs.NetAddress.constr_from_ptr(ret_conv_12);
129                         if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
130                         ret_conv_12_arr[m] = ret_conv_12_hu_conv;
131                 }
132                 return ret_conv_12_arr;
133         }
134
135         /**
136          * List of addresses on which this node is reachable
137          */
138         public void set_addresses(NetAddress[] val) {
139                 bindings.UnsignedNodeAnnouncement_set_addresses(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_12 => val_conv_12.ptr) : null);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(val);
142         }
143
144         internal long clone_ptr() {
145                 long ret = bindings.UnsignedNodeAnnouncement_clone_ptr(this.ptr);
146                 GC.KeepAlive(this);
147                 return ret;
148         }
149
150         /**
151          * Creates a copy of the UnsignedNodeAnnouncement
152          */
153         public UnsignedNodeAnnouncement clone() {
154                 long ret = bindings.UnsignedNodeAnnouncement_clone(this.ptr);
155                 GC.KeepAlive(this);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.UnsignedNodeAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedNodeAnnouncement(null, ret); }
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * Checks if two UnsignedNodeAnnouncements contain equal inner contents.
164          * This ignores pointers and is_owned flags and looks at the values in fields.
165          * Two objects with NULL inner values will be considered "equal" here.
166          */
167         public bool eq(org.ldk.structs.UnsignedNodeAnnouncement b) {
168                 bool ret = bindings.UnsignedNodeAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
169                 GC.KeepAlive(this);
170                 GC.KeepAlive(b);
171                 if (this != null) { this.ptrs_to.AddLast(b); };
172                 return ret;
173         }
174
175         public override bool Equals(object o) {
176                 if (!(o is UnsignedNodeAnnouncement)) return false;
177                 return this.eq((UnsignedNodeAnnouncement)o);
178         }
179         /**
180          * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
181          */
182         public byte[] write() {
183                 byte[] ret = bindings.UnsignedNodeAnnouncement_write(this.ptr);
184                 GC.KeepAlive(this);
185                 return ret;
186         }
187
188         /**
189          * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write
190          */
191         public static Result_UnsignedNodeAnnouncementDecodeErrorZ read(byte[] ser) {
192                 long ret = bindings.UnsignedNodeAnnouncement_read(ser);
193                 GC.KeepAlive(ser);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 Result_UnsignedNodeAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedNodeAnnouncementDecodeErrorZ.constr_from_ptr(ret);
196                 return ret_hu_conv;
197         }
198
199 }
200 } } }