[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelFeatures.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 `channel_announcement` message.
11  */
12 public class ChannelFeatures : CommonBase {
13         internal ChannelFeatures(object _dummy, long ptr) : base(ptr) { }
14         ~ChannelFeatures() {
15                 if (ptr != 0) { bindings.ChannelFeatures_free(ptr); }
16         }
17
18         /**
19          * Checks if two ChannelFeaturess 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.ChannelFeatures b) {
24                 bool ret = bindings.ChannelFeatures_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 ChannelFeatures)) return false;
33                 return this.eq((ChannelFeatures)o);
34         }
35         internal long clone_ptr() {
36                 long ret = bindings.ChannelFeatures_clone_ptr(this.ptr);
37                 GC.KeepAlive(this);
38                 return ret;
39         }
40
41         /**
42          * Creates a copy of the ChannelFeatures
43          */
44         public ChannelFeatures clone() {
45                 long ret = bindings.ChannelFeatures_clone(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
49                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
50                 return ret_hu_conv;
51         }
52
53         /**
54          * Generates a non-cryptographic 64-bit hash of the ChannelFeatures.
55          */
56         public long hash() {
57                 long ret = bindings.ChannelFeatures_hash(this.ptr);
58                 GC.KeepAlive(this);
59                 return ret;
60         }
61
62         public override int GetHashCode() {
63                 return (int)this.hash();
64         }
65         /**
66          * Create a blank Features with no features set
67          */
68         public static ChannelFeatures empty() {
69                 long ret = bindings.ChannelFeatures_empty();
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Returns true if this `Features` object contains required features unknown by `other`.
78          */
79         public bool requires_unknown_bits_from(org.ldk.structs.ChannelFeatures other) {
80                 bool ret = bindings.ChannelFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
81                 GC.KeepAlive(this);
82                 GC.KeepAlive(other);
83                 if (this != null) { this.ptrs_to.AddLast(other); };
84                 return ret;
85         }
86
87         /**
88          * Returns true if this `Features` object contains unknown feature flags which are set as
89          * \"required\".
90          */
91         public bool requires_unknown_bits() {
92                 bool ret = bindings.ChannelFeatures_requires_unknown_bits(this.ptr);
93                 GC.KeepAlive(this);
94                 return ret;
95         }
96
97         /**
98          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
99          * by [BOLT 9].
100          * 
101          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
102          * be set instead (i.e., `bit - 1`).
103          * 
104          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
105          */
106         public Result_NoneNoneZ set_required_feature_bit(long bit) {
107                 long ret = bindings.ChannelFeatures_set_required_feature_bit(this.ptr, bit);
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(bit);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
117          * by [BOLT 9].
118          * 
119          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
120          * set instead (i.e., `bit + 1`).
121          * 
122          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
123          */
124         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
125                 long ret = bindings.ChannelFeatures_set_optional_feature_bit(this.ptr, bit);
126                 GC.KeepAlive(this);
127                 GC.KeepAlive(bit);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
130                 return ret_hu_conv;
131         }
132
133         /**
134          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
135          * by [bLIP 2] or if it is a known `T` feature.
136          * 
137          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
138          * be set instead (i.e., `bit - 1`).
139          * 
140          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
141          */
142         public Result_NoneNoneZ set_required_custom_bit(long bit) {
143                 long ret = bindings.ChannelFeatures_set_required_custom_bit(this.ptr, bit);
144                 GC.KeepAlive(this);
145                 GC.KeepAlive(bit);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
153          * by [bLIP 2] or if it is a known `T` feature.
154          * 
155          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
156          * set instead (i.e., `bit + 1`).
157          * 
158          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
159          */
160         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
161                 long ret = bindings.ChannelFeatures_set_optional_custom_bit(this.ptr, bit);
162                 GC.KeepAlive(this);
163                 GC.KeepAlive(bit);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read
171          */
172         public byte[] write() {
173                 long ret = bindings.ChannelFeatures_write(this.ptr);
174                 GC.KeepAlive(this);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
177                 return ret_conv;
178         }
179
180         /**
181          * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write
182          */
183         public static Result_ChannelFeaturesDecodeErrorZ read(byte[] ser) {
184                 long ret = bindings.ChannelFeatures_read(InternalUtils.encodeUint8Array(ser));
185                 GC.KeepAlive(ser);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 Result_ChannelFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelFeaturesDecodeErrorZ.constr_from_ptr(ret);
188                 return ret_hu_conv;
189         }
190
191 }
192 } } }