84f27848bf43a6f550784ea2a88463d050e3378d
[ldk-java] / c_sharp / src / org / ldk / structs / NodeFeatures.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  * Features used within a `node_announcement` message.
11  */
12 public class NodeFeatures : CommonBase {
13         internal NodeFeatures(object _dummy, long ptr) : base(ptr) { }
14         ~NodeFeatures() {
15                 if (ptr != 0) { bindings.NodeFeatures_free(ptr); }
16         }
17
18         /**
19          * Checks if two NodeFeaturess contain equal inner contents.
20          * This ignores pointers and is_owned flags and looks at the values in fields.
21          * Two objects with NULL inner values will be considered "equal" here.
22          */
23         public bool eq(org.ldk.structs.NodeFeatures b) {
24                 bool ret = bindings.NodeFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
25                 GC.KeepAlive(this);
26                 GC.KeepAlive(b);
27                 if (this != null) { this.ptrs_to.AddLast(b); };
28                 return ret;
29         }
30
31         public override bool Equals(object o) {
32                 if (!(o is NodeFeatures)) return false;
33                 return this.eq((NodeFeatures)o);
34         }
35         internal long clone_ptr() {
36                 long ret = bindings.NodeFeatures_clone_ptr(this.ptr);
37                 GC.KeepAlive(this);
38                 return ret;
39         }
40
41         /**
42          * Creates a copy of the NodeFeatures
43          */
44         public NodeFeatures clone() {
45                 long ret = bindings.NodeFeatures_clone(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Create a blank Features with no features set
55          */
56         public static NodeFeatures empty() {
57                 long ret = bindings.NodeFeatures_empty();
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
61                 return ret_hu_conv;
62         }
63
64         /**
65          * Returns true if this `Features` object contains required features unknown by `other`.
66          */
67         public bool requires_unknown_bits_from(org.ldk.structs.NodeFeatures other) {
68                 bool ret = bindings.NodeFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(other);
71                 if (this != null) { this.ptrs_to.AddLast(other); };
72                 return ret;
73         }
74
75         /**
76          * Returns true if this `Features` object contains unknown feature flags which are set as
77          * \"required\".
78          */
79         public bool requires_unknown_bits() {
80                 bool ret = bindings.NodeFeatures_requires_unknown_bits(this.ptr);
81                 GC.KeepAlive(this);
82                 return ret;
83         }
84
85         /**
86          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
87          * by [bLIP 2] or if it is a known `T` feature.
88          * 
89          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
90          * be set instead (i.e., `bit - 1`).
91          * 
92          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
93          */
94         public Result_NoneNoneZ set_required_custom_bit(long bit) {
95                 long ret = bindings.NodeFeatures_set_required_custom_bit(this.ptr, bit);
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(bit);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
100                 return ret_hu_conv;
101         }
102
103         /**
104          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
105          * by [bLIP 2] or if it is a known `T` feature.
106          * 
107          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
108          * set instead (i.e., `bit + 1`).
109          * 
110          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
111          */
112         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
113                 long ret = bindings.NodeFeatures_set_optional_custom_bit(this.ptr, bit);
114                 GC.KeepAlive(this);
115                 GC.KeepAlive(bit);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read
123          */
124         public byte[] write() {
125                 byte[] ret = bindings.NodeFeatures_write(this.ptr);
126                 GC.KeepAlive(this);
127                 return ret;
128         }
129
130         /**
131          * Read a NodeFeatures from a byte array, created by NodeFeatures_write
132          */
133         public static Result_NodeFeaturesDecodeErrorZ read(byte[] ser) {
134                 long ret = bindings.NodeFeatures_read(ser);
135                 GC.KeepAlive(ser);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 Result_NodeFeaturesDecodeErrorZ ret_hu_conv = Result_NodeFeaturesDecodeErrorZ.constr_from_ptr(ret);
138                 return ret_hu_conv;
139         }
140
141         /**
142          * Set this feature as optional.
143          */
144         public void set_data_loss_protect_optional() {
145                 bindings.NodeFeatures_set_data_loss_protect_optional(this.ptr);
146                 GC.KeepAlive(this);
147         }
148
149         /**
150          * Set this feature as required.
151          */
152         public void set_data_loss_protect_required() {
153                 bindings.NodeFeatures_set_data_loss_protect_required(this.ptr);
154                 GC.KeepAlive(this);
155         }
156
157         /**
158          * Checks if this feature is supported.
159          */
160         public bool supports_data_loss_protect() {
161                 bool ret = bindings.NodeFeatures_supports_data_loss_protect(this.ptr);
162                 GC.KeepAlive(this);
163                 return ret;
164         }
165
166         /**
167          * Checks if this feature is required.
168          */
169         public bool requires_data_loss_protect() {
170                 bool ret = bindings.NodeFeatures_requires_data_loss_protect(this.ptr);
171                 GC.KeepAlive(this);
172                 return ret;
173         }
174
175         /**
176          * Set this feature as optional.
177          */
178         public void set_upfront_shutdown_script_optional() {
179                 bindings.NodeFeatures_set_upfront_shutdown_script_optional(this.ptr);
180                 GC.KeepAlive(this);
181         }
182
183         /**
184          * Set this feature as required.
185          */
186         public void set_upfront_shutdown_script_required() {
187                 bindings.NodeFeatures_set_upfront_shutdown_script_required(this.ptr);
188                 GC.KeepAlive(this);
189         }
190
191         /**
192          * Checks if this feature is supported.
193          */
194         public bool supports_upfront_shutdown_script() {
195                 bool ret = bindings.NodeFeatures_supports_upfront_shutdown_script(this.ptr);
196                 GC.KeepAlive(this);
197                 return ret;
198         }
199
200         /**
201          * Checks if this feature is required.
202          */
203         public bool requires_upfront_shutdown_script() {
204                 bool ret = bindings.NodeFeatures_requires_upfront_shutdown_script(this.ptr);
205                 GC.KeepAlive(this);
206                 return ret;
207         }
208
209         /**
210          * Set this feature as optional.
211          */
212         public void set_gossip_queries_optional() {
213                 bindings.NodeFeatures_set_gossip_queries_optional(this.ptr);
214                 GC.KeepAlive(this);
215         }
216
217         /**
218          * Set this feature as required.
219          */
220         public void set_gossip_queries_required() {
221                 bindings.NodeFeatures_set_gossip_queries_required(this.ptr);
222                 GC.KeepAlive(this);
223         }
224
225         /**
226          * Checks if this feature is supported.
227          */
228         public bool supports_gossip_queries() {
229                 bool ret = bindings.NodeFeatures_supports_gossip_queries(this.ptr);
230                 GC.KeepAlive(this);
231                 return ret;
232         }
233
234         /**
235          * Checks if this feature is required.
236          */
237         public bool requires_gossip_queries() {
238                 bool ret = bindings.NodeFeatures_requires_gossip_queries(this.ptr);
239                 GC.KeepAlive(this);
240                 return ret;
241         }
242
243         /**
244          * Set this feature as optional.
245          */
246         public void set_variable_length_onion_optional() {
247                 bindings.NodeFeatures_set_variable_length_onion_optional(this.ptr);
248                 GC.KeepAlive(this);
249         }
250
251         /**
252          * Set this feature as required.
253          */
254         public void set_variable_length_onion_required() {
255                 bindings.NodeFeatures_set_variable_length_onion_required(this.ptr);
256                 GC.KeepAlive(this);
257         }
258
259         /**
260          * Checks if this feature is supported.
261          */
262         public bool supports_variable_length_onion() {
263                 bool ret = bindings.NodeFeatures_supports_variable_length_onion(this.ptr);
264                 GC.KeepAlive(this);
265                 return ret;
266         }
267
268         /**
269          * Checks if this feature is required.
270          */
271         public bool requires_variable_length_onion() {
272                 bool ret = bindings.NodeFeatures_requires_variable_length_onion(this.ptr);
273                 GC.KeepAlive(this);
274                 return ret;
275         }
276
277         /**
278          * Set this feature as optional.
279          */
280         public void set_static_remote_key_optional() {
281                 bindings.NodeFeatures_set_static_remote_key_optional(this.ptr);
282                 GC.KeepAlive(this);
283         }
284
285         /**
286          * Set this feature as required.
287          */
288         public void set_static_remote_key_required() {
289                 bindings.NodeFeatures_set_static_remote_key_required(this.ptr);
290                 GC.KeepAlive(this);
291         }
292
293         /**
294          * Checks if this feature is supported.
295          */
296         public bool supports_static_remote_key() {
297                 bool ret = bindings.NodeFeatures_supports_static_remote_key(this.ptr);
298                 GC.KeepAlive(this);
299                 return ret;
300         }
301
302         /**
303          * Checks if this feature is required.
304          */
305         public bool requires_static_remote_key() {
306                 bool ret = bindings.NodeFeatures_requires_static_remote_key(this.ptr);
307                 GC.KeepAlive(this);
308                 return ret;
309         }
310
311         /**
312          * Set this feature as optional.
313          */
314         public void set_payment_secret_optional() {
315                 bindings.NodeFeatures_set_payment_secret_optional(this.ptr);
316                 GC.KeepAlive(this);
317         }
318
319         /**
320          * Set this feature as required.
321          */
322         public void set_payment_secret_required() {
323                 bindings.NodeFeatures_set_payment_secret_required(this.ptr);
324                 GC.KeepAlive(this);
325         }
326
327         /**
328          * Checks if this feature is supported.
329          */
330         public bool supports_payment_secret() {
331                 bool ret = bindings.NodeFeatures_supports_payment_secret(this.ptr);
332                 GC.KeepAlive(this);
333                 return ret;
334         }
335
336         /**
337          * Checks if this feature is required.
338          */
339         public bool requires_payment_secret() {
340                 bool ret = bindings.NodeFeatures_requires_payment_secret(this.ptr);
341                 GC.KeepAlive(this);
342                 return ret;
343         }
344
345         /**
346          * Set this feature as optional.
347          */
348         public void set_basic_mpp_optional() {
349                 bindings.NodeFeatures_set_basic_mpp_optional(this.ptr);
350                 GC.KeepAlive(this);
351         }
352
353         /**
354          * Set this feature as required.
355          */
356         public void set_basic_mpp_required() {
357                 bindings.NodeFeatures_set_basic_mpp_required(this.ptr);
358                 GC.KeepAlive(this);
359         }
360
361         /**
362          * Checks if this feature is supported.
363          */
364         public bool supports_basic_mpp() {
365                 bool ret = bindings.NodeFeatures_supports_basic_mpp(this.ptr);
366                 GC.KeepAlive(this);
367                 return ret;
368         }
369
370         /**
371          * Checks if this feature is required.
372          */
373         public bool requires_basic_mpp() {
374                 bool ret = bindings.NodeFeatures_requires_basic_mpp(this.ptr);
375                 GC.KeepAlive(this);
376                 return ret;
377         }
378
379         /**
380          * Set this feature as optional.
381          */
382         public void set_wumbo_optional() {
383                 bindings.NodeFeatures_set_wumbo_optional(this.ptr);
384                 GC.KeepAlive(this);
385         }
386
387         /**
388          * Set this feature as required.
389          */
390         public void set_wumbo_required() {
391                 bindings.NodeFeatures_set_wumbo_required(this.ptr);
392                 GC.KeepAlive(this);
393         }
394
395         /**
396          * Checks if this feature is supported.
397          */
398         public bool supports_wumbo() {
399                 bool ret = bindings.NodeFeatures_supports_wumbo(this.ptr);
400                 GC.KeepAlive(this);
401                 return ret;
402         }
403
404         /**
405          * Checks if this feature is required.
406          */
407         public bool requires_wumbo() {
408                 bool ret = bindings.NodeFeatures_requires_wumbo(this.ptr);
409                 GC.KeepAlive(this);
410                 return ret;
411         }
412
413         /**
414          * Set this feature as optional.
415          */
416         public void set_anchors_nonzero_fee_htlc_tx_optional() {
417                 bindings.NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this.ptr);
418                 GC.KeepAlive(this);
419         }
420
421         /**
422          * Set this feature as required.
423          */
424         public void set_anchors_nonzero_fee_htlc_tx_required() {
425                 bindings.NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this.ptr);
426                 GC.KeepAlive(this);
427         }
428
429         /**
430          * Checks if this feature is supported.
431          */
432         public bool supports_anchors_nonzero_fee_htlc_tx() {
433                 bool ret = bindings.NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this.ptr);
434                 GC.KeepAlive(this);
435                 return ret;
436         }
437
438         /**
439          * Checks if this feature is required.
440          */
441         public bool requires_anchors_nonzero_fee_htlc_tx() {
442                 bool ret = bindings.NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this.ptr);
443                 GC.KeepAlive(this);
444                 return ret;
445         }
446
447         /**
448          * Set this feature as optional.
449          */
450         public void set_anchors_zero_fee_htlc_tx_optional() {
451                 bindings.NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(this.ptr);
452                 GC.KeepAlive(this);
453         }
454
455         /**
456          * Set this feature as required.
457          */
458         public void set_anchors_zero_fee_htlc_tx_required() {
459                 bindings.NodeFeatures_set_anchors_zero_fee_htlc_tx_required(this.ptr);
460                 GC.KeepAlive(this);
461         }
462
463         /**
464          * Checks if this feature is supported.
465          */
466         public bool supports_anchors_zero_fee_htlc_tx() {
467                 bool ret = bindings.NodeFeatures_supports_anchors_zero_fee_htlc_tx(this.ptr);
468                 GC.KeepAlive(this);
469                 return ret;
470         }
471
472         /**
473          * Checks if this feature is required.
474          */
475         public bool requires_anchors_zero_fee_htlc_tx() {
476                 bool ret = bindings.NodeFeatures_requires_anchors_zero_fee_htlc_tx(this.ptr);
477                 GC.KeepAlive(this);
478                 return ret;
479         }
480
481         /**
482          * Set this feature as optional.
483          */
484         public void set_shutdown_any_segwit_optional() {
485                 bindings.NodeFeatures_set_shutdown_any_segwit_optional(this.ptr);
486                 GC.KeepAlive(this);
487         }
488
489         /**
490          * Set this feature as required.
491          */
492         public void set_shutdown_any_segwit_required() {
493                 bindings.NodeFeatures_set_shutdown_any_segwit_required(this.ptr);
494                 GC.KeepAlive(this);
495         }
496
497         /**
498          * Checks if this feature is supported.
499          */
500         public bool supports_shutdown_anysegwit() {
501                 bool ret = bindings.NodeFeatures_supports_shutdown_anysegwit(this.ptr);
502                 GC.KeepAlive(this);
503                 return ret;
504         }
505
506         /**
507          * Checks if this feature is required.
508          */
509         public bool requires_shutdown_anysegwit() {
510                 bool ret = bindings.NodeFeatures_requires_shutdown_anysegwit(this.ptr);
511                 GC.KeepAlive(this);
512                 return ret;
513         }
514
515         /**
516          * Set this feature as optional.
517          */
518         public void set_onion_messages_optional() {
519                 bindings.NodeFeatures_set_onion_messages_optional(this.ptr);
520                 GC.KeepAlive(this);
521         }
522
523         /**
524          * Set this feature as required.
525          */
526         public void set_onion_messages_required() {
527                 bindings.NodeFeatures_set_onion_messages_required(this.ptr);
528                 GC.KeepAlive(this);
529         }
530
531         /**
532          * Checks if this feature is supported.
533          */
534         public bool supports_onion_messages() {
535                 bool ret = bindings.NodeFeatures_supports_onion_messages(this.ptr);
536                 GC.KeepAlive(this);
537                 return ret;
538         }
539
540         /**
541          * Checks if this feature is required.
542          */
543         public bool requires_onion_messages() {
544                 bool ret = bindings.NodeFeatures_requires_onion_messages(this.ptr);
545                 GC.KeepAlive(this);
546                 return ret;
547         }
548
549         /**
550          * Set this feature as optional.
551          */
552         public void set_channel_type_optional() {
553                 bindings.NodeFeatures_set_channel_type_optional(this.ptr);
554                 GC.KeepAlive(this);
555         }
556
557         /**
558          * Set this feature as required.
559          */
560         public void set_channel_type_required() {
561                 bindings.NodeFeatures_set_channel_type_required(this.ptr);
562                 GC.KeepAlive(this);
563         }
564
565         /**
566          * Checks if this feature is supported.
567          */
568         public bool supports_channel_type() {
569                 bool ret = bindings.NodeFeatures_supports_channel_type(this.ptr);
570                 GC.KeepAlive(this);
571                 return ret;
572         }
573
574         /**
575          * Checks if this feature is required.
576          */
577         public bool requires_channel_type() {
578                 bool ret = bindings.NodeFeatures_requires_channel_type(this.ptr);
579                 GC.KeepAlive(this);
580                 return ret;
581         }
582
583         /**
584          * Set this feature as optional.
585          */
586         public void set_scid_privacy_optional() {
587                 bindings.NodeFeatures_set_scid_privacy_optional(this.ptr);
588                 GC.KeepAlive(this);
589         }
590
591         /**
592          * Set this feature as required.
593          */
594         public void set_scid_privacy_required() {
595                 bindings.NodeFeatures_set_scid_privacy_required(this.ptr);
596                 GC.KeepAlive(this);
597         }
598
599         /**
600          * Checks if this feature is supported.
601          */
602         public bool supports_scid_privacy() {
603                 bool ret = bindings.NodeFeatures_supports_scid_privacy(this.ptr);
604                 GC.KeepAlive(this);
605                 return ret;
606         }
607
608         /**
609          * Checks if this feature is required.
610          */
611         public bool requires_scid_privacy() {
612                 bool ret = bindings.NodeFeatures_requires_scid_privacy(this.ptr);
613                 GC.KeepAlive(this);
614                 return ret;
615         }
616
617         /**
618          * Set this feature as optional.
619          */
620         public void set_zero_conf_optional() {
621                 bindings.NodeFeatures_set_zero_conf_optional(this.ptr);
622                 GC.KeepAlive(this);
623         }
624
625         /**
626          * Set this feature as required.
627          */
628         public void set_zero_conf_required() {
629                 bindings.NodeFeatures_set_zero_conf_required(this.ptr);
630                 GC.KeepAlive(this);
631         }
632
633         /**
634          * Checks if this feature is supported.
635          */
636         public bool supports_zero_conf() {
637                 bool ret = bindings.NodeFeatures_supports_zero_conf(this.ptr);
638                 GC.KeepAlive(this);
639                 return ret;
640         }
641
642         /**
643          * Checks if this feature is required.
644          */
645         public bool requires_zero_conf() {
646                 bool ret = bindings.NodeFeatures_requires_zero_conf(this.ptr);
647                 GC.KeepAlive(this);
648                 return ret;
649         }
650
651         /**
652          * Set this feature as optional.
653          */
654         public void set_keysend_optional() {
655                 bindings.NodeFeatures_set_keysend_optional(this.ptr);
656                 GC.KeepAlive(this);
657         }
658
659         /**
660          * Set this feature as required.
661          */
662         public void set_keysend_required() {
663                 bindings.NodeFeatures_set_keysend_required(this.ptr);
664                 GC.KeepAlive(this);
665         }
666
667         /**
668          * Checks if this feature is supported.
669          */
670         public bool supports_keysend() {
671                 bool ret = bindings.NodeFeatures_supports_keysend(this.ptr);
672                 GC.KeepAlive(this);
673                 return ret;
674         }
675
676         /**
677          * Checks if this feature is required.
678          */
679         public bool requires_keysend() {
680                 bool ret = bindings.NodeFeatures_requires_keysend(this.ptr);
681                 GC.KeepAlive(this);
682                 return ret;
683         }
684
685 }
686 } } }