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 ret_hu_conv.ptrs_to.add(this);
37 * Protocol features of a channel communicated during its announcement
39 public void set_features(ChannelFeatures val) {
40 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * Source node of the first direction of a channel
48 public NodeId get_node_one() {
49 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
50 Reference.reachabilityFence(this);
51 if (ret >= 0 && ret <= 4096) { return null; }
52 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
53 ret_hu_conv.ptrs_to.add(this);
58 * Source node of the first direction of a channel
60 public void set_node_one(NodeId val) {
61 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr & ~1);
62 Reference.reachabilityFence(this);
63 Reference.reachabilityFence(val);
67 * Details about the first direction of a channel
69 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
72 public ChannelUpdateInfo get_one_to_two() {
73 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
74 Reference.reachabilityFence(this);
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
77 ret_hu_conv.ptrs_to.add(this);
82 * Details about the first direction of a channel
84 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
86 public void set_one_to_two(@Nullable ChannelUpdateInfo val) {
87 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1);
88 Reference.reachabilityFence(this);
89 Reference.reachabilityFence(val);
93 * Source node of the second direction of a channel
95 public NodeId get_node_two() {
96 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
97 Reference.reachabilityFence(this);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
100 ret_hu_conv.ptrs_to.add(this);
105 * Source node of the second direction of a channel
107 public void set_node_two(NodeId val) {
108 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr & ~1);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(val);
114 * Details about the second direction of a channel
116 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
119 public ChannelUpdateInfo get_two_to_one() {
120 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
121 Reference.reachabilityFence(this);
122 if (ret >= 0 && ret <= 4096) { return null; }
123 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
124 ret_hu_conv.ptrs_to.add(this);
129 * Details about the second direction of a channel
131 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
133 public void set_two_to_one(@Nullable ChannelUpdateInfo val) {
134 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1);
135 Reference.reachabilityFence(this);
136 Reference.reachabilityFence(val);
140 * The channel capacity as seen on-chain, if chain lookup is available.
142 public Option_u64Z get_capacity_sats() {
143 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
144 Reference.reachabilityFence(this);
145 if (ret >= 0 && ret <= 4096) { return null; }
146 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
147 ret_hu_conv.ptrs_to.add(this);
152 * The channel capacity as seen on-chain, if chain lookup is available.
154 public void set_capacity_sats(Option_u64Z val) {
155 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
156 Reference.reachabilityFence(this);
157 Reference.reachabilityFence(val);
161 * An initial announcement of the channel
162 * Mostly redundant with the data we store in fields explicitly.
163 * Everything else is useful only for sending out for initial routing sync.
164 * Not stored if contains excess data to prevent DoS.
166 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
169 public ChannelAnnouncement get_announcement_message() {
170 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
171 Reference.reachabilityFence(this);
172 if (ret >= 0 && ret <= 4096) { return null; }
173 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
174 ret_hu_conv.ptrs_to.add(this);
179 * An initial announcement of the channel
180 * Mostly redundant with the data we store in fields explicitly.
181 * Everything else is useful only for sending out for initial routing sync.
182 * Not stored if contains excess data to prevent DoS.
184 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
186 public void set_announcement_message(@Nullable ChannelAnnouncement val) {
187 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
188 Reference.reachabilityFence(this);
189 Reference.reachabilityFence(val);
193 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
194 Reference.reachabilityFence(this);
199 * Creates a copy of the ChannelInfo
201 public ChannelInfo clone() {
202 long ret = bindings.ChannelInfo_clone(this.ptr);
203 Reference.reachabilityFence(this);
204 if (ret >= 0 && ret <= 4096) { return null; }
205 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
206 ret_hu_conv.ptrs_to.add(this);
211 * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
213 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
216 public ChannelUpdateInfo get_directional_info(byte channel_flags) {
217 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
218 Reference.reachabilityFence(this);
219 Reference.reachabilityFence(channel_flags);
220 if (ret >= 0 && ret <= 4096) { return null; }
221 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
222 ret_hu_conv.ptrs_to.add(this);
227 * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
229 public byte[] write() {
230 byte[] ret = bindings.ChannelInfo_write(this.ptr);
231 Reference.reachabilityFence(this);
236 * Read a ChannelInfo from a byte array, created by ChannelInfo_write
238 public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
239 long ret = bindings.ChannelInfo_read(ser);
240 Reference.reachabilityFence(ser);
241 if (ret >= 0 && ret <= 4096) { return null; }
242 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);