1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Features used within an invoice.
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 {
20 if (ptr != 0) { bindings.Bolt11InvoiceFeatures_free(ptr); }
24 * Checks if two Bolt11InvoiceFeaturess 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.
28 public boolean eq(org.ldk.structs.Bolt11InvoiceFeatures b) {
29 boolean ret = bindings.Bolt11InvoiceFeatures_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); };
36 @Override public boolean equals(Object o) {
37 if (!(o instanceof Bolt11InvoiceFeatures)) return false;
38 return this.eq((Bolt11InvoiceFeatures)o);
41 long ret = bindings.Bolt11InvoiceFeatures_clone_ptr(this.ptr);
42 Reference.reachabilityFence(this);
47 * Creates a copy of the Bolt11InvoiceFeatures
49 public Bolt11InvoiceFeatures clone() {
50 long ret = bindings.Bolt11InvoiceFeatures_clone(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59 * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures.
62 long ret = bindings.Bolt11InvoiceFeatures_hash(this.ptr);
63 Reference.reachabilityFence(this);
67 @Override public int hashCode() {
68 return (int)this.hash();
71 * Create a blank Features with no features set
73 public static Bolt11InvoiceFeatures empty() {
74 long ret = bindings.Bolt11InvoiceFeatures_empty();
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
77 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
82 * Returns true if this `Features` object contains required features unknown by `other`.
84 public boolean requires_unknown_bits_from(org.ldk.structs.Bolt11InvoiceFeatures other) {
85 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
86 Reference.reachabilityFence(this);
87 Reference.reachabilityFence(other);
88 if (this != null) { this.ptrs_to.add(other); };
93 * Returns true if this `Features` object contains unknown feature flags which are set as
96 public boolean requires_unknown_bits() {
97 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits(this.ptr);
98 Reference.reachabilityFence(this);
103 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
106 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
107 * be set instead (i.e., `bit - 1`).
109 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
111 public Result_NoneNoneZ set_required_feature_bit(long bit) {
112 long ret = bindings.Bolt11InvoiceFeatures_set_required_feature_bit(this.ptr, bit);
113 Reference.reachabilityFence(this);
114 Reference.reachabilityFence(bit);
115 if (ret >= 0 && ret <= 4096) { return null; }
116 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
121 * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined
124 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
125 * set instead (i.e., `bit + 1`).
127 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
129 public Result_NoneNoneZ set_optional_feature_bit(long bit) {
130 long ret = bindings.Bolt11InvoiceFeatures_set_optional_feature_bit(this.ptr, bit);
131 Reference.reachabilityFence(this);
132 Reference.reachabilityFence(bit);
133 if (ret >= 0 && ret <= 4096) { return null; }
134 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
139 * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
140 * by [bLIP 2] or if it is a known `T` feature.
142 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
143 * be set instead (i.e., `bit - 1`).
145 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
147 public Result_NoneNoneZ set_required_custom_bit(long bit) {
148 long ret = bindings.Bolt11InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
149 Reference.reachabilityFence(this);
150 Reference.reachabilityFence(bit);
151 if (ret >= 0 && ret <= 4096) { return null; }
152 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
157 * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
158 * by [bLIP 2] or if it is a known `T` feature.
160 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
161 * set instead (i.e., `bit + 1`).
163 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
165 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
166 long ret = bindings.Bolt11InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
167 Reference.reachabilityFence(this);
168 Reference.reachabilityFence(bit);
169 if (ret >= 0 && ret <= 4096) { return null; }
170 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
175 * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read
177 public byte[] write() {
178 byte[] ret = bindings.Bolt11InvoiceFeatures_write(this.ptr);
179 Reference.reachabilityFence(this);
184 * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write
186 public static Result_Bolt11InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
187 long ret = bindings.Bolt11InvoiceFeatures_read(ser);
188 Reference.reachabilityFence(ser);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 Result_Bolt11InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt11InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
195 * Set this feature as optional.
197 public void set_variable_length_onion_optional() {
198 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_optional(this.ptr);
199 Reference.reachabilityFence(this);
203 * Set this feature as required.
205 public void set_variable_length_onion_required() {
206 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_required(this.ptr);
207 Reference.reachabilityFence(this);
211 * Checks if this feature is supported.
213 public boolean supports_variable_length_onion() {
214 boolean ret = bindings.Bolt11InvoiceFeatures_supports_variable_length_onion(this.ptr);
215 Reference.reachabilityFence(this);
220 * Checks if this feature is required.
222 public boolean requires_variable_length_onion() {
223 boolean ret = bindings.Bolt11InvoiceFeatures_requires_variable_length_onion(this.ptr);
224 Reference.reachabilityFence(this);
229 * Set this feature as optional.
231 public void set_payment_secret_optional() {
232 bindings.Bolt11InvoiceFeatures_set_payment_secret_optional(this.ptr);
233 Reference.reachabilityFence(this);
237 * Set this feature as required.
239 public void set_payment_secret_required() {
240 bindings.Bolt11InvoiceFeatures_set_payment_secret_required(this.ptr);
241 Reference.reachabilityFence(this);
245 * Checks if this feature is supported.
247 public boolean supports_payment_secret() {
248 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_secret(this.ptr);
249 Reference.reachabilityFence(this);
254 * Checks if this feature is required.
256 public boolean requires_payment_secret() {
257 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_secret(this.ptr);
258 Reference.reachabilityFence(this);
263 * Set this feature as optional.
265 public void set_basic_mpp_optional() {
266 bindings.Bolt11InvoiceFeatures_set_basic_mpp_optional(this.ptr);
267 Reference.reachabilityFence(this);
271 * Set this feature as required.
273 public void set_basic_mpp_required() {
274 bindings.Bolt11InvoiceFeatures_set_basic_mpp_required(this.ptr);
275 Reference.reachabilityFence(this);
279 * Checks if this feature is supported.
281 public boolean supports_basic_mpp() {
282 boolean ret = bindings.Bolt11InvoiceFeatures_supports_basic_mpp(this.ptr);
283 Reference.reachabilityFence(this);
288 * Checks if this feature is required.
290 public boolean requires_basic_mpp() {
291 boolean ret = bindings.Bolt11InvoiceFeatures_requires_basic_mpp(this.ptr);
292 Reference.reachabilityFence(this);
297 * Set this feature as optional.
299 public void set_payment_metadata_optional() {
300 bindings.Bolt11InvoiceFeatures_set_payment_metadata_optional(this.ptr);
301 Reference.reachabilityFence(this);
305 * Set this feature as required.
307 public void set_payment_metadata_required() {
308 bindings.Bolt11InvoiceFeatures_set_payment_metadata_required(this.ptr);
309 Reference.reachabilityFence(this);
313 * Checks if this feature is supported.
315 public boolean supports_payment_metadata() {
316 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_metadata(this.ptr);
317 Reference.reachabilityFence(this);
322 * Checks if this feature is required.
324 public boolean requires_payment_metadata() {
325 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_metadata(this.ptr);
326 Reference.reachabilityFence(this);