1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Details about a channel (both directions).
12 * Received within a channel announcement.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelInfo extends CommonBase {
16 ChannelInfo(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelInfo_free(ptr); }
24 * Protocol features of a channel communicated during its announcement
26 public ChannelFeatures get_features() {
27 long ret = bindings.ChannelInfo_get_features(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelFeatures(null, ret); }
30 ret_hu_conv.ptrs_to.add(this);
35 * Protocol features of a channel communicated during its announcement
37 public void set_features(ChannelFeatures val) {
38 bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
42 * Source node of the first direction of a channel
44 public NodeId get_node_one() {
45 long ret = bindings.ChannelInfo_get_node_one(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
48 ret_hu_conv.ptrs_to.add(this);
53 * Source node of the first direction of a channel
55 public void set_node_one(NodeId val) {
56 bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr & ~1);
60 * Details about the first direction of a channel
62 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
65 public DirectionalChannelInfo get_one_to_two() {
66 long ret = bindings.ChannelInfo_get_one_to_two(this.ptr);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
69 ret_hu_conv.ptrs_to.add(this);
74 * Details about the first direction of a channel
76 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
78 public void set_one_to_two(@Nullable DirectionalChannelInfo val) {
79 bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1);
83 * Source node of the second direction of a channel
85 public NodeId get_node_two() {
86 long ret = bindings.ChannelInfo_get_node_two(this.ptr);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
89 ret_hu_conv.ptrs_to.add(this);
94 * Source node of the second direction of a channel
96 public void set_node_two(NodeId val) {
97 bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr & ~1);
101 * Details about the second direction of a channel
103 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
106 public DirectionalChannelInfo get_two_to_one() {
107 long ret = bindings.ChannelInfo_get_two_to_one(this.ptr);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
110 ret_hu_conv.ptrs_to.add(this);
115 * Details about the second direction of a channel
117 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
119 public void set_two_to_one(@Nullable DirectionalChannelInfo val) {
120 bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1);
124 * The channel capacity as seen on-chain, if chain lookup is available.
126 public Option_u64Z get_capacity_sats() {
127 long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
130 ret_hu_conv.ptrs_to.add(this);
135 * The channel capacity as seen on-chain, if chain lookup is available.
137 public void set_capacity_sats(Option_u64Z val) {
138 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
142 * An initial announcement of the channel
143 * Mostly redundant with the data we store in fields explicitly.
144 * Everything else is useful only for sending out for initial routing sync.
145 * Not stored if contains excess data to prevent DoS.
147 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
150 public ChannelAnnouncement get_announcement_message() {
151 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
152 if (ret >= 0 && ret <= 4096) { return null; }
153 ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelAnnouncement(null, ret); }
154 ret_hu_conv.ptrs_to.add(this);
159 * An initial announcement of the channel
160 * Mostly redundant with the data we store in fields explicitly.
161 * Everything else is useful only for sending out for initial routing sync.
162 * Not stored if contains excess data to prevent DoS.
164 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
166 public void set_announcement_message(@Nullable ChannelAnnouncement val) {
167 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
171 * Constructs a new ChannelInfo given each field
173 public static ChannelInfo of(ChannelFeatures features_arg, NodeId node_one_arg, DirectionalChannelInfo one_to_two_arg, NodeId node_two_arg, DirectionalChannelInfo two_to_one_arg, Option_u64Z capacity_sats_arg, ChannelAnnouncement announcement_message_arg) {
174 long ret = bindings.ChannelInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, node_one_arg == null ? 0 : node_one_arg.ptr & ~1, one_to_two_arg == null ? 0 : one_to_two_arg.ptr & ~1, node_two_arg == null ? 0 : node_two_arg.ptr & ~1, two_to_one_arg == null ? 0 : two_to_one_arg.ptr & ~1, capacity_sats_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
177 ret_hu_conv.ptrs_to.add(ret_hu_conv);
182 * Creates a copy of the ChannelInfo
184 public ChannelInfo clone() {
185 long ret = bindings.ChannelInfo_clone(this.ptr);
186 if (ret >= 0 && ret <= 4096) { return null; }
187 ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelInfo(null, ret); }
188 ret_hu_conv.ptrs_to.add(this);
193 * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
195 public byte[] write() {
196 byte[] ret = bindings.ChannelInfo_write(this.ptr);
201 * Read a ChannelInfo from a byte array, created by ChannelInfo_write
203 public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
204 long ret = bindings.ChannelInfo_read(ser);
205 if (ret >= 0 && ret <= 4096) { return null; }
206 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);