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 * Create a blank Features with no features set
61 public static Bolt11InvoiceFeatures empty() {
62 long ret = bindings.Bolt11InvoiceFeatures_empty();
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
65 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
70 * Returns true if this `Features` object contains required features unknown by `other`.
72 public boolean requires_unknown_bits_from(org.ldk.structs.Bolt11InvoiceFeatures other) {
73 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits_from(this.ptr, other == null ? 0 : other.ptr);
74 Reference.reachabilityFence(this);
75 Reference.reachabilityFence(other);
76 if (this != null) { this.ptrs_to.add(other); };
81 * Returns true if this `Features` object contains unknown feature flags which are set as
84 public boolean requires_unknown_bits() {
85 boolean ret = bindings.Bolt11InvoiceFeatures_requires_unknown_bits(this.ptr);
86 Reference.reachabilityFence(this);
91 * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
92 * by [bLIP 2] or if it is a known `T` feature.
94 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
95 * be set instead (i.e., `bit - 1`).
97 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
99 public Result_NoneNoneZ set_required_custom_bit(long bit) {
100 long ret = bindings.Bolt11InvoiceFeatures_set_required_custom_bit(this.ptr, bit);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(bit);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
109 * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
110 * by [bLIP 2] or if it is a known `T` feature.
112 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
113 * set instead (i.e., `bit + 1`).
115 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
117 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
118 long ret = bindings.Bolt11InvoiceFeatures_set_optional_custom_bit(this.ptr, bit);
119 Reference.reachabilityFence(this);
120 Reference.reachabilityFence(bit);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
127 * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read
129 public byte[] write() {
130 byte[] ret = bindings.Bolt11InvoiceFeatures_write(this.ptr);
131 Reference.reachabilityFence(this);
136 * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write
138 public static Result_Bolt11InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
139 long ret = bindings.Bolt11InvoiceFeatures_read(ser);
140 Reference.reachabilityFence(ser);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 Result_Bolt11InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt11InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
147 * Set this feature as optional.
149 public void set_variable_length_onion_optional() {
150 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_optional(this.ptr);
151 Reference.reachabilityFence(this);
155 * Set this feature as required.
157 public void set_variable_length_onion_required() {
158 bindings.Bolt11InvoiceFeatures_set_variable_length_onion_required(this.ptr);
159 Reference.reachabilityFence(this);
163 * Checks if this feature is supported.
165 public boolean supports_variable_length_onion() {
166 boolean ret = bindings.Bolt11InvoiceFeatures_supports_variable_length_onion(this.ptr);
167 Reference.reachabilityFence(this);
172 * Checks if this feature is required.
174 public boolean requires_variable_length_onion() {
175 boolean ret = bindings.Bolt11InvoiceFeatures_requires_variable_length_onion(this.ptr);
176 Reference.reachabilityFence(this);
181 * Set this feature as optional.
183 public void set_payment_secret_optional() {
184 bindings.Bolt11InvoiceFeatures_set_payment_secret_optional(this.ptr);
185 Reference.reachabilityFence(this);
189 * Set this feature as required.
191 public void set_payment_secret_required() {
192 bindings.Bolt11InvoiceFeatures_set_payment_secret_required(this.ptr);
193 Reference.reachabilityFence(this);
197 * Checks if this feature is supported.
199 public boolean supports_payment_secret() {
200 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_secret(this.ptr);
201 Reference.reachabilityFence(this);
206 * Checks if this feature is required.
208 public boolean requires_payment_secret() {
209 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_secret(this.ptr);
210 Reference.reachabilityFence(this);
215 * Set this feature as optional.
217 public void set_basic_mpp_optional() {
218 bindings.Bolt11InvoiceFeatures_set_basic_mpp_optional(this.ptr);
219 Reference.reachabilityFence(this);
223 * Set this feature as required.
225 public void set_basic_mpp_required() {
226 bindings.Bolt11InvoiceFeatures_set_basic_mpp_required(this.ptr);
227 Reference.reachabilityFence(this);
231 * Checks if this feature is supported.
233 public boolean supports_basic_mpp() {
234 boolean ret = bindings.Bolt11InvoiceFeatures_supports_basic_mpp(this.ptr);
235 Reference.reachabilityFence(this);
240 * Checks if this feature is required.
242 public boolean requires_basic_mpp() {
243 boolean ret = bindings.Bolt11InvoiceFeatures_requires_basic_mpp(this.ptr);
244 Reference.reachabilityFence(this);
249 * Set this feature as optional.
251 public void set_payment_metadata_optional() {
252 bindings.Bolt11InvoiceFeatures_set_payment_metadata_optional(this.ptr);
253 Reference.reachabilityFence(this);
257 * Set this feature as required.
259 public void set_payment_metadata_required() {
260 bindings.Bolt11InvoiceFeatures_set_payment_metadata_required(this.ptr);
261 Reference.reachabilityFence(this);
265 * Checks if this feature is supported.
267 public boolean supports_payment_metadata() {
268 boolean ret = bindings.Bolt11InvoiceFeatures_supports_payment_metadata(this.ptr);
269 Reference.reachabilityFence(this);
274 * Checks if this feature is required.
276 public boolean requires_payment_metadata() {
277 boolean ret = bindings.Bolt11InvoiceFeatures_requires_payment_metadata(this.ptr);
278 Reference.reachabilityFence(this);