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(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(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 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(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 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(Option_u64Z val) {
160 bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr);
161 Reference.reachabilityFence(this);
162 Reference.reachabilityFence(val);
166 * An initial announcement of the channel
167 * Mostly redundant with the data we store in fields explicitly.
168 * Everything else is useful only for sending out for initial routing sync.
169 * Not stored if contains excess data to prevent DoS.
171 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
174 public ChannelAnnouncement get_announcement_message() {
175 long ret = bindings.ChannelInfo_get_announcement_message(this.ptr);
176 Reference.reachabilityFence(this);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); }
179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
184 * An initial announcement of the channel
185 * Mostly redundant with the data we store in fields explicitly.
186 * Everything else is useful only for sending out for initial routing sync.
187 * Not stored if contains excess data to prevent DoS.
189 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
191 public void set_announcement_message(@Nullable ChannelAnnouncement val) {
192 bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr);
193 Reference.reachabilityFence(this);
194 Reference.reachabilityFence(val);
195 if (this != null) { this.ptrs_to.add(val); };
199 long ret = bindings.ChannelInfo_clone_ptr(this.ptr);
200 Reference.reachabilityFence(this);
205 * Creates a copy of the ChannelInfo
207 public ChannelInfo clone() {
208 long ret = bindings.ChannelInfo_clone(this.ptr);
209 Reference.reachabilityFence(this);
210 if (ret >= 0 && ret <= 4096) { return null; }
211 org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); }
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
217 * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag.
219 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
222 public ChannelUpdateInfo get_directional_info(byte channel_flags) {
223 long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags);
224 Reference.reachabilityFence(this);
225 Reference.reachabilityFence(channel_flags);
226 if (ret >= 0 && ret <= 4096) { return null; }
227 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
228 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
233 * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read
235 public byte[] write() {
236 byte[] ret = bindings.ChannelInfo_write(this.ptr);
237 Reference.reachabilityFence(this);
242 * Read a ChannelInfo from a byte array, created by ChannelInfo_write
244 public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) {
245 long ret = bindings.ChannelInfo_read(ser);
246 Reference.reachabilityFence(ser);
247 if (ret >= 0 && ret <= 4096) { return null; }
248 Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret);