]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/Bolt11InvoiceFeatures.java
Update CI references to LDK 0.0.124 drop stale memchr pins
[ldk-java] / src / main / java / org / ldk / structs / Bolt11InvoiceFeatures.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 an invoice.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Bolt11InvoiceFeatures extends CommonBase {
16         Bolt11InvoiceFeatures(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Bolt11InvoiceFeatures_free(ptr); }
21         }
22
23         /**
24          * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read
25          */
26         public byte[] write() {
27                 byte[] ret = bindings.Bolt11InvoiceFeatures_write(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write
34          */
35         public static Result_Bolt11InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
36                 long ret = bindings.Bolt11InvoiceFeatures_read(ser);
37                 Reference.reachabilityFence(ser);
38                 if (ret >= 0 && ret <= 4096) { return null; }
39                 Result_Bolt11InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt11InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
40                 return ret_hu_conv;
41         }
42
43         /**
44          * Checks if two Bolt11InvoiceFeaturess contain equal inner contents.
45          * This ignores pointers and is_owned flags and looks at the values in fields.
46          * Two objects with NULL inner values will be considered "equal" here.
47          */
48         public boolean eq(org.ldk.structs.Bolt11InvoiceFeatures b) {
49                 boolean ret = bindings.Bolt11InvoiceFeatures_eq(this.ptr, b.ptr);
50                 Reference.reachabilityFence(this);
51                 Reference.reachabilityFence(b);
52                 if (this != null) { this.ptrs_to.add(b); };
53                 return ret;
54         }
55
56         @Override public boolean equals(Object o) {
57                 if (!(o instanceof Bolt11InvoiceFeatures)) return false;
58                 return this.eq((Bolt11InvoiceFeatures)o);
59         }
60         long clone_ptr() {
61                 long ret = bindings.Bolt11InvoiceFeatures_clone_ptr(this.ptr);
62                 Reference.reachabilityFence(this);
63                 return ret;
64         }
65
66         /**
67          * Creates a copy of the Bolt11InvoiceFeatures
68          */
69         public Bolt11InvoiceFeatures clone() {
70                 long ret = bindings.Bolt11InvoiceFeatures_clone(this.ptr);
71                 Reference.reachabilityFence(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures.
80          */
81         public long hash() {
82                 long ret = bindings.Bolt11InvoiceFeatures_hash(this.ptr);
83                 Reference.reachabilityFence(this);
84                 return ret;
85         }
86
87         @Override public int hashCode() {
88                 return (int)this.hash();
89         }
90         /**
91          * Getting a route for a keysend payment to a private node requires providing the payee's
92          * features (since they were not announced in a node announcement). However, keysend payments
93          * don't have an invoice to pull the payee's features from, so this method is provided for use
94          * when a [`Bolt11InvoiceFeatures`] is required in a route.
95          * 
96          * MPP keysend is not widely supported yet, so we parameterize support to allow the user to
97          * choose whether their router should find multi-part routes.
98          */
99         public static Bolt11InvoiceFeatures for_keysend(boolean allow_mpp) {
100                 long ret = bindings.Bolt11InvoiceFeatures_for_keysend(allow_mpp);
101                 Reference.reachabilityFence(allow_mpp);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Create a blank Features with no features set
110          */
111         public static Bolt11InvoiceFeatures empty() {
112                 long ret = bindings.Bolt11InvoiceFeatures_empty();
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
116                 return ret_hu_conv;
117         }
118
119         /**
120          * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order
121          * from most on-the-wire encodings.
122          */
123         public byte[] le_flags() {
124                 byte[] ret = bindings.Bolt11InvoiceFeatures_le_flags(this.ptr);
125                 Reference.reachabilityFence(this);
126                 return ret;
127         }
128
129         /**
130          * Returns true if this `Features` has any optional flags set
131          */
132         public boolean supports_any_optional_bits() {
133                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_any_optional_bits(this.ptr);
134                 Reference.reachabilityFence(this);
135                 return ret;
136         }
137
138         /**
139          * Returns true if this `Features` object contains required features unknown by `other`.
140          */
141         public boolean requires_unknown_bits_from(org.ldk.structs.Bolt11InvoiceFeatures other) {
142                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits_from(this.ptr, other.ptr);
143                 Reference.reachabilityFence(this);
144                 Reference.reachabilityFence(other);
145                 if (this != null) { this.ptrs_to.add(other); };
146                 return ret;
147         }
148
149         /**
150          * Returns the set of required features unknown by `other`, as their bit position.
151          */
152         public long[] required_unknown_bits_from(org.ldk.structs.Bolt11InvoiceFeatures other) {
153                 long[] ret = bindings.Bolt11InvoiceFeatures_required_unknown_bits_from(this.ptr, other.ptr);
154                 Reference.reachabilityFence(this);
155                 Reference.reachabilityFence(other);
156                 if (this != null) { this.ptrs_to.add(other); };
157                 return ret;
158         }
159
160         /**
161          * Returns true if this `Features` object contains unknown feature flags which are set as
162          * \"required\".
163          */
164         public boolean requires_unknown_bits() {
165                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits(this.ptr);
166                 Reference.reachabilityFence(this);
167                 return ret;
168         }
169
170         /**
171          * Returns true if this `Features` supports any bits which we do not know of
172          */
173         public boolean supports_unknown_bits() {
174                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_unknown_bits(this.ptr);
175                 Reference.reachabilityFence(this);
176                 return ret;
177         }
178
179         /**
180          * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
181          * by [BOLT 9].
182          * 
183          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
184          * be set instead (i.e., `bit - 1`).
185          * 
186          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
187          */
188         public Result_NoneNoneZ set_required_feature_bit(long bit) {
189                 long ret = bindings.Bolt11InvoiceFeatures_set_required_feature_bit(this.ptr, bit);
190                 Reference.reachabilityFence(this);
191                 Reference.reachabilityFence(bit);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
194                 return ret_hu_conv;
195         }
196
197         /**
198          * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
199          * by [BOLT 9].
200          * 
201          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
202          * set instead (i.e., `bit + 1`).
203          * 
204          * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
205          */
206         public Result_NoneNoneZ set_optional_feature_bit(long bit) {
207                 long ret = bindings.Bolt11InvoiceFeatures_set_optional_feature_bit(this.ptr, bit);
208                 Reference.reachabilityFence(this);
209                 Reference.reachabilityFence(bit);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
217          * by [bLIP 2] or if it is a known `T` feature.
218          * 
219          * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
220          * be set instead (i.e., `bit - 1`).
221          * 
222          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
223          */
224         public Result_NoneNoneZ set_required_custom_bit(long bit) {
225                 long ret = bindings.Bolt11InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
226                 Reference.reachabilityFence(this);
227                 Reference.reachabilityFence(bit);
228                 if (ret >= 0 && ret <= 4096) { return null; }
229                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
230                 return ret_hu_conv;
231         }
232
233         /**
234          * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
235          * by [bLIP 2] or if it is a known `T` feature.
236          * 
237          * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
238          * set instead (i.e., `bit + 1`).
239          * 
240          * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
241          */
242         public Result_NoneNoneZ set_optional_custom_bit(long bit) {
243                 long ret = bindings.Bolt11InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
244                 Reference.reachabilityFence(this);
245                 Reference.reachabilityFence(bit);
246                 if (ret >= 0 && ret <= 4096) { return null; }
247                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
248                 return ret_hu_conv;
249         }
250
251         /**
252          * Set this feature as optional.
253          */
254         public void set_variable_length_onion_optional() {
255                 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_optional(this.ptr);
256                 Reference.reachabilityFence(this);
257         }
258
259         /**
260          * Set this feature as required.
261          */
262         public void set_variable_length_onion_required() {
263                 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_required(this.ptr);
264                 Reference.reachabilityFence(this);
265         }
266
267         /**
268          * Checks if this feature is supported.
269          */
270         public boolean supports_variable_length_onion() {
271                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_variable_length_onion(this.ptr);
272                 Reference.reachabilityFence(this);
273                 return ret;
274         }
275
276         /**
277          * Checks if this feature is required.
278          */
279         public boolean requires_variable_length_onion() {
280                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_variable_length_onion(this.ptr);
281                 Reference.reachabilityFence(this);
282                 return ret;
283         }
284
285         /**
286          * Set this feature as optional.
287          */
288         public void set_payment_secret_optional() {
289                 bindings.Bolt11InvoiceFeatures_set_payment_secret_optional(this.ptr);
290                 Reference.reachabilityFence(this);
291         }
292
293         /**
294          * Set this feature as required.
295          */
296         public void set_payment_secret_required() {
297                 bindings.Bolt11InvoiceFeatures_set_payment_secret_required(this.ptr);
298                 Reference.reachabilityFence(this);
299         }
300
301         /**
302          * Checks if this feature is supported.
303          */
304         public boolean supports_payment_secret() {
305                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_secret(this.ptr);
306                 Reference.reachabilityFence(this);
307                 return ret;
308         }
309
310         /**
311          * Checks if this feature is required.
312          */
313         public boolean requires_payment_secret() {
314                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_secret(this.ptr);
315                 Reference.reachabilityFence(this);
316                 return ret;
317         }
318
319         /**
320          * Set this feature as optional.
321          */
322         public void set_basic_mpp_optional() {
323                 bindings.Bolt11InvoiceFeatures_set_basic_mpp_optional(this.ptr);
324                 Reference.reachabilityFence(this);
325         }
326
327         /**
328          * Set this feature as required.
329          */
330         public void set_basic_mpp_required() {
331                 bindings.Bolt11InvoiceFeatures_set_basic_mpp_required(this.ptr);
332                 Reference.reachabilityFence(this);
333         }
334
335         /**
336          * Checks if this feature is supported.
337          */
338         public boolean supports_basic_mpp() {
339                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_basic_mpp(this.ptr);
340                 Reference.reachabilityFence(this);
341                 return ret;
342         }
343
344         /**
345          * Checks if this feature is required.
346          */
347         public boolean requires_basic_mpp() {
348                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_basic_mpp(this.ptr);
349                 Reference.reachabilityFence(this);
350                 return ret;
351         }
352
353         /**
354          * Set this feature as optional.
355          */
356         public void set_payment_metadata_optional() {
357                 bindings.Bolt11InvoiceFeatures_set_payment_metadata_optional(this.ptr);
358                 Reference.reachabilityFence(this);
359         }
360
361         /**
362          * Set this feature as required.
363          */
364         public void set_payment_metadata_required() {
365                 bindings.Bolt11InvoiceFeatures_set_payment_metadata_required(this.ptr);
366                 Reference.reachabilityFence(this);
367         }
368
369         /**
370          * Checks if this feature is supported.
371          */
372         public boolean supports_payment_metadata() {
373                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_metadata(this.ptr);
374                 Reference.reachabilityFence(this);
375                 return ret;
376         }
377
378         /**
379          * Checks if this feature is required.
380          */
381         public boolean requires_payment_metadata() {
382                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_metadata(this.ptr);
383                 Reference.reachabilityFence(this);
384                 return ret;
385         }
386
387         /**
388          * Set this feature as optional.
389          */
390         public void set_trampoline_routing_optional() {
391                 bindings.Bolt11InvoiceFeatures_set_trampoline_routing_optional(this.ptr);
392                 Reference.reachabilityFence(this);
393         }
394
395         /**
396          * Set this feature as required.
397          */
398         public void set_trampoline_routing_required() {
399                 bindings.Bolt11InvoiceFeatures_set_trampoline_routing_required(this.ptr);
400                 Reference.reachabilityFence(this);
401         }
402
403         /**
404          * Checks if this feature is supported.
405          */
406         public boolean supports_trampoline_routing() {
407                 boolean ret = bindings.Bolt11InvoiceFeatures_supports_trampoline_routing(this.ptr);
408                 Reference.reachabilityFence(this);
409                 return ret;
410         }
411
412         /**
413          * Checks if this feature is required.
414          */
415         public boolean requires_trampoline_routing() {
416                 boolean ret = bindings.Bolt11InvoiceFeatures_requires_trampoline_routing(this.ptr);
417                 Reference.reachabilityFence(this);
418                 return ret;
419         }
420
421 }