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 ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 DirectionalChannelInfo 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 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(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 DirectionalChannelInfo 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 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 DirectionalChannelInfo 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 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(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 DirectionalChannelInfo 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 Option_u64Z ret_hu_conv = 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 ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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 ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
206 ret_hu_conv.ptrs_to.add(this);
211 * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
213 public byte[] write() {
214 byte[] ret = bindings.ChannelInfo_write(this.ptr);
215 Reference.reachabilityFence(this);
220 * Read a ChannelInfo from a byte array, created by ChannelInfo_write
222 public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
223 long ret = bindings.ChannelInfo_read(ser);
224 Reference.reachabilityFence(ser);
225 if (ret >= 0 && ret <= 4096) { return null; }
226 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);