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 InvoiceFeatures extends CommonBase {
16 InvoiceFeatures(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.InvoiceFeatures_free(ptr); }
24 * Checks if two InvoiceFeaturess 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(InvoiceFeatures b) {
29 boolean ret = bindings.InvoiceFeatures_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
30 Reference.reachabilityFence(this);
31 Reference.reachabilityFence(b);
36 @Override public boolean equals(Object o) {
37 if (!(o instanceof InvoiceFeatures)) return false;
38 return this.eq((InvoiceFeatures)o);
41 long ret = bindings.InvoiceFeatures_clone_ptr(this.ptr);
42 Reference.reachabilityFence(this);
47 * Creates a copy of the InvoiceFeatures
49 public InvoiceFeatures clone() {
50 long ret = bindings.InvoiceFeatures_clone(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
54 ret_hu_conv.ptrs_to.add(this);
59 * Create a blank Features with no features set
61 public static InvoiceFeatures empty() {
62 long ret = bindings.InvoiceFeatures_empty();
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
65 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70 * Creates a Features with the bits set which are known by the implementation
72 public static InvoiceFeatures known() {
73 long ret = bindings.InvoiceFeatures_known();
74 if (ret >= 0 && ret <= 4096) { return null; }
75 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
76 ret_hu_conv.ptrs_to.add(ret_hu_conv);
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.InvoiceFeatures_requires_unknown_bits(this.ptr);
86 Reference.reachabilityFence(this);
91 * Serialize the InvoiceFeatures object into a byte array which can be read by InvoiceFeatures_read
93 public byte[] write() {
94 byte[] ret = bindings.InvoiceFeatures_write(this.ptr);
95 Reference.reachabilityFence(this);
100 * Read a InvoiceFeatures from a byte array, created by InvoiceFeatures_write
102 public static Result_InvoiceFeaturesDecodeErrorZ read(byte[] ser) {
103 long ret = bindings.InvoiceFeatures_read(ser);
104 Reference.reachabilityFence(ser);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 Result_InvoiceFeaturesDecodeErrorZ ret_hu_conv = Result_InvoiceFeaturesDecodeErrorZ.constr_from_ptr(ret);
111 * Set this feature as optional.
113 public void set_variable_length_onion_optional() {
114 bindings.InvoiceFeatures_set_variable_length_onion_optional(this.ptr);
115 Reference.reachabilityFence(this);
119 * Set this feature as required.
121 public void set_variable_length_onion_required() {
122 bindings.InvoiceFeatures_set_variable_length_onion_required(this.ptr);
123 Reference.reachabilityFence(this);
127 * Checks if this feature is supported.
129 public boolean supports_variable_length_onion() {
130 boolean ret = bindings.InvoiceFeatures_supports_variable_length_onion(this.ptr);
131 Reference.reachabilityFence(this);
136 * Checks if this feature is required.
138 public boolean requires_variable_length_onion() {
139 boolean ret = bindings.InvoiceFeatures_requires_variable_length_onion(this.ptr);
140 Reference.reachabilityFence(this);
145 * Set this feature as optional.
147 public void set_payment_secret_optional() {
148 bindings.InvoiceFeatures_set_payment_secret_optional(this.ptr);
149 Reference.reachabilityFence(this);
153 * Set this feature as required.
155 public void set_payment_secret_required() {
156 bindings.InvoiceFeatures_set_payment_secret_required(this.ptr);
157 Reference.reachabilityFence(this);
161 * Checks if this feature is supported.
163 public boolean supports_payment_secret() {
164 boolean ret = bindings.InvoiceFeatures_supports_payment_secret(this.ptr);
165 Reference.reachabilityFence(this);
170 * Checks if this feature is required.
172 public boolean requires_payment_secret() {
173 boolean ret = bindings.InvoiceFeatures_requires_payment_secret(this.ptr);
174 Reference.reachabilityFence(this);
179 * Set this feature as optional.
181 public void set_basic_mpp_optional() {
182 bindings.InvoiceFeatures_set_basic_mpp_optional(this.ptr);
183 Reference.reachabilityFence(this);
187 * Set this feature as required.
189 public void set_basic_mpp_required() {
190 bindings.InvoiceFeatures_set_basic_mpp_required(this.ptr);
191 Reference.reachabilityFence(this);
195 * Checks if this feature is supported.
197 public boolean supports_basic_mpp() {
198 boolean ret = bindings.InvoiceFeatures_supports_basic_mpp(this.ptr);
199 Reference.reachabilityFence(this);
204 * Checks if this feature is required.
206 public boolean requires_basic_mpp() {
207 boolean ret = bindings.InvoiceFeatures_requires_basic_mpp(this.ptr);
208 Reference.reachabilityFence(this);