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 as received within a [`ChannelUpdate`].
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelUpdateInfo extends CommonBase {
16 ChannelUpdateInfo(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelUpdateInfo_free(ptr); }
24 * When the last update to the channel direction was issued.
25 * Value is opaque, as set in the announcement.
27 public int get_last_update() {
28 int ret = bindings.ChannelUpdateInfo_get_last_update(this.ptr);
29 Reference.reachabilityFence(this);
34 * When the last update to the channel direction was issued.
35 * Value is opaque, as set in the announcement.
37 public void set_last_update(int val) {
38 bindings.ChannelUpdateInfo_set_last_update(this.ptr, val);
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * Whether the channel can be currently used for payments (in this one direction).
46 public boolean get_enabled() {
47 boolean ret = bindings.ChannelUpdateInfo_get_enabled(this.ptr);
48 Reference.reachabilityFence(this);
53 * Whether the channel can be currently used for payments (in this one direction).
55 public void set_enabled(boolean val) {
56 bindings.ChannelUpdateInfo_set_enabled(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * The difference in CLTV values that you must have when routing through this channel.
64 public short get_cltv_expiry_delta() {
65 short ret = bindings.ChannelUpdateInfo_get_cltv_expiry_delta(this.ptr);
66 Reference.reachabilityFence(this);
71 * The difference in CLTV values that you must have when routing through this channel.
73 public void set_cltv_expiry_delta(short val) {
74 bindings.ChannelUpdateInfo_set_cltv_expiry_delta(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The minimum value, which must be relayed to the next hop via the channel
82 public long get_htlc_minimum_msat() {
83 long ret = bindings.ChannelUpdateInfo_get_htlc_minimum_msat(this.ptr);
84 Reference.reachabilityFence(this);
89 * The minimum value, which must be relayed to the next hop via the channel
91 public void set_htlc_minimum_msat(long val) {
92 bindings.ChannelUpdateInfo_set_htlc_minimum_msat(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The maximum value which may be relayed to the next hop via the channel.
100 public Option_u64Z get_htlc_maximum_msat() {
101 long ret = bindings.ChannelUpdateInfo_get_htlc_maximum_msat(this.ptr);
102 Reference.reachabilityFence(this);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
105 ret_hu_conv.ptrs_to.add(this);
110 * The maximum value which may be relayed to the next hop via the channel.
112 public void set_htlc_maximum_msat(Option_u64Z val) {
113 bindings.ChannelUpdateInfo_set_htlc_maximum_msat(this.ptr, val.ptr);
114 Reference.reachabilityFence(this);
115 Reference.reachabilityFence(val);
119 * Fees charged when the channel is used for routing
121 public RoutingFees get_fees() {
122 long ret = bindings.ChannelUpdateInfo_get_fees(this.ptr);
123 Reference.reachabilityFence(this);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RoutingFees(null, ret); }
126 ret_hu_conv.ptrs_to.add(this);
131 * Fees charged when the channel is used for routing
133 public void set_fees(RoutingFees val) {
134 bindings.ChannelUpdateInfo_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
135 Reference.reachabilityFence(this);
136 Reference.reachabilityFence(val);
140 * Most recent update for the channel received from the network
141 * Mostly redundant with the data we store in fields explicitly.
142 * Everything else is useful only for sending out for initial routing sync.
143 * Not stored if contains excess data to prevent DoS.
145 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
148 public ChannelUpdate get_last_update_message() {
149 long ret = bindings.ChannelUpdateInfo_get_last_update_message(this.ptr);
150 Reference.reachabilityFence(this);
151 if (ret >= 0 && ret <= 4096) { return null; }
152 ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdate(null, ret); }
153 ret_hu_conv.ptrs_to.add(this);
158 * Most recent update for the channel received from the network
159 * Mostly redundant with the data we store in fields explicitly.
160 * Everything else is useful only for sending out for initial routing sync.
161 * Not stored if contains excess data to prevent DoS.
163 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
165 public void set_last_update_message(@Nullable ChannelUpdate val) {
166 bindings.ChannelUpdateInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr & ~1);
167 Reference.reachabilityFence(this);
168 Reference.reachabilityFence(val);
172 * Constructs a new ChannelUpdateInfo given each field
174 public static ChannelUpdateInfo 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) {
175 long ret = bindings.ChannelUpdateInfo_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);
176 Reference.reachabilityFence(last_update_arg);
177 Reference.reachabilityFence(enabled_arg);
178 Reference.reachabilityFence(cltv_expiry_delta_arg);
179 Reference.reachabilityFence(htlc_minimum_msat_arg);
180 Reference.reachabilityFence(htlc_maximum_msat_arg);
181 Reference.reachabilityFence(fees_arg);
182 Reference.reachabilityFence(last_update_message_arg);
183 if (ret >= 0 && ret <= 4096) { return null; }
184 ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdateInfo(null, ret); }
185 ret_hu_conv.ptrs_to.add(ret_hu_conv);
190 long ret = bindings.ChannelUpdateInfo_clone_ptr(this.ptr);
191 Reference.reachabilityFence(this);
196 * Creates a copy of the ChannelUpdateInfo
198 public ChannelUpdateInfo clone() {
199 long ret = bindings.ChannelUpdateInfo_clone(this.ptr);
200 Reference.reachabilityFence(this);
201 if (ret >= 0 && ret <= 4096) { return null; }
202 ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelUpdateInfo(null, ret); }
203 ret_hu_conv.ptrs_to.add(this);
208 * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read
210 public byte[] write() {
211 byte[] ret = bindings.ChannelUpdateInfo_write(this.ptr);
212 Reference.reachabilityFence(this);
217 * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write
219 public static Result_ChannelUpdateInfoDecodeErrorZ read(byte[] ser) {
220 long ret = bindings.ChannelUpdateInfo_read(ser);
221 Reference.reachabilityFence(ser);
222 if (ret >= 0 && ret <= 4096) { return null; }
223 Result_ChannelUpdateInfoDecodeErrorZ ret_hu_conv = Result_ChannelUpdateInfoDecodeErrorZ.constr_from_ptr(ret);