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`] message.
14 * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UnsignedChannelUpdate extends CommonBase {
18 UnsignedChannelUpdate(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UnsignedChannelUpdate_free(ptr); }
26 * The genesis hash of the blockchain where the channel is to be opened
28 public byte[] get_chain_hash() {
29 byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr);
30 Reference.reachabilityFence(this);
35 * The genesis hash of the blockchain where the channel is to be opened
37 public void set_chain_hash(byte[] val) {
38 bindings.UnsignedChannelUpdate_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The short channel ID
46 public long get_short_channel_id() {
47 long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr);
48 Reference.reachabilityFence(this);
53 * The short channel ID
55 public void set_short_channel_id(long val) {
56 bindings.UnsignedChannelUpdate_set_short_channel_id(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
64 public int get_timestamp() {
65 int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr);
66 Reference.reachabilityFence(this);
71 * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
73 public void set_timestamp(int val) {
74 bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
82 public byte get_flags() {
83 byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr);
84 Reference.reachabilityFence(this);
91 public void set_flags(byte val) {
92 bindings.UnsignedChannelUpdate_set_flags(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * The number of blocks such that if:
99 * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
100 * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
101 * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
102 * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
103 * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
104 * forwarding. Note that the HTLC sender is the one who originally sets this value when
105 * constructing the route.
107 public short get_cltv_expiry_delta() {
108 short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr);
109 Reference.reachabilityFence(this);
114 * The number of blocks such that if:
115 * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta`
116 * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines
117 * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a
118 * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10,
119 * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before
120 * forwarding. Note that the HTLC sender is the one who originally sets this value when
121 * constructing the route.
123 public void set_cltv_expiry_delta(short val) {
124 bindings.UnsignedChannelUpdate_set_cltv_expiry_delta(this.ptr, val);
125 Reference.reachabilityFence(this);
126 Reference.reachabilityFence(val);
130 * The minimum HTLC size incoming to sender, in milli-satoshi
132 public long get_htlc_minimum_msat() {
133 long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr);
134 Reference.reachabilityFence(this);
139 * The minimum HTLC size incoming to sender, in milli-satoshi
141 public void set_htlc_minimum_msat(long val) {
142 bindings.UnsignedChannelUpdate_set_htlc_minimum_msat(this.ptr, val);
143 Reference.reachabilityFence(this);
144 Reference.reachabilityFence(val);
148 * The maximum HTLC value incoming to sender, in milli-satoshi.
150 * This used to be optional.
152 public long get_htlc_maximum_msat() {
153 long ret = bindings.UnsignedChannelUpdate_get_htlc_maximum_msat(this.ptr);
154 Reference.reachabilityFence(this);
159 * The maximum HTLC value incoming to sender, in milli-satoshi.
161 * This used to be optional.
163 public void set_htlc_maximum_msat(long val) {
164 bindings.UnsignedChannelUpdate_set_htlc_maximum_msat(this.ptr, val);
165 Reference.reachabilityFence(this);
166 Reference.reachabilityFence(val);
170 * The base HTLC fee charged by sender, in milli-satoshi
172 public int get_fee_base_msat() {
173 int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr);
174 Reference.reachabilityFence(this);
179 * The base HTLC fee charged by sender, in milli-satoshi
181 public void set_fee_base_msat(int val) {
182 bindings.UnsignedChannelUpdate_set_fee_base_msat(this.ptr, val);
183 Reference.reachabilityFence(this);
184 Reference.reachabilityFence(val);
188 * The amount to fee multiplier, in micro-satoshi
190 public int get_fee_proportional_millionths() {
191 int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr);
192 Reference.reachabilityFence(this);
197 * The amount to fee multiplier, in micro-satoshi
199 public void set_fee_proportional_millionths(int val) {
200 bindings.UnsignedChannelUpdate_set_fee_proportional_millionths(this.ptr, val);
201 Reference.reachabilityFence(this);
202 Reference.reachabilityFence(val);
206 * Excess data which was signed as a part of the message which we do not (yet) understand how
209 * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
211 * Returns a copy of the field.
213 public byte[] get_excess_data() {
214 byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr);
215 Reference.reachabilityFence(this);
220 * Excess data which was signed as a part of the message which we do not (yet) understand how
223 * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
225 public void set_excess_data(byte[] val) {
226 bindings.UnsignedChannelUpdate_set_excess_data(this.ptr, val);
227 Reference.reachabilityFence(this);
228 Reference.reachabilityFence(val);
232 * Constructs a new UnsignedChannelUpdate given each field
234 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) {
235 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);
236 Reference.reachabilityFence(chain_hash_arg);
237 Reference.reachabilityFence(short_channel_id_arg);
238 Reference.reachabilityFence(timestamp_arg);
239 Reference.reachabilityFence(flags_arg);
240 Reference.reachabilityFence(cltv_expiry_delta_arg);
241 Reference.reachabilityFence(htlc_minimum_msat_arg);
242 Reference.reachabilityFence(htlc_maximum_msat_arg);
243 Reference.reachabilityFence(fee_base_msat_arg);
244 Reference.reachabilityFence(fee_proportional_millionths_arg);
245 Reference.reachabilityFence(excess_data_arg);
246 if (ret >= 0 && ret <= 4096) { return null; }
247 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
248 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
253 long ret = bindings.UnsignedChannelUpdate_clone_ptr(this.ptr);
254 Reference.reachabilityFence(this);
259 * Creates a copy of the UnsignedChannelUpdate
261 public UnsignedChannelUpdate clone() {
262 long ret = bindings.UnsignedChannelUpdate_clone(this.ptr);
263 Reference.reachabilityFence(this);
264 if (ret >= 0 && ret <= 4096) { return null; }
265 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
266 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
271 * Checks if two UnsignedChannelUpdates contain equal inner contents.
272 * This ignores pointers and is_owned flags and looks at the values in fields.
273 * Two objects with NULL inner values will be considered "equal" here.
275 public boolean eq(org.ldk.structs.UnsignedChannelUpdate b) {
276 boolean ret = bindings.UnsignedChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
277 Reference.reachabilityFence(this);
278 Reference.reachabilityFence(b);
279 if (this != null) { this.ptrs_to.add(b); };
283 @Override public boolean equals(Object o) {
284 if (!(o instanceof UnsignedChannelUpdate)) return false;
285 return this.eq((UnsignedChannelUpdate)o);
288 * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
290 public byte[] write() {
291 byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr);
292 Reference.reachabilityFence(this);
297 * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
299 public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) {
300 long ret = bindings.UnsignedChannelUpdate_read(ser);
301 Reference.reachabilityFence(ser);
302 if (ret >= 0 && ret <= 4096) { return null; }
303 Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);