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 * The unsigned part of a channel_update
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class UnsignedChannelUpdate extends CommonBase {
16 UnsignedChannelUpdate(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.UnsignedChannelUpdate_free(ptr); }
24 * The genesis hash of the blockchain where the channel is to be opened
26 public byte[] get_chain_hash() {
27 byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr);
28 Reference.reachabilityFence(this);
33 * The genesis hash of the blockchain where the channel is to be opened
35 public void set_chain_hash(byte[] val) {
36 bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The short channel ID
44 public long get_short_channel_id() {
45 long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr);
46 Reference.reachabilityFence(this);
51 * The short channel ID
53 public void set_short_channel_id(long val) {
54 bindings.UnsignedChannelUpdate_set_short_channel_id(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
62 public int get_timestamp() {
63 int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr);
64 Reference.reachabilityFence(this);
69 * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
71 public void set_timestamp(int val) {
72 bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val);
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
80 public byte get_flags() {
81 byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr);
82 Reference.reachabilityFence(this);
89 public void set_flags(byte val) {
90 bindings.UnsignedChannelUpdate_set_flags(this.ptr, val);
91 Reference.reachabilityFence(this);
92 Reference.reachabilityFence(val);
96 * The number of blocks such that if:
97 * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
98 * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
99 * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
100 * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
101 * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
102 * forwarding. Note that the HTLC sender is the one who originally sets this value when
103 * constructing the route.
105 public short get_cltv_expiry_delta() {
106 short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr);
107 Reference.reachabilityFence(this);
112 * The number of blocks such that if:
113 * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
114 * then we need to fail the HTLC backwards. When forwarding an HTLC, cltv_expiry_delta determines
115 * the outgoing HTLC's minimum cltv_expiry value -- so, if an incoming HTLC comes in with a
116 * cltv_expiry of 100000, and the node we're forwarding to has a cltv_expiry_delta value of 10,
117 * then we'll check that the outgoing HTLC's cltv_expiry value is at least 100010 before
118 * forwarding. Note that the HTLC sender is the one who originally sets this value when
119 * constructing the route.
121 public void set_cltv_expiry_delta(short val) {
122 bindings.UnsignedChannelUpdate_set_cltv_expiry_delta(this.ptr, val);
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(val);
128 * The minimum HTLC size incoming to sender, in milli-satoshi
130 public long get_htlc_minimum_msat() {
131 long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr);
132 Reference.reachabilityFence(this);
137 * The minimum HTLC size incoming to sender, in milli-satoshi
139 public void set_htlc_minimum_msat(long val) {
140 bindings.UnsignedChannelUpdate_set_htlc_minimum_msat(this.ptr, val);
141 Reference.reachabilityFence(this);
142 Reference.reachabilityFence(val);
146 * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
148 public long get_htlc_maximum_msat() {
149 long ret = bindings.UnsignedChannelUpdate_get_htlc_maximum_msat(this.ptr);
150 Reference.reachabilityFence(this);
155 * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
157 public void set_htlc_maximum_msat(long val) {
158 bindings.UnsignedChannelUpdate_set_htlc_maximum_msat(this.ptr, val);
159 Reference.reachabilityFence(this);
160 Reference.reachabilityFence(val);
164 * The base HTLC fee charged by sender, in milli-satoshi
166 public int get_fee_base_msat() {
167 int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr);
168 Reference.reachabilityFence(this);
173 * The base HTLC fee charged by sender, in milli-satoshi
175 public void set_fee_base_msat(int val) {
176 bindings.UnsignedChannelUpdate_set_fee_base_msat(this.ptr, val);
177 Reference.reachabilityFence(this);
178 Reference.reachabilityFence(val);
182 * The amount to fee multiplier, in micro-satoshi
184 public int get_fee_proportional_millionths() {
185 int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr);
186 Reference.reachabilityFence(this);
191 * The amount to fee multiplier, in micro-satoshi
193 public void set_fee_proportional_millionths(int val) {
194 bindings.UnsignedChannelUpdate_set_fee_proportional_millionths(this.ptr, val);
195 Reference.reachabilityFence(this);
196 Reference.reachabilityFence(val);
200 * Excess data which was signed as a part of the message which we do not (yet) understand how
201 * to decode. This is stored to ensure forward-compatibility as new fields are added to the
204 * Returns a copy of the field.
206 public byte[] get_excess_data() {
207 byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr);
208 Reference.reachabilityFence(this);
213 * Excess data which was signed as a part of the message which we do not (yet) understand how
214 * to decode. This is stored to ensure forward-compatibility as new fields are added to the
217 public void set_excess_data(byte[] val) {
218 bindings.UnsignedChannelUpdate_set_excess_data(this.ptr, val);
219 Reference.reachabilityFence(this);
220 Reference.reachabilityFence(val);
224 * Constructs a new UnsignedChannelUpdate given each field
226 public static UnsignedChannelUpdate of(byte[] chain_hash_arg, long short_channel_id_arg, int timestamp_arg, byte flags_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg, int fee_base_msat_arg, int fee_proportional_millionths_arg, byte[] excess_data_arg) {
227 long ret = bindings.UnsignedChannelUpdate_new(InternalUtils.check_arr_len(chain_hash_arg, 32), short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg);
228 Reference.reachabilityFence(chain_hash_arg);
229 Reference.reachabilityFence(short_channel_id_arg);
230 Reference.reachabilityFence(timestamp_arg);
231 Reference.reachabilityFence(flags_arg);
232 Reference.reachabilityFence(cltv_expiry_delta_arg);
233 Reference.reachabilityFence(htlc_minimum_msat_arg);
234 Reference.reachabilityFence(htlc_maximum_msat_arg);
235 Reference.reachabilityFence(fee_base_msat_arg);
236 Reference.reachabilityFence(fee_proportional_millionths_arg);
237 Reference.reachabilityFence(excess_data_arg);
238 if (ret >= 0 && ret <= 4096) { return null; }
239 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
240 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
245 long ret = bindings.UnsignedChannelUpdate_clone_ptr(this.ptr);
246 Reference.reachabilityFence(this);
251 * Creates a copy of the UnsignedChannelUpdate
253 public UnsignedChannelUpdate clone() {
254 long ret = bindings.UnsignedChannelUpdate_clone(this.ptr);
255 Reference.reachabilityFence(this);
256 if (ret >= 0 && ret <= 4096) { return null; }
257 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
258 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
263 * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
265 public byte[] write() {
266 byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr);
267 Reference.reachabilityFence(this);
272 * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
274 public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) {
275 long ret = bindings.UnsignedChannelUpdate_read(ser);
276 Reference.reachabilityFence(ser);
277 if (ret >= 0 && ret <= 4096) { return null; }
278 Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);