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 one direction of a channel. Received
12 * within a channel update.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class DirectionalChannelInfo extends CommonBase {
16 DirectionalChannelInfo(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.DirectionalChannelInfo_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.DirectionalChannelInfo_get_last_update(this.ptr);
33 * When the last update to the channel direction was issued.
34 * Value is opaque, as set in the announcement.
36 public void set_last_update(int val) {
37 bindings.DirectionalChannelInfo_set_last_update(this.ptr, val);
41 * Whether the channel can be currently used for payments (in this one direction).
43 public boolean get_enabled() {
44 boolean ret = bindings.DirectionalChannelInfo_get_enabled(this.ptr);
49 * Whether the channel can be currently used for payments (in this one direction).
51 public void set_enabled(boolean val) {
52 bindings.DirectionalChannelInfo_set_enabled(this.ptr, val);
56 * The difference in CLTV values that you must have when routing through this channel.
58 public short get_cltv_expiry_delta() {
59 short ret = bindings.DirectionalChannelInfo_get_cltv_expiry_delta(this.ptr);
64 * The difference in CLTV values that you must have when routing through this channel.
66 public void set_cltv_expiry_delta(short val) {
67 bindings.DirectionalChannelInfo_set_cltv_expiry_delta(this.ptr, val);
71 * The minimum value, which must be relayed to the next hop via the channel
73 public long get_htlc_minimum_msat() {
74 long ret = bindings.DirectionalChannelInfo_get_htlc_minimum_msat(this.ptr);
79 * The minimum value, which must be relayed to the next hop via the channel
81 public void set_htlc_minimum_msat(long val) {
82 bindings.DirectionalChannelInfo_set_htlc_minimum_msat(this.ptr, val);
86 * The maximum value which may be relayed to the next hop via the channel.
88 public Option_u64Z get_htlc_maximum_msat() {
89 long ret = bindings.DirectionalChannelInfo_get_htlc_maximum_msat(this.ptr);
90 if (ret < 1024) { return null; }
91 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
92 ret_hu_conv.ptrs_to.add(this);
97 * The maximum value which may be relayed to the next hop via the channel.
99 public void set_htlc_maximum_msat(Option_u64Z val) {
100 bindings.DirectionalChannelInfo_set_htlc_maximum_msat(this.ptr, val.ptr);
104 * Fees charged when the channel is used for routing
106 public RoutingFees get_fees() {
107 long ret = bindings.DirectionalChannelInfo_get_fees(this.ptr);
108 if (ret < 1024) { return null; }
109 RoutingFees ret_hu_conv = new RoutingFees(null, ret);
110 ret_hu_conv.ptrs_to.add(this);
115 * Fees charged when the channel is used for routing
117 public void set_fees(RoutingFees val) {
118 bindings.DirectionalChannelInfo_set_fees(this.ptr, val == null ? 0 : val.ptr & ~1);
119 this.ptrs_to.add(val);
123 * Most recent update for the channel received from the network
124 * Mostly redundant with the data we store in fields explicitly.
125 * Everything else is useful only for sending out for initial routing sync.
126 * Not stored if contains excess data to prevent DoS.
128 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
131 public ChannelUpdate get_last_update_message() {
132 long ret = bindings.DirectionalChannelInfo_get_last_update_message(this.ptr);
133 if (ret < 1024) { return null; }
134 ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
135 ret_hu_conv.ptrs_to.add(this);
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 val (or a relevant inner pointer) may be NULL or all-0s to represent None
147 public void set_last_update_message(@Nullable ChannelUpdate val) {
148 bindings.DirectionalChannelInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr & ~1);
149 this.ptrs_to.add(val);
153 * Constructs a new DirectionalChannelInfo given each field
155 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) {
156 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);
157 if (ret < 1024) { return null; }
158 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
159 ret_hu_conv.ptrs_to.add(ret_hu_conv);
160 ret_hu_conv.ptrs_to.add(fees_arg);
161 ret_hu_conv.ptrs_to.add(last_update_message_arg);
166 * Creates a copy of the DirectionalChannelInfo
168 public DirectionalChannelInfo clone() {
169 long ret = bindings.DirectionalChannelInfo_clone(this.ptr);
170 if (ret < 1024) { return null; }
171 DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret);
172 ret_hu_conv.ptrs_to.add(this);
177 * Serialize the DirectionalChannelInfo object into a byte array which can be read by DirectionalChannelInfo_read
179 public byte[] write() {
180 byte[] ret = bindings.DirectionalChannelInfo_write(this.ptr);
185 * Read a DirectionalChannelInfo from a byte array, created by DirectionalChannelInfo_write
187 public static Result_DirectionalChannelInfoDecodeErrorZ read(byte[] ser) {
188 long ret = bindings.DirectionalChannelInfo_read(ser);
189 if (ret < 1024) { return null; }
190 Result_DirectionalChannelInfoDecodeErrorZ ret_hu_conv = Result_DirectionalChannelInfoDecodeErrorZ.constr_from_ptr(ret);