[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / UnsignedChannelUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * The unsigned part of a [`channel_update`] message.
13  * 
14  * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.UnsignedChannelUpdate_free(ptr); }
23         }
24
25         /**
26          * The genesis hash of the blockchain where the channel is to be opened
27          */
28         public byte[] get_chain_hash() {
29                 byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The genesis hash of the blockchain where the channel is to be opened
36          */
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);
41         }
42
43         /**
44          * The short channel ID
45          */
46         public long get_short_channel_id() {
47                 long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The short channel ID
54          */
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);
59         }
60
61         /**
62          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
63          */
64         public int get_timestamp() {
65                 int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
72          */
73         public void set_timestamp(int val) {
74                 bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * Channel flags
81          */
82         public byte get_flags() {
83                 byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * Channel flags
90          */
91         public void set_flags(byte val) {
92                 bindings.UnsignedChannelUpdate_set_flags(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
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.
106          */
107         public short get_cltv_expiry_delta() {
108                 short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr);
109                 Reference.reachabilityFence(this);
110                 return ret;
111         }
112
113         /**
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.
122          */
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);
127         }
128
129         /**
130          * The minimum HTLC size incoming to sender, in milli-satoshi
131          */
132         public long get_htlc_minimum_msat() {
133                 long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr);
134                 Reference.reachabilityFence(this);
135                 return ret;
136         }
137
138         /**
139          * The minimum HTLC size incoming to sender, in milli-satoshi
140          */
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);
145         }
146
147         /**
148          * The maximum HTLC value incoming to sender, in milli-satoshi.
149          * 
150          * This used to be optional.
151          */
152         public long get_htlc_maximum_msat() {
153                 long ret = bindings.UnsignedChannelUpdate_get_htlc_maximum_msat(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158         /**
159          * The maximum HTLC value incoming to sender, in milli-satoshi.
160          * 
161          * This used to be optional.
162          */
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);
167         }
168
169         /**
170          * The base HTLC fee charged by sender, in milli-satoshi
171          */
172         public int get_fee_base_msat() {
173                 int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr);
174                 Reference.reachabilityFence(this);
175                 return ret;
176         }
177
178         /**
179          * The base HTLC fee charged by sender, in milli-satoshi
180          */
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);
185         }
186
187         /**
188          * The amount to fee multiplier, in micro-satoshi
189          */
190         public int get_fee_proportional_millionths() {
191                 int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr);
192                 Reference.reachabilityFence(this);
193                 return ret;
194         }
195
196         /**
197          * The amount to fee multiplier, in micro-satoshi
198          */
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);
203         }
204
205         /**
206          * Excess data which was signed as a part of the message which we do not (yet) understand how
207          * to decode.
208          * 
209          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
210          * 
211          * Returns a copy of the field.
212          */
213         public byte[] get_excess_data() {
214                 byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr);
215                 Reference.reachabilityFence(this);
216                 return ret;
217         }
218
219         /**
220          * Excess data which was signed as a part of the message which we do not (yet) understand how
221          * to decode.
222          * 
223          * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol.
224          */
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);
229         }
230
231         /**
232          * Constructs a new UnsignedChannelUpdate given each field
233          */
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); };
249                 return ret_hu_conv;
250         }
251
252         long clone_ptr() {
253                 long ret = bindings.UnsignedChannelUpdate_clone_ptr(this.ptr);
254                 Reference.reachabilityFence(this);
255                 return ret;
256         }
257
258         /**
259          * Creates a copy of the UnsignedChannelUpdate
260          */
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); };
267                 return ret_hu_conv;
268         }
269
270         /**
271          * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate.
272          */
273         public long hash() {
274                 long ret = bindings.UnsignedChannelUpdate_hash(this.ptr);
275                 Reference.reachabilityFence(this);
276                 return ret;
277         }
278
279         @Override public int hashCode() {
280                 return (int)this.hash();
281         }
282         /**
283          * Checks if two UnsignedChannelUpdates contain equal inner contents.
284          * This ignores pointers and is_owned flags and looks at the values in fields.
285          * Two objects with NULL inner values will be considered "equal" here.
286          */
287         public boolean eq(org.ldk.structs.UnsignedChannelUpdate b) {
288                 boolean ret = bindings.UnsignedChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
289                 Reference.reachabilityFence(this);
290                 Reference.reachabilityFence(b);
291                 if (this != null) { this.ptrs_to.add(b); };
292                 return ret;
293         }
294
295         @Override public boolean equals(Object o) {
296                 if (!(o instanceof UnsignedChannelUpdate)) return false;
297                 return this.eq((UnsignedChannelUpdate)o);
298         }
299         /**
300          * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
301          */
302         public byte[] write() {
303                 byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr);
304                 Reference.reachabilityFence(this);
305                 return ret;
306         }
307
308         /**
309          * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
310          */
311         public static Result_UnsignedChannelUpdateDecodeErrorZ read(byte[] ser) {
312                 long ret = bindings.UnsignedChannelUpdate_read(ser);
313                 Reference.reachabilityFence(ser);
314                 if (ret >= 0 && ret <= 4096) { return null; }
315                 Result_UnsignedChannelUpdateDecodeErrorZ ret_hu_conv = Result_UnsignedChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
316                 return ret_hu_conv;
317         }
318
319 }