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 * Details about a channel (both directions).
13 * Received within a channel announcement.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ChannelInfo extends CommonBase {
17 ChannelInfo(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
25 * Protocol features of a channel communicated during its announcement
27 public ChannelFeatures get_features() {
28 long ret = bindings.ChannelInfo_get_features(this.ptr);
29 Reference.reachabilityFence(this);
30 if (ret >= 0 && ret <= 4096) { return null; }
31 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
32 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
37 * Protocol features of a channel communicated during its announcement
39 public void set_features(org.ldk.structs.ChannelFeatures val) {
40 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr);
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
43 if (this != null) { this.ptrs_to.add(val); };
47 * Source node of the first direction of a channel
49 public NodeId get_node_one() {
50 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59 * Source node of the first direction of a channel
61 public void set_node_one(org.ldk.structs.NodeId val) {
62 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
65 if (this != null) { this.ptrs_to.add(val); };
69 * Details about the first direction of a channel
71 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
74 public ChannelUpdateInfo get_one_to_two() {
75 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
76 Reference.reachabilityFence(this);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
84 * Details about the first direction of a channel
86 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
88 public void set_one_to_two(@Nullable org.ldk.structs.ChannelUpdateInfo val) {
89 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr);
90 Reference.reachabilityFence(this);
91 Reference.reachabilityFence(val);
92 if (this != null) { this.ptrs_to.add(val); };
96 * Source node of the second direction of a channel
98 public NodeId get_node_two() {
99 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
100 Reference.reachabilityFence(this);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108 * Source node of the second direction of a channel
110 public void set_node_two(org.ldk.structs.NodeId val) {
111 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr);
112 Reference.reachabilityFence(this);
113 Reference.reachabilityFence(val);
114 if (this != null) { this.ptrs_to.add(val); };
118 * Details about the second direction of a channel
120 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
123 public ChannelUpdateInfo get_two_to_one() {
124 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
125 Reference.reachabilityFence(this);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133 * Details about the second direction of a channel
135 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
137 public void set_two_to_one(@Nullable org.ldk.structs.ChannelUpdateInfo val) {
138 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr);
139 Reference.reachabilityFence(this);
140 Reference.reachabilityFence(val);
141 if (this != null) { this.ptrs_to.add(val); };
145 * The channel capacity as seen on-chain, if chain lookup is available.
147 public Option_u64Z get_capacity_sats() {
148 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
149 Reference.reachabilityFence(this);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
157 * The channel capacity as seen on-chain, if chain lookup is available.
159 public void set_capacity_sats(org.ldk.structs.Option_u64Z val) {
160 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
161 Reference.reachabilityFence(this);
162 Reference.reachabilityFence(val);
163 if (this != null) { this.ptrs_to.add(val); };
167 * An initial announcement of the channel
168 * Mostly redundant with the data we store in fields explicitly.
169 * Everything else is useful only for sending out for initial routing sync.
170 * Not stored if contains excess data to prevent DoS.
172 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
175 public ChannelAnnouncement get_announcement_message() {
176 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
177 Reference.reachabilityFence(this);
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
185 * An initial announcement of the channel
186 * Mostly redundant with the data we store in fields explicitly.
187 * Everything else is useful only for sending out for initial routing sync.
188 * Not stored if contains excess data to prevent DoS.
190 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
192 public void set_announcement_message(@Nullable org.ldk.structs.ChannelAnnouncement val) {
193 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
194 Reference.reachabilityFence(this);
195 Reference.reachabilityFence(val);
196 if (this != null) { this.ptrs_to.add(val); };
200 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
201 Reference.reachabilityFence(this);
206 * Creates a copy of the ChannelInfo
208 public ChannelInfo clone() {
209 long ret = bindings.ChannelInfo_clone(this.ptr);
210 Reference.reachabilityFence(this);
211 if (ret >= 0 && ret <= 4096) { return null; }
212 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
213 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
218 * Checks if two ChannelInfos contain equal inner contents.
219 * This ignores pointers and is_owned flags and looks at the values in fields.
220 * Two objects with NULL inner values will be considered "equal" here.
222 public boolean eq(org.ldk.structs.ChannelInfo b) {
223 boolean ret = bindings.ChannelInfo_eq(this.ptr, b == null ? 0 : b.ptr);
224 Reference.reachabilityFence(this);
225 Reference.reachabilityFence(b);
226 if (this != null) { this.ptrs_to.add(b); };
230 @Override public boolean equals(Object o) {
231 if (!(o instanceof ChannelInfo)) return false;
232 return this.eq((ChannelInfo)o);
235 * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
237 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
240 public ChannelUpdateInfo get_directional_info(byte channel_flags) {
241 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
242 Reference.reachabilityFence(this);
243 Reference.reachabilityFence(channel_flags);
244 if (ret >= 0 && ret <= 4096) { return null; }
245 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
246 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
251 * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
253 public byte[] write() {
254 byte[] ret = bindings.ChannelInfo_write(this.ptr);
255 Reference.reachabilityFence(this);
260 * Read a ChannelInfo from a byte array, created by ChannelInfo_write
262 public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
263 long ret = bindings.ChannelInfo_read(ser);
264 Reference.reachabilityFence(ser);
265 if (ret >= 0 && ret <= 4096) { return null; }
266 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);