e79460ab63eb0137d5284120bd00ef25663d67bb
[ldk-java] / src / main / java / org / ldk / structs / NodeFeatures.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Features used within a `node_announcement` message.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class NodeFeatures extends CommonBase {
16         NodeFeatures(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.NodeFeatures_free(ptr); }
21         }
22
23         /**
24          * Checks if two NodeFeaturess contain equal inner contents.
25          * This ignores pointers and is_owned flags and looks at the values in fields.
26          * Two objects with NULL inner values will be considered "equal" here.
27          */
28         public boolean eq(NodeFeatures b) {
29                 boolean ret = bindings.NodeFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
30                 Reference.reachabilityFence(this);
31                 Reference.reachabilityFence(b);
32                 if (this != null) { this.ptrs_to.add(b); };
33                 return ret;
34         }
35
36         @Override public boolean equals(Object o) {
37                 if (!(o instanceof NodeFeatures)) return false;
38                 return this.eq((NodeFeatures)o);
39         }
40         long clone_ptr() {
41                 long ret = bindings.NodeFeatures_clone_ptr(this.ptr);
42                 Reference.reachabilityFence(this);
43                 return ret;
44         }
45
46         /**
47          * Creates a copy of the NodeFeatures
48          */
49         public NodeFeatures clone() {
50                 long ret = bindings.NodeFeatures_clone(this.ptr);
51                 Reference.reachabilityFence(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
54                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Returns the set of known node features that are related to channels.
60          */
61         public static NodeFeatures known_channel_features() {
62                 long ret = bindings.NodeFeatures_known_channel_features();
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
65                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
66                 return ret_hu_conv;
67         }
68
69         /**
70          * Create a blank Features with no features set
71          */
72         public static NodeFeatures empty() {
73                 long ret = bindings.NodeFeatures_empty();
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
76                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77                 return ret_hu_conv;
78         }
79
80         /**
81          * Creates a Features with the bits set which are known by the implementation
82          */
83         public static NodeFeatures known() {
84                 long ret = bindings.NodeFeatures_known();
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
88                 return ret_hu_conv;
89         }
90
91         /**
92          * Returns true if this `Features` object contains unknown feature flags which are set as
93          * \"required\".
94          */
95         public boolean requires_unknown_bits() {
96                 boolean ret = bindings.NodeFeatures_requires_unknown_bits(this.ptr);
97                 Reference.reachabilityFence(this);
98                 return ret;
99         }
100
101         /**
102          * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
103          */
104         public byte[] write() {
105                 byte[] ret = bindings.NodeFeatures_write(this.ptr);
106                 Reference.reachabilityFence(this);
107                 return ret;
108         }
109
110         /**
111          * Read a NodeFeatures from a byte array, created by NodeFeatures_write
112          */
113         public static Result_NodeFeaturesDecodeErrorZ read(byte[] ser) {
114                 long ret = bindings.NodeFeatures_read(ser);
115                 Reference.reachabilityFence(ser);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 Result_NodeFeaturesDecodeErrorZ ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret);
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Set this feature as optional.
123          */
124         public void set_data_loss_protect_optional() {
125                 bindings.NodeFeatures_set_data_loss_protect_optional(this.ptr);
126                 Reference.reachabilityFence(this);
127         }
128
129         /**
130          * Set this feature as required.
131          */
132         public void set_data_loss_protect_required() {
133                 bindings.NodeFeatures_set_data_loss_protect_required(this.ptr);
134                 Reference.reachabilityFence(this);
135         }
136
137         /**
138          * Checks if this feature is supported.
139          */
140         public boolean supports_data_loss_protect() {
141                 boolean ret = bindings.NodeFeatures_supports_data_loss_protect(this.ptr);
142                 Reference.reachabilityFence(this);
143                 return ret;
144         }
145
146         /**
147          * Checks if this feature is required.
148          */
149         public boolean requires_data_loss_protect() {
150                 boolean ret = bindings.NodeFeatures_requires_data_loss_protect(this.ptr);
151                 Reference.reachabilityFence(this);
152                 return ret;
153         }
154
155         /**
156          * Set this feature as optional.
157          */
158         public void set_upfront_shutdown_script_optional() {
159                 bindings.NodeFeatures_set_upfront_shutdown_script_optional(this.ptr);
160                 Reference.reachabilityFence(this);
161         }
162
163         /**
164          * Set this feature as required.
165          */
166         public void set_upfront_shutdown_script_required() {
167                 bindings.NodeFeatures_set_upfront_shutdown_script_required(this.ptr);
168                 Reference.reachabilityFence(this);
169         }
170
171         /**
172          * Checks if this feature is supported.
173          */
174         public boolean supports_upfront_shutdown_script() {
175                 boolean ret = bindings.NodeFeatures_supports_upfront_shutdown_script(this.ptr);
176                 Reference.reachabilityFence(this);
177                 return ret;
178         }
179
180         /**
181          * Checks if this feature is required.
182          */
183         public boolean requires_upfront_shutdown_script() {
184                 boolean ret = bindings.NodeFeatures_requires_upfront_shutdown_script(this.ptr);
185                 Reference.reachabilityFence(this);
186                 return ret;
187         }
188
189         /**
190          * Set this feature as optional.
191          */
192         public void set_gossip_queries_optional() {
193                 bindings.NodeFeatures_set_gossip_queries_optional(this.ptr);
194                 Reference.reachabilityFence(this);
195         }
196
197         /**
198          * Set this feature as required.
199          */
200         public void set_gossip_queries_required() {
201                 bindings.NodeFeatures_set_gossip_queries_required(this.ptr);
202                 Reference.reachabilityFence(this);
203         }
204
205         /**
206          * Checks if this feature is supported.
207          */
208         public boolean supports_gossip_queries() {
209                 boolean ret = bindings.NodeFeatures_supports_gossip_queries(this.ptr);
210                 Reference.reachabilityFence(this);
211                 return ret;
212         }
213
214         /**
215          * Checks if this feature is required.
216          */
217         public boolean requires_gossip_queries() {
218                 boolean ret = bindings.NodeFeatures_requires_gossip_queries(this.ptr);
219                 Reference.reachabilityFence(this);
220                 return ret;
221         }
222
223         /**
224          * Set this feature as optional.
225          */
226         public void set_variable_length_onion_optional() {
227                 bindings.NodeFeatures_set_variable_length_onion_optional(this.ptr);
228                 Reference.reachabilityFence(this);
229         }
230
231         /**
232          * Set this feature as required.
233          */
234         public void set_variable_length_onion_required() {
235                 bindings.NodeFeatures_set_variable_length_onion_required(this.ptr);
236                 Reference.reachabilityFence(this);
237         }
238
239         /**
240          * Checks if this feature is supported.
241          */
242         public boolean supports_variable_length_onion() {
243                 boolean ret = bindings.NodeFeatures_supports_variable_length_onion(this.ptr);
244                 Reference.reachabilityFence(this);
245                 return ret;
246         }
247
248         /**
249          * Checks if this feature is required.
250          */
251         public boolean requires_variable_length_onion() {
252                 boolean ret = bindings.NodeFeatures_requires_variable_length_onion(this.ptr);
253                 Reference.reachabilityFence(this);
254                 return ret;
255         }
256
257         /**
258          * Set this feature as optional.
259          */
260         public void set_static_remote_key_optional() {
261                 bindings.NodeFeatures_set_static_remote_key_optional(this.ptr);
262                 Reference.reachabilityFence(this);
263         }
264
265         /**
266          * Set this feature as required.
267          */
268         public void set_static_remote_key_required() {
269                 bindings.NodeFeatures_set_static_remote_key_required(this.ptr);
270                 Reference.reachabilityFence(this);
271         }
272
273         /**
274          * Checks if this feature is supported.
275          */
276         public boolean supports_static_remote_key() {
277                 boolean ret = bindings.NodeFeatures_supports_static_remote_key(this.ptr);
278                 Reference.reachabilityFence(this);
279                 return ret;
280         }
281
282         /**
283          * Checks if this feature is required.
284          */
285         public boolean requires_static_remote_key() {
286                 boolean ret = bindings.NodeFeatures_requires_static_remote_key(this.ptr);
287                 Reference.reachabilityFence(this);
288                 return ret;
289         }
290
291         /**
292          * Set this feature as optional.
293          */
294         public void set_payment_secret_optional() {
295                 bindings.NodeFeatures_set_payment_secret_optional(this.ptr);
296                 Reference.reachabilityFence(this);
297         }
298
299         /**
300          * Set this feature as required.
301          */
302         public void set_payment_secret_required() {
303                 bindings.NodeFeatures_set_payment_secret_required(this.ptr);
304                 Reference.reachabilityFence(this);
305         }
306
307         /**
308          * Checks if this feature is supported.
309          */
310         public boolean supports_payment_secret() {
311                 boolean ret = bindings.NodeFeatures_supports_payment_secret(this.ptr);
312                 Reference.reachabilityFence(this);
313                 return ret;
314         }
315
316         /**
317          * Checks if this feature is required.
318          */
319         public boolean requires_payment_secret() {
320                 boolean ret = bindings.NodeFeatures_requires_payment_secret(this.ptr);
321                 Reference.reachabilityFence(this);
322                 return ret;
323         }
324
325         /**
326          * Set this feature as optional.
327          */
328         public void set_basic_mpp_optional() {
329                 bindings.NodeFeatures_set_basic_mpp_optional(this.ptr);
330                 Reference.reachabilityFence(this);
331         }
332
333         /**
334          * Set this feature as required.
335          */
336         public void set_basic_mpp_required() {
337                 bindings.NodeFeatures_set_basic_mpp_required(this.ptr);
338                 Reference.reachabilityFence(this);
339         }
340
341         /**
342          * Checks if this feature is supported.
343          */
344         public boolean supports_basic_mpp() {
345                 boolean ret = bindings.NodeFeatures_supports_basic_mpp(this.ptr);
346                 Reference.reachabilityFence(this);
347                 return ret;
348         }
349
350         /**
351          * Checks if this feature is required.
352          */
353         public boolean requires_basic_mpp() {
354                 boolean ret = bindings.NodeFeatures_requires_basic_mpp(this.ptr);
355                 Reference.reachabilityFence(this);
356                 return ret;
357         }
358
359         /**
360          * Set this feature as optional.
361          */
362         public void set_wumbo_optional() {
363                 bindings.NodeFeatures_set_wumbo_optional(this.ptr);
364                 Reference.reachabilityFence(this);
365         }
366
367         /**
368          * Set this feature as required.
369          */
370         public void set_wumbo_required() {
371                 bindings.NodeFeatures_set_wumbo_required(this.ptr);
372                 Reference.reachabilityFence(this);
373         }
374
375         /**
376          * Checks if this feature is supported.
377          */
378         public boolean supports_wumbo() {
379                 boolean ret = bindings.NodeFeatures_supports_wumbo(this.ptr);
380                 Reference.reachabilityFence(this);
381                 return ret;
382         }
383
384         /**
385          * Checks if this feature is required.
386          */
387         public boolean requires_wumbo() {
388                 boolean ret = bindings.NodeFeatures_requires_wumbo(this.ptr);
389                 Reference.reachabilityFence(this);
390                 return ret;
391         }
392
393         /**
394          * Set this feature as optional.
395          */
396         public void set_shutdown_any_segwit_optional() {
397                 bindings.NodeFeatures_set_shutdown_any_segwit_optional(this.ptr);
398                 Reference.reachabilityFence(this);
399         }
400
401         /**
402          * Set this feature as required.
403          */
404         public void set_shutdown_any_segwit_required() {
405                 bindings.NodeFeatures_set_shutdown_any_segwit_required(this.ptr);
406                 Reference.reachabilityFence(this);
407         }
408
409         /**
410          * Checks if this feature is supported.
411          */
412         public boolean supports_shutdown_anysegwit() {
413                 boolean ret = bindings.NodeFeatures_supports_shutdown_anysegwit(this.ptr);
414                 Reference.reachabilityFence(this);
415                 return ret;
416         }
417
418         /**
419          * Checks if this feature is required.
420          */
421         public boolean requires_shutdown_anysegwit() {
422                 boolean ret = bindings.NodeFeatures_requires_shutdown_anysegwit(this.ptr);
423                 Reference.reachabilityFence(this);
424                 return ret;
425         }
426
427         /**
428          * Set this feature as optional.
429          */
430         public void set_onion_messages_optional() {
431                 bindings.NodeFeatures_set_onion_messages_optional(this.ptr);
432                 Reference.reachabilityFence(this);
433         }
434
435         /**
436          * Set this feature as required.
437          */
438         public void set_onion_messages_required() {
439                 bindings.NodeFeatures_set_onion_messages_required(this.ptr);
440                 Reference.reachabilityFence(this);
441         }
442
443         /**
444          * Checks if this feature is supported.
445          */
446         public boolean supports_onion_messages() {
447                 boolean ret = bindings.NodeFeatures_supports_onion_messages(this.ptr);
448                 Reference.reachabilityFence(this);
449                 return ret;
450         }
451
452         /**
453          * Checks if this feature is required.
454          */
455         public boolean requires_onion_messages() {
456                 boolean ret = bindings.NodeFeatures_requires_onion_messages(this.ptr);
457                 Reference.reachabilityFence(this);
458                 return ret;
459         }
460
461         /**
462          * Set this feature as optional.
463          */
464         public void set_channel_type_optional() {
465                 bindings.NodeFeatures_set_channel_type_optional(this.ptr);
466                 Reference.reachabilityFence(this);
467         }
468
469         /**
470          * Set this feature as required.
471          */
472         public void set_channel_type_required() {
473                 bindings.NodeFeatures_set_channel_type_required(this.ptr);
474                 Reference.reachabilityFence(this);
475         }
476
477         /**
478          * Checks if this feature is supported.
479          */
480         public boolean supports_channel_type() {
481                 boolean ret = bindings.NodeFeatures_supports_channel_type(this.ptr);
482                 Reference.reachabilityFence(this);
483                 return ret;
484         }
485
486         /**
487          * Checks if this feature is required.
488          */
489         public boolean requires_channel_type() {
490                 boolean ret = bindings.NodeFeatures_requires_channel_type(this.ptr);
491                 Reference.reachabilityFence(this);
492                 return ret;
493         }
494
495         /**
496          * Set this feature as optional.
497          */
498         public void set_scid_privacy_optional() {
499                 bindings.NodeFeatures_set_scid_privacy_optional(this.ptr);
500                 Reference.reachabilityFence(this);
501         }
502
503         /**
504          * Set this feature as required.
505          */
506         public void set_scid_privacy_required() {
507                 bindings.NodeFeatures_set_scid_privacy_required(this.ptr);
508                 Reference.reachabilityFence(this);
509         }
510
511         /**
512          * Checks if this feature is supported.
513          */
514         public boolean supports_scid_privacy() {
515                 boolean ret = bindings.NodeFeatures_supports_scid_privacy(this.ptr);
516                 Reference.reachabilityFence(this);
517                 return ret;
518         }
519
520         /**
521          * Checks if this feature is required.
522          */
523         public boolean requires_scid_privacy() {
524                 boolean ret = bindings.NodeFeatures_requires_scid_privacy(this.ptr);
525                 Reference.reachabilityFence(this);
526                 return ret;
527         }
528
529         /**
530          * Set this feature as optional.
531          */
532         public void set_zero_conf_optional() {
533                 bindings.NodeFeatures_set_zero_conf_optional(this.ptr);
534                 Reference.reachabilityFence(this);
535         }
536
537         /**
538          * Set this feature as required.
539          */
540         public void set_zero_conf_required() {
541                 bindings.NodeFeatures_set_zero_conf_required(this.ptr);
542                 Reference.reachabilityFence(this);
543         }
544
545         /**
546          * Checks if this feature is supported.
547          */
548         public boolean supports_zero_conf() {
549                 boolean ret = bindings.NodeFeatures_supports_zero_conf(this.ptr);
550                 Reference.reachabilityFence(this);
551                 return ret;
552         }
553
554         /**
555          * Checks if this feature is required.
556          */
557         public boolean requires_zero_conf() {
558                 boolean ret = bindings.NodeFeatures_requires_zero_conf(this.ptr);
559                 Reference.reachabilityFence(this);
560                 return ret;
561         }
562
563         /**
564          * Set this feature as optional.
565          */
566         public void set_keysend_optional() {
567                 bindings.NodeFeatures_set_keysend_optional(this.ptr);
568                 Reference.reachabilityFence(this);
569         }
570
571         /**
572          * Set this feature as required.
573          */
574         public void set_keysend_required() {
575                 bindings.NodeFeatures_set_keysend_required(this.ptr);
576                 Reference.reachabilityFence(this);
577         }
578
579         /**
580          * Checks if this feature is supported.
581          */
582         public boolean supports_keysend() {
583                 boolean ret = bindings.NodeFeatures_supports_keysend(this.ptr);
584                 Reference.reachabilityFence(this);
585                 return ret;
586         }
587
588         /**
589          * Checks if this feature is required.
590          */
591         public boolean requires_keysend() {
592                 boolean ret = bindings.NodeFeatures_requires_keysend(this.ptr);
593                 Reference.reachabilityFence(this);
594                 return ret;
595         }
596
597 }