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 BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class BlindedHopFeatures extends CommonBase {
16 BlindedHopFeatures(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.BlindedHopFeatures_free(ptr); }
24 * Checks if two BlindedHopFeaturess 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.BlindedHopFeatures b) {
29 boolean ret = bindings.BlindedHopFeatures_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 BlindedHopFeatures)) return false;
38 return this.eq((BlindedHopFeatures)o);
41 long ret = bindings.BlindedHopFeatures_clone_ptr(this.ptr);
42 Reference.reachabilityFence(this);
47 * Creates a copy of the BlindedHopFeatures
49 public BlindedHopFeatures clone() {
50 long ret = bindings.BlindedHopFeatures_clone(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.BlindedHopFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHopFeatures(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 BlindedHopFeatures.
62 long ret = bindings.BlindedHopFeatures_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 BlindedHopFeatures empty() {
74 long ret = bindings.BlindedHopFeatures_empty();
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.BlindedHopFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHopFeatures(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.BlindedHopFeatures other) {
85 boolean ret = bindings.BlindedHopFeatures_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.BlindedHopFeatures_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.BlindedHopFeatures_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.BlindedHopFeatures_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.BlindedHopFeatures_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.BlindedHopFeatures_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 BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read
177 public byte[] write() {
178 byte[] ret = bindings.BlindedHopFeatures_write(this.ptr);
179 Reference.reachabilityFence(this);
184 * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write
186 public static Result_BlindedHopFeaturesDecodeErrorZ read(byte[] ser) {
187 long ret = bindings.BlindedHopFeatures_read(ser);
188 Reference.reachabilityFence(ser);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 Result_BlindedHopFeaturesDecodeErrorZ ret_hu_conv = Result_BlindedHopFeaturesDecodeErrorZ.constr_from_ptr(ret);