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 one direction of a channel. Received
13 * within a channel update.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class DirectionalChannelInfo extends CommonBase {
17 DirectionalChannelInfo(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.DirectionalChannelInfo_free(ptr); }
25 * When the last update to the channel direction was issued.
26 * Value is opaque, as set in the announcement.
28 public int get_last_update() {
29 int ret = bindings.DirectionalChannelInfo_get_last_update(this.ptr);
30 Reference.reachabilityFence(this);
35 * When the last update to the channel direction was issued.
36 * Value is opaque, as set in the announcement.
38 public void set_last_update(int val) {
39 bindings.DirectionalChannelInfo_set_last_update(this.ptr, val);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
45 * Whether the channel can be currently used for payments (in this one direction).
47 public boolean get_enabled() {
48 boolean ret = bindings.DirectionalChannelInfo_get_enabled(this.ptr);
49 Reference.reachabilityFence(this);
54 * Whether the channel can be currently used for payments (in this one direction).
56 public void set_enabled(boolean val) {
57 bindings.DirectionalChannelInfo_set_enabled(this.ptr, val);
58 Reference.reachabilityFence(this);
59 Reference.reachabilityFence(val);
63 * The difference in CLTV values that you must have when routing through this channel.
65 public short get_cltv_expiry_delta() {
66 short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this.ptr);
67 Reference.reachabilityFence(this);
72 * The difference in CLTV values that you must have when routing through this channel.
74 public void set_cltv_expiry_delta(short val) {
75 bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this.ptr, val);
76 Reference.reachabilityFence(this);
77 Reference.reachabilityFence(val);
81 * The minimum value, which must be relayed to the next hop via the channel
83 public long get_htlc_minimum_msat() {
84 long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this.ptr);
85 Reference.reachabilityFence(this);
90 * The minimum value, which must be relayed to the next hop via the channel
92 public void set_htlc_minimum_msat(long val) {
93 bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this.ptr, val);
94 Reference.reachabilityFence(this);
95 Reference.reachabilityFence(val);
99 * The maximum value which may be relayed to the next hop via the channel.
101 public Option_u64Z get_htlc_maximum_msat() {
102 long ret = bindings.DirectionalChannelInfo_get_htlc_maximum_msat(this.ptr);
103 Reference.reachabilityFence(this);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
106 ret_hu_conv.ptrs_to.add(this);
111 * The maximum value which may be relayed to the next hop via the channel.
113 public void set_htlc_maximum_msat(Option_u64Z val) {
114 bindings.DirectionalChannelInfo_set_htlc_maximum_msat(this.ptr, val.ptr);
115 Reference.reachabilityFence(this);
116 Reference.reachabilityFence(val);
120 * Fees charged when the channel is used for routing
122 public RoutingFees get_fees() {
123 long ret = bindings.DirectionalChannelInfo_get_fees(this.ptr);
124 Reference.reachabilityFence(this);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
127 ret_hu_conv.ptrs_to.add(this);
132 * Fees charged when the channel is used for routing
134 public void set_fees(RoutingFees val) {
135 bindings.DirectionalChannelInfo_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
136 Reference.reachabilityFence(this);
137 Reference.reachabilityFence(val);
141 * Most recent update for the channel received from the network
142 * Mostly redundant with the data we store in fields explicitly.
143 * Everything else is useful only for sending out for initial routing sync.
144 * Not stored if contains excess data to prevent DoS.
146 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
149 public ChannelUpdate get_last_update_message() {
150 long ret = bindings.DirectionalChannelInfo_get_last_update_message(this.ptr);
151 Reference.reachabilityFence(this);
152 if (ret >= 0 && ret <= 4096) { return null; }
153 ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); }
154 ret_hu_conv.ptrs_to.add(this);
159 * Most recent update for the channel received from the network
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_last_update_message(@Nullable ChannelUpdate val) {
167 bindings.DirectionalChannelInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr & ~1);
168 Reference.reachabilityFence(this);
169 Reference.reachabilityFence(val);
173 * Constructs a new DirectionalChannelInfo given each field
175 public static DirectionalChannelInfo of(int last_update_arg, boolean enabled_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, Option_u64Z htlc_maximum_msat_arg, RoutingFees fees_arg, ChannelUpdate last_update_message_arg) {
176 long ret = bindings.DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg.ptr, fees_arg == null ? 0 : fees_arg.ptr & ~1, last_update_message_arg == null ? 0 : last_update_message_arg.ptr & ~1);
177 Reference.reachabilityFence(last_update_arg);
178 Reference.reachabilityFence(enabled_arg);
179 Reference.reachabilityFence(cltv_expiry_delta_arg);
180 Reference.reachabilityFence(htlc_minimum_msat_arg);
181 Reference.reachabilityFence(htlc_maximum_msat_arg);
182 Reference.reachabilityFence(fees_arg);
183 Reference.reachabilityFence(last_update_message_arg);
184 if (ret >= 0 && ret <= 4096) { return null; }
185 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
186 ret_hu_conv.ptrs_to.add(ret_hu_conv);
191 long ret = bindings.DirectionalChannelInfo_clone_ptr(this.ptr);
192 Reference.reachabilityFence(this);
197 * Creates a copy of the DirectionalChannelInfo
199 public DirectionalChannelInfo clone() {
200 long ret = bindings.DirectionalChannelInfo_clone(this.ptr);
201 Reference.reachabilityFence(this);
202 if (ret >= 0 && ret <= 4096) { return null; }
203 DirectionalChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new DirectionalChannelInfo(null, ret); }
204 ret_hu_conv.ptrs_to.add(this);
209 * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
211 public byte[] write() {
212 byte[] ret = bindings.DirectionalChannelInfo_write(this.ptr);
213 Reference.reachabilityFence(this);
218 * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
220 public static Result_DirectionalChannelInfoDecodeErrorZ read(byte[] ser) {
221 long ret = bindings.DirectionalChannelInfo_read(ser);
222 Reference.reachabilityFence(ser);
223 if (ret >= 0 && ret <= 4096) { return null; }
224 Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);