54b7de0bf7b72e841aad56b08eb8569c12396900
[ldk-java] / src / main / java / org / ldk / structs / ChannelTypeFeatures.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Features used within the channel_type field in an OpenChannel message.
13  * 
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.
16  * 
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.
19  * 
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.
22  */
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 {
28                 super.finalize();
29                 if (ptr != 0) { bindings.ChannelTypeFeatures_free(ptr); }
30         }
31
32         /**
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.
36          */
37         public boolean eq(org.ldk.structs.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); };
42                 return ret;
43         }
44
45         @Override public boolean equals(Object o) {
46                 if (!(o instanceof ChannelTypeFeatures)) return false;
47                 return this.eq((ChannelTypeFeatures)o);
48         }
49         long clone_ptr() {
50                 long ret = bindings.ChannelTypeFeatures_clone_ptr(this.ptr);
51                 Reference.reachabilityFence(this);
52                 return ret;
53         }
54
55         /**
56          * Creates a copy of the ChannelTypeFeatures
57          */
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); };
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Create a blank Features with no features set
69          */
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); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Returns true if this `Features` object contains unknown feature flags which are set as
80          * \"required\".
81          */
82         public boolean requires_unknown_bits() {
83                 boolean ret = bindings.ChannelTypeFeatures_requires_unknown_bits(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read
90          */
91         public byte[] write() {
92                 byte[] ret = bindings.ChannelTypeFeatures_write(this.ptr);
93                 Reference.reachabilityFence(this);
94                 return ret;
95         }
96
97         /**
98          * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write
99          */
100         public static Result_ChannelTypeFeaturesDecodeErrorZ read(byte[] ser) {
101                 long ret = bindings.ChannelTypeFeatures_read(ser);
102                 Reference.reachabilityFence(ser);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 Result_ChannelTypeFeaturesDecodeErrorZ ret_hu_conv = Result_ChannelTypeFeaturesDecodeErrorZ.constr_from_ptr(ret);
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Set this feature as optional.
110          */
111         public void set_static_remote_key_optional() {
112                 bindings.ChannelTypeFeatures_set_static_remote_key_optional(this.ptr);
113                 Reference.reachabilityFence(this);
114         }
115
116         /**
117          * Set this feature as required.
118          */
119         public void set_static_remote_key_required() {
120                 bindings.ChannelTypeFeatures_set_static_remote_key_required(this.ptr);
121                 Reference.reachabilityFence(this);
122         }
123
124         /**
125          * Checks if this feature is supported.
126          */
127         public boolean supports_static_remote_key() {
128                 boolean ret = bindings.ChannelTypeFeatures_supports_static_remote_key(this.ptr);
129                 Reference.reachabilityFence(this);
130                 return ret;
131         }
132
133         /**
134          * Checks if this feature is required.
135          */
136         public boolean requires_static_remote_key() {
137                 boolean ret = bindings.ChannelTypeFeatures_requires_static_remote_key(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * Set this feature as optional.
144          */
145         public void set_scid_privacy_optional() {
146                 bindings.ChannelTypeFeatures_set_scid_privacy_optional(this.ptr);
147                 Reference.reachabilityFence(this);
148         }
149
150         /**
151          * Set this feature as required.
152          */
153         public void set_scid_privacy_required() {
154                 bindings.ChannelTypeFeatures_set_scid_privacy_required(this.ptr);
155                 Reference.reachabilityFence(this);
156         }
157
158         /**
159          * Checks if this feature is supported.
160          */
161         public boolean supports_scid_privacy() {
162                 boolean ret = bindings.ChannelTypeFeatures_supports_scid_privacy(this.ptr);
163                 Reference.reachabilityFence(this);
164                 return ret;
165         }
166
167         /**
168          * Checks if this feature is required.
169          */
170         public boolean requires_scid_privacy() {
171                 boolean ret = bindings.ChannelTypeFeatures_requires_scid_privacy(this.ptr);
172                 Reference.reachabilityFence(this);
173                 return ret;
174         }
175
176         /**
177          * Set this feature as optional.
178          */
179         public void set_zero_conf_optional() {
180                 bindings.ChannelTypeFeatures_set_zero_conf_optional(this.ptr);
181                 Reference.reachabilityFence(this);
182         }
183
184         /**
185          * Set this feature as required.
186          */
187         public void set_zero_conf_required() {
188                 bindings.ChannelTypeFeatures_set_zero_conf_required(this.ptr);
189                 Reference.reachabilityFence(this);
190         }
191
192         /**
193          * Checks if this feature is supported.
194          */
195         public boolean supports_zero_conf() {
196                 boolean ret = bindings.ChannelTypeFeatures_supports_zero_conf(this.ptr);
197                 Reference.reachabilityFence(this);
198                 return ret;
199         }
200
201         /**
202          * Checks if this feature is required.
203          */
204         public boolean requires_zero_conf() {
205                 boolean ret = bindings.ChannelTypeFeatures_requires_zero_conf(this.ptr);
206                 Reference.reachabilityFence(this);
207                 return ret;
208         }
209
210 }