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 the channel_type field in an OpenChannel message.
14 * A channel is always of some known \"type\", describing the transaction formats used and the exact
15 * semantics of our interaction with our peer.
17 * Note that because a channel is a specific type which is proposed by the opener and accepted by
18 * the counterparty, only required features are allowed here.
20 * This is serialized differently from other feature types - it is not prefixed by a length, and
21 * thus must only appear inside a TLV where its length is known in advance.
23 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
24 public class ChannelTypeFeatures extends CommonBase {
25 ChannelTypeFeatures(Object _dummy, long ptr) { super(ptr); }
26 @Override @SuppressWarnings("deprecation")
27 protected void finalize() throws Throwable {
29 if (ptr != 0) { bindings.ChannelTypeFeatures_free(ptr); }
33 * Checks if two ChannelTypeFeaturess contain equal inner contents.
34 * This ignores pointers and is_owned flags and looks at the values in fields.
35 * Two objects with NULL inner values will be considered "equal" here.
37 public boolean eq(ChannelTypeFeatures b) {
38 boolean ret = bindings.ChannelTypeFeatures_eq(this.ptr, b == null ? 0 : b.ptr);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(b);
41 if (this != null) { this.ptrs_to.add(b); };
45 @Override public boolean equals(Object o) {
46 if (!(o instanceof ChannelTypeFeatures)) return false;
47 return this.eq((ChannelTypeFeatures)o);
50 long ret = bindings.ChannelTypeFeatures_clone_ptr(this.ptr);
51 Reference.reachabilityFence(this);
56 * Creates a copy of the ChannelTypeFeatures
58 public ChannelTypeFeatures clone() {
59 long ret = bindings.ChannelTypeFeatures_clone(this.ptr);
60 Reference.reachabilityFence(this);
61 if (ret >= 0 && ret <= 4096) { return null; }
62 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
63 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
68 * Create a blank Features with no features set
70 public static ChannelTypeFeatures empty() {
71 long ret = bindings.ChannelTypeFeatures_empty();
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79 * Creates a Features with the bits set which are known by the implementation
81 public static ChannelTypeFeatures known() {
82 long ret = bindings.ChannelTypeFeatures_known();
83 if (ret >= 0 && ret <= 4096) { return null; }
84 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
90 * Returns true if this `Features` object contains unknown feature flags which are set as
93 public boolean requires_unknown_bits() {
94 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
95 Reference.reachabilityFence(this);
100 * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
102 public byte[] write() {
103 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
104 Reference.reachabilityFence(this);
109 * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
111 public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
112 long ret = bindings.ChannelTypeFeatures_read(ser);
113 Reference.reachabilityFence(ser);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
120 * Set this feature as optional.
122 public void set_static_remote_key_optional() {
123 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
124 Reference.reachabilityFence(this);
128 * Set this feature as required.
130 public void set_static_remote_key_required() {
131 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
132 Reference.reachabilityFence(this);
136 * Checks if this feature is supported.
138 public boolean supports_static_remote_key() {
139 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
140 Reference.reachabilityFence(this);
145 * Checks if this feature is required.
147 public boolean requires_static_remote_key() {
148 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
149 Reference.reachabilityFence(this);
154 * Set this feature as optional.
156 public void set_scid_privacy_optional() {
157 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
158 Reference.reachabilityFence(this);
162 * Set this feature as required.
164 public void set_scid_privacy_required() {
165 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
166 Reference.reachabilityFence(this);
170 * Checks if this feature is supported.
172 public boolean supports_scid_privacy() {
173 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
174 Reference.reachabilityFence(this);
179 * Checks if this feature is required.
181 public boolean requires_scid_privacy() {
182 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
183 Reference.reachabilityFence(this);
188 * Set this feature as optional.
190 public void set_zero_conf_optional() {
191 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
192 Reference.reachabilityFence(this);
196 * Set this feature as required.
198 public void set_zero_conf_required() {
199 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
200 Reference.reachabilityFence(this);
204 * Checks if this feature is supported.
206 public boolean supports_zero_conf() {
207 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
208 Reference.reachabilityFence(this);
213 * Checks if this feature is required.
215 public boolean requires_zero_conf() {
216 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
217 Reference.reachabilityFence(this);