b1e77cc44f480685e04c74e93e9e431713093f7a
[ldk-java] / c_sharp / src / org / ldk / structs / Bolt11InvoiceFeatures.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 an invoice.
11  */
12 public class Bolt11InvoiceFeatures : CommonBase {
13         internal Bolt11InvoiceFeatures(object _dummy, long ptr) : base(ptr) { }
14         ~Bolt11InvoiceFeatures() {
15                 if (ptr != 0) { bindings.Bolt11InvoiceFeatures_free(ptr); }
16         }
17
18         /**
19          * Checks if two Bolt11InvoiceFeaturess 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.Bolt11InvoiceFeatures b) {
24                 bool ret = bindings.Bolt11InvoiceFeatures_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 Bolt11InvoiceFeatures)) return false;
33                 return this.eq((Bolt11InvoiceFeatures)o);
34         }
35         internal long clone_ptr() {
36                 long ret = bindings.Bolt11InvoiceFeatures_clone_ptr(this.ptr);
37                 GC.KeepAlive(this);
38                 return ret;
39         }
40
41         /**
42          * Creates a copy of the Bolt11InvoiceFeatures
43          */
44         public Bolt11InvoiceFeatures clone() {
45                 long ret = bindings.Bolt11InvoiceFeatures_clone(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(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 Bolt11InvoiceFeatures empty() {
57                 long ret = bindings.Bolt11InvoiceFeatures_empty();
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(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.Bolt11InvoiceFeatures other) {
68                 bool ret = bindings.Bolt11InvoiceFeatures_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.Bolt11InvoiceFeatures_requires_unknown_bits(this.ptr);
81                 GC.KeepAlive(this);
82                 return ret;
83         }
84
85         /**
86          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
87          * by [BOLT 9].
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          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
93          */
94         public Result_NoneNoneZ set_required_feature_bit(long bit) {
95                 long ret = bindings.Bolt11InvoiceFeatures_set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined
105          * by [BOLT 9].
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          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
111          */
112         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
113                 long ret = bindings.Bolt11InvoiceFeatures_set_optional_feature_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          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
123          * by [bLIP 2] or if it is a known `T` feature.
124          * 
125          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
126          * be set instead (i.e., `bit - 1`).
127          * 
128          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
129          */
130         public Result_NoneNoneZ set_required_custom_bit(long bit) {
131                 long ret = bindings.Bolt11InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
132                 GC.KeepAlive(this);
133                 GC.KeepAlive(bit);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
136                 return ret_hu_conv;
137         }
138
139         /**
140          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
141          * by [bLIP 2] or if it is a known `T` feature.
142          * 
143          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
144          * set instead (i.e., `bit + 1`).
145          * 
146          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
147          */
148         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
149                 long ret = bindings.Bolt11InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
150                 GC.KeepAlive(this);
151                 GC.KeepAlive(bit);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read
159          */
160         public byte[] write() {
161                 long ret = bindings.Bolt11InvoiceFeatures_write(this.ptr);
162                 GC.KeepAlive(this);
163                 if (ret >= 0 && ret <= 4096) { return null; }
164                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
165                 return ret_conv;
166         }
167
168         /**
169          * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write
170          */
171         public static Result_Bolt11InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
172                 long ret = bindings.Bolt11InvoiceFeatures_read(InternalUtils.encodeUint8Array(ser));
173                 GC.KeepAlive(ser);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 Result_Bolt11InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt11InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Set this feature as optional.
181          */
182         public void set_variable_length_onion_optional() {
183                 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_optional(this.ptr);
184                 GC.KeepAlive(this);
185         }
186
187         /**
188          * Set this feature as required.
189          */
190         public void set_variable_length_onion_required() {
191                 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_required(this.ptr);
192                 GC.KeepAlive(this);
193         }
194
195         /**
196          * Checks if this feature is supported.
197          */
198         public bool supports_variable_length_onion() {
199                 bool ret = bindings.Bolt11InvoiceFeatures_supports_variable_length_onion(this.ptr);
200                 GC.KeepAlive(this);
201                 return ret;
202         }
203
204         /**
205          * Checks if this feature is required.
206          */
207         public bool requires_variable_length_onion() {
208                 bool ret = bindings.Bolt11InvoiceFeatures_requires_variable_length_onion(this.ptr);
209                 GC.KeepAlive(this);
210                 return ret;
211         }
212
213         /**
214          * Set this feature as optional.
215          */
216         public void set_payment_secret_optional() {
217                 bindings.Bolt11InvoiceFeatures_set_payment_secret_optional(this.ptr);
218                 GC.KeepAlive(this);
219         }
220
221         /**
222          * Set this feature as required.
223          */
224         public void set_payment_secret_required() {
225                 bindings.Bolt11InvoiceFeatures_set_payment_secret_required(this.ptr);
226                 GC.KeepAlive(this);
227         }
228
229         /**
230          * Checks if this feature is supported.
231          */
232         public bool supports_payment_secret() {
233                 bool ret = bindings.Bolt11InvoiceFeatures_supports_payment_secret(this.ptr);
234                 GC.KeepAlive(this);
235                 return ret;
236         }
237
238         /**
239          * Checks if this feature is required.
240          */
241         public bool requires_payment_secret() {
242                 bool ret = bindings.Bolt11InvoiceFeatures_requires_payment_secret(this.ptr);
243                 GC.KeepAlive(this);
244                 return ret;
245         }
246
247         /**
248          * Set this feature as optional.
249          */
250         public void set_basic_mpp_optional() {
251                 bindings.Bolt11InvoiceFeatures_set_basic_mpp_optional(this.ptr);
252                 GC.KeepAlive(this);
253         }
254
255         /**
256          * Set this feature as required.
257          */
258         public void set_basic_mpp_required() {
259                 bindings.Bolt11InvoiceFeatures_set_basic_mpp_required(this.ptr);
260                 GC.KeepAlive(this);
261         }
262
263         /**
264          * Checks if this feature is supported.
265          */
266         public bool supports_basic_mpp() {
267                 bool ret = bindings.Bolt11InvoiceFeatures_supports_basic_mpp(this.ptr);
268                 GC.KeepAlive(this);
269                 return ret;
270         }
271
272         /**
273          * Checks if this feature is required.
274          */
275         public bool requires_basic_mpp() {
276                 bool ret = bindings.Bolt11InvoiceFeatures_requires_basic_mpp(this.ptr);
277                 GC.KeepAlive(this);
278                 return ret;
279         }
280
281         /**
282          * Set this feature as optional.
283          */
284         public void set_payment_metadata_optional() {
285                 bindings.Bolt11InvoiceFeatures_set_payment_metadata_optional(this.ptr);
286                 GC.KeepAlive(this);
287         }
288
289         /**
290          * Set this feature as required.
291          */
292         public void set_payment_metadata_required() {
293                 bindings.Bolt11InvoiceFeatures_set_payment_metadata_required(this.ptr);
294                 GC.KeepAlive(this);
295         }
296
297         /**
298          * Checks if this feature is supported.
299          */
300         public bool supports_payment_metadata() {
301                 bool ret = bindings.Bolt11InvoiceFeatures_supports_payment_metadata(this.ptr);
302                 GC.KeepAlive(this);
303                 return ret;
304         }
305
306         /**
307          * Checks if this feature is required.
308          */
309         public bool requires_payment_metadata() {
310                 bool ret = bindings.Bolt11InvoiceFeatures_requires_payment_metadata(this.ptr);
311                 GC.KeepAlive(this);
312                 return ret;
313         }
314
315 }
316 } } }