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 Bolt12InvoiceFeatures extends CommonBase {
16 Bolt12InvoiceFeatures(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Bolt12InvoiceFeatures_free(ptr); }
24 * Checks if two Bolt12InvoiceFeaturess 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.Bolt12InvoiceFeatures b) {
29 boolean ret = bindings.Bolt12InvoiceFeatures_eq(this.ptr, 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 Bolt12InvoiceFeatures)) return false;
38 return this.eq((Bolt12InvoiceFeatures)o);
41 long ret = bindings.Bolt12InvoiceFeatures_clone_ptr(this.ptr);
42 Reference.reachabilityFence(this);
47 * Creates a copy of the Bolt12InvoiceFeatures
49 public Bolt12InvoiceFeatures clone() {
50 long ret = bindings.Bolt12InvoiceFeatures_clone(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(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 Bolt12InvoiceFeatures.
62 long ret = bindings.Bolt12InvoiceFeatures_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 Bolt12InvoiceFeatures empty() {
74 long ret = bindings.Bolt12InvoiceFeatures_empty();
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(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.Bolt12InvoiceFeatures other) {
85 boolean ret = bindings.Bolt12InvoiceFeatures_requires_unknown_bits_from(this.ptr, 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.Bolt12InvoiceFeatures_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.Bolt12InvoiceFeatures_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.Bolt12InvoiceFeatures_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.Bolt12InvoiceFeatures_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.Bolt12InvoiceFeatures_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 Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read
177 public byte[] write() {
178 byte[] ret = bindings.Bolt12InvoiceFeatures_write(this.ptr);
179 Reference.reachabilityFence(this);
184 * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write
186 public static Result_Bolt12InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
187 long ret = bindings.Bolt12InvoiceFeatures_read(ser);
188 Reference.reachabilityFence(ser);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 Result_Bolt12InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_Bolt12InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
195 * Set this feature as optional.
197 public void set_basic_mpp_optional() {
198 bindings.Bolt12InvoiceFeatures_set_basic_mpp_optional(this.ptr);
199 Reference.reachabilityFence(this);
203 * Set this feature as required.
205 public void set_basic_mpp_required() {
206 bindings.Bolt12InvoiceFeatures_set_basic_mpp_required(this.ptr);
207 Reference.reachabilityFence(this);
211 * Checks if this feature is supported.
213 public boolean supports_basic_mpp() {
214 boolean ret = bindings.Bolt12InvoiceFeatures_supports_basic_mpp(this.ptr);
215 Reference.reachabilityFence(this);
220 * Checks if this feature is required.
222 public boolean requires_basic_mpp() {
223 boolean ret = bindings.Bolt12InvoiceFeatures_requires_basic_mpp(this.ptr);
224 Reference.reachabilityFence(this);