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 * Create a blank Features with no features set
61 public static BlindedHopFeatures empty() {
62 long ret = bindings.BlindedHopFeatures_empty();
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.BlindedHopFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHopFeatures(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.BlindedHopFeatures other) {
73 boolean ret = bindings.BlindedHopFeatures_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.BlindedHopFeatures_requires_unknown_bits(this.ptr);
86 Reference.reachabilityFence(this);
91 * Sets a required feature bit. Errors if `bit` is outside the feature range as defined
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 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
99 public Result_NoneNoneZ set_required_feature_bit(long bit) {
100 long ret = bindings.BlindedHopFeatures_set_required_feature_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 feature bit. Errors if `bit` is outside the feature range as defined
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 * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md
117 public Result_NoneNoneZ set_optional_feature_bit(long bit) {
118 long ret = bindings.BlindedHopFeatures_set_optional_feature_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 * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined
128 * by [bLIP 2] or if it is a known `T` feature.
130 * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will
131 * be set instead (i.e., `bit - 1`).
133 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
135 public Result_NoneNoneZ set_required_custom_bit(long bit) {
136 long ret = bindings.BlindedHopFeatures_set_required_custom_bit(this.ptr, bit);
137 Reference.reachabilityFence(this);
138 Reference.reachabilityFence(bit);
139 if (ret >= 0 && ret <= 4096) { return null; }
140 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
145 * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined
146 * by [bLIP 2] or if it is a known `T` feature.
148 * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be
149 * set instead (i.e., `bit + 1`).
151 * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits
153 public Result_NoneNoneZ set_optional_custom_bit(long bit) {
154 long ret = bindings.BlindedHopFeatures_set_optional_custom_bit(this.ptr, bit);
155 Reference.reachabilityFence(this);
156 Reference.reachabilityFence(bit);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
163 * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read
165 public byte[] write() {
166 byte[] ret = bindings.BlindedHopFeatures_write(this.ptr);
167 Reference.reachabilityFence(this);
172 * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write
174 public static Result_BlindedHopFeaturesDecodeErrorZ read(byte[] ser) {
175 long ret = bindings.BlindedHopFeatures_read(ser);
176 Reference.reachabilityFence(ser);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 Result_BlindedHopFeaturesDecodeErrorZ ret_hu_conv = Result_BlindedHopFeaturesDecodeErrorZ.constr_from_ptr(ret);