[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / UnsignedChannelAnnouncement.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 [`channel_announcement`] message.
11  * 
12  * [`channel_announcement`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
13  */
14 public class UnsignedChannelAnnouncement : CommonBase {
15         internal UnsignedChannelAnnouncement(object _dummy, long ptr) : base(ptr) { }
16         ~UnsignedChannelAnnouncement() {
17                 if (ptr != 0) { bindings.UnsignedChannelAnnouncement_free(ptr); }
18         }
19
20         /**
21          * The advertised channel features
22          */
23         public ChannelFeatures get_features() {
24                 long ret = bindings.UnsignedChannelAnnouncement_get_features(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(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 channel features
34          */
35         public void set_features(org.ldk.structs.ChannelFeatures val) {
36                 bindings.UnsignedChannelAnnouncement_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          * The genesis hash of the blockchain where the channel is to be opened
44          */
45         public byte[] get_chain_hash() {
46                 long ret = bindings.UnsignedChannelAnnouncement_get_chain_hash(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
50                 return ret_conv;
51         }
52
53         /**
54          * The genesis hash of the blockchain where the channel is to be opened
55          */
56         public void set_chain_hash(byte[] val) {
57                 bindings.UnsignedChannelAnnouncement_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * The short channel ID
64          */
65         public long get_short_channel_id() {
66                 long ret = bindings.UnsignedChannelAnnouncement_get_short_channel_id(this.ptr);
67                 GC.KeepAlive(this);
68                 return ret;
69         }
70
71         /**
72          * The short channel ID
73          */
74         public void set_short_channel_id(long val) {
75                 bindings.UnsignedChannelAnnouncement_set_short_channel_id(this.ptr, val);
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * One of the two `node_id`s which are endpoints of this channel
82          */
83         public NodeId get_node_id_1() {
84                 long ret = bindings.UnsignedChannelAnnouncement_get_node_id_1(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * One of the two `node_id`s which are endpoints of this channel
94          */
95         public void set_node_id_1(org.ldk.structs.NodeId val) {
96                 bindings.UnsignedChannelAnnouncement_set_node_id_1(this.ptr, val == null ? 0 : val.ptr);
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(val);
99                 if (this != null) { this.ptrs_to.AddLast(val); };
100         }
101
102         /**
103          * The other of the two `node_id`s which are endpoints of this channel
104          */
105         public NodeId get_node_id_2() {
106                 long ret = bindings.UnsignedChannelAnnouncement_get_node_id_2(this.ptr);
107                 GC.KeepAlive(this);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * The other of the two `node_id`s which are endpoints of this channel
116          */
117         public void set_node_id_2(org.ldk.structs.NodeId val) {
118                 bindings.UnsignedChannelAnnouncement_set_node_id_2(this.ptr, val == null ? 0 : val.ptr);
119                 GC.KeepAlive(this);
120                 GC.KeepAlive(val);
121                 if (this != null) { this.ptrs_to.AddLast(val); };
122         }
123
124         /**
125          * The funding key for the first node
126          */
127         public NodeId get_bitcoin_key_1() {
128                 long ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_1(this.ptr);
129                 GC.KeepAlive(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
133                 return ret_hu_conv;
134         }
135
136         /**
137          * The funding key for the first node
138          */
139         public void set_bitcoin_key_1(org.ldk.structs.NodeId val) {
140                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_1(this.ptr, val == null ? 0 : val.ptr);
141                 GC.KeepAlive(this);
142                 GC.KeepAlive(val);
143                 if (this != null) { this.ptrs_to.AddLast(val); };
144         }
145
146         /**
147          * The funding key for the second node
148          */
149         public NodeId get_bitcoin_key_2() {
150                 long ret = bindings.UnsignedChannelAnnouncement_get_bitcoin_key_2(this.ptr);
151                 GC.KeepAlive(this);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
155                 return ret_hu_conv;
156         }
157
158         /**
159          * The funding key for the second node
160          */
161         public void set_bitcoin_key_2(org.ldk.structs.NodeId val) {
162                 bindings.UnsignedChannelAnnouncement_set_bitcoin_key_2(this.ptr, val == null ? 0 : val.ptr);
163                 GC.KeepAlive(this);
164                 GC.KeepAlive(val);
165                 if (this != null) { this.ptrs_to.AddLast(val); };
166         }
167
168         /**
169          * Excess data which was signed as a part of the message which we do not (yet) understand how
170          * to decode.
171          * 
172          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
173          * 
174          * Returns a copy of the field.
175          */
176         public byte[] get_excess_data() {
177                 long ret = bindings.UnsignedChannelAnnouncement_get_excess_data(this.ptr);
178                 GC.KeepAlive(this);
179                 if (ret >= 0 && ret <= 4096) { return null; }
180                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
181                 return ret_conv;
182         }
183
184         /**
185          * Excess data which was signed as a part of the message which we do not (yet) understand how
186          * to decode.
187          * 
188          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
189          */
190         public void set_excess_data(byte[] val) {
191                 bindings.UnsignedChannelAnnouncement_set_excess_data(this.ptr, InternalUtils.encodeUint8Array(val));
192                 GC.KeepAlive(this);
193                 GC.KeepAlive(val);
194         }
195
196         /**
197          * Constructs a new UnsignedChannelAnnouncement given each field
198          */
199         public static UnsignedChannelAnnouncement of(org.ldk.structs.ChannelFeatures features_arg, byte[] chain_hash_arg, long short_channel_id_arg, org.ldk.structs.NodeId node_id_1_arg, org.ldk.structs.NodeId node_id_2_arg, org.ldk.structs.NodeId bitcoin_key_1_arg, org.ldk.structs.NodeId bitcoin_key_2_arg, byte[] excess_data_arg) {
200                 long ret = bindings.UnsignedChannelAnnouncement_new(features_arg == null ? 0 : features_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), short_channel_id_arg, node_id_1_arg == null ? 0 : node_id_1_arg.ptr, node_id_2_arg == null ? 0 : node_id_2_arg.ptr, bitcoin_key_1_arg == null ? 0 : bitcoin_key_1_arg.ptr, bitcoin_key_2_arg == null ? 0 : bitcoin_key_2_arg.ptr, InternalUtils.encodeUint8Array(excess_data_arg));
201                 GC.KeepAlive(features_arg);
202                 GC.KeepAlive(chain_hash_arg);
203                 GC.KeepAlive(short_channel_id_arg);
204                 GC.KeepAlive(node_id_1_arg);
205                 GC.KeepAlive(node_id_2_arg);
206                 GC.KeepAlive(bitcoin_key_1_arg);
207                 GC.KeepAlive(bitcoin_key_2_arg);
208                 GC.KeepAlive(excess_data_arg);
209                 if (ret >= 0 && ret <= 4096) { return null; }
210                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features_arg); };
213                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_id_1_arg); };
214                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_id_2_arg); };
215                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(bitcoin_key_1_arg); };
216                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(bitcoin_key_2_arg); };
217                 return ret_hu_conv;
218         }
219
220         internal long clone_ptr() {
221                 long ret = bindings.UnsignedChannelAnnouncement_clone_ptr(this.ptr);
222                 GC.KeepAlive(this);
223                 return ret;
224         }
225
226         /**
227          * Creates a copy of the UnsignedChannelAnnouncement
228          */
229         public UnsignedChannelAnnouncement clone() {
230                 long ret = bindings.UnsignedChannelAnnouncement_clone(this.ptr);
231                 GC.KeepAlive(this);
232                 if (ret >= 0 && ret <= 4096) { return null; }
233                 org.ldk.structs.UnsignedChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelAnnouncement(null, ret); }
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
235                 return ret_hu_conv;
236         }
237
238         /**
239          * Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement.
240          */
241         public long hash() {
242                 long ret = bindings.UnsignedChannelAnnouncement_hash(this.ptr);
243                 GC.KeepAlive(this);
244                 return ret;
245         }
246
247         public override int GetHashCode() {
248                 return (int)this.hash();
249         }
250         /**
251          * Checks if two UnsignedChannelAnnouncements contain equal inner contents.
252          * This ignores pointers and is_owned flags and looks at the values in fields.
253          * Two objects with NULL inner values will be considered "equal" here.
254          */
255         public bool eq(org.ldk.structs.UnsignedChannelAnnouncement b) {
256                 bool ret = bindings.UnsignedChannelAnnouncement_eq(this.ptr, b == null ? 0 : b.ptr);
257                 GC.KeepAlive(this);
258                 GC.KeepAlive(b);
259                 if (this != null) { this.ptrs_to.AddLast(b); };
260                 return ret;
261         }
262
263         public override bool Equals(object o) {
264                 if (!(o is UnsignedChannelAnnouncement)) return false;
265                 return this.eq((UnsignedChannelAnnouncement)o);
266         }
267         /**
268          * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read
269          */
270         public byte[] write() {
271                 long ret = bindings.UnsignedChannelAnnouncement_write(this.ptr);
272                 GC.KeepAlive(this);
273                 if (ret >= 0 && ret <= 4096) { return null; }
274                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
275                 return ret_conv;
276         }
277
278         /**
279          * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write
280          */
281         public static Result_UnsignedChannelAnnouncementDecodeErrorZ read(byte[] ser) {
282                 long ret = bindings.UnsignedChannelAnnouncement_read(InternalUtils.encodeUint8Array(ser));
283                 GC.KeepAlive(ser);
284                 if (ret >= 0 && ret <= 4096) { return null; }
285                 Result_UnsignedChannelAnnouncementDecodeErrorZ ret_hu_conv = Result_UnsignedChannelAnnouncementDecodeErrorZ.constr_from_ptr(ret);
286                 return ret_hu_conv;
287         }
288
289 }
290 } } }