fc6d0b6596b9b53f9ef6f97fefba7941871eec43
[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
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.UnsignedChannelUpdate_free(ptr); }
21         }
22
23         /**
24          * The genesis hash of the blockchain where the channel is to be opened
25          */
26         public byte[] get_chain_hash() {
27                 byte[] ret = bindings.UnsignedChannelUpdate_get_chain_hash(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The genesis hash of the blockchain where the channel is to be opened
34          */
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);
39         }
40
41         /**
42          * The short channel ID
43          */
44         public long get_short_channel_id() {
45                 long ret = bindings.UnsignedChannelUpdate_get_short_channel_id(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The short channel ID
52          */
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);
57         }
58
59         /**
60          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
61          */
62         public int get_timestamp() {
63                 int ret = bindings.UnsignedChannelUpdate_get_timestamp(this.ptr);
64                 Reference.reachabilityFence(this);
65                 return ret;
66         }
67
68         /**
69          * A strictly monotonic announcement counter, with gaps allowed, specific to this channel
70          */
71         public void set_timestamp(int val) {
72                 bindings.UnsignedChannelUpdate_set_timestamp(this.ptr, val);
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(val);
75         }
76
77         /**
78          * Channel flags
79          */
80         public byte get_flags() {
81                 byte ret = bindings.UnsignedChannelUpdate_get_flags(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * Channel flags
88          */
89         public void set_flags(byte val) {
90                 bindings.UnsignedChannelUpdate_set_flags(this.ptr, val);
91                 Reference.reachabilityFence(this);
92                 Reference.reachabilityFence(val);
93         }
94
95         /**
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.
104          */
105         public short get_cltv_expiry_delta() {
106                 short ret = bindings.UnsignedChannelUpdate_get_cltv_expiry_delta(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
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.
120          */
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);
125         }
126
127         /**
128          * The minimum HTLC size incoming to sender, in milli-satoshi
129          */
130         public long get_htlc_minimum_msat() {
131                 long ret = bindings.UnsignedChannelUpdate_get_htlc_minimum_msat(this.ptr);
132                 Reference.reachabilityFence(this);
133                 return ret;
134         }
135
136         /**
137          * The minimum HTLC size incoming to sender, in milli-satoshi
138          */
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);
143         }
144
145         /**
146          * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
147          */
148         public long get_htlc_maximum_msat() {
149                 long ret = bindings.UnsignedChannelUpdate_get_htlc_maximum_msat(this.ptr);
150                 Reference.reachabilityFence(this);
151                 return ret;
152         }
153
154         /**
155          * The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
156          */
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);
161         }
162
163         /**
164          * The base HTLC fee charged by sender, in milli-satoshi
165          */
166         public int get_fee_base_msat() {
167                 int ret = bindings.UnsignedChannelUpdate_get_fee_base_msat(this.ptr);
168                 Reference.reachabilityFence(this);
169                 return ret;
170         }
171
172         /**
173          * The base HTLC fee charged by sender, in milli-satoshi
174          */
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);
179         }
180
181         /**
182          * The amount to fee multiplier, in micro-satoshi
183          */
184         public int get_fee_proportional_millionths() {
185                 int ret = bindings.UnsignedChannelUpdate_get_fee_proportional_millionths(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         /**
191          * The amount to fee multiplier, in micro-satoshi
192          */
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);
197         }
198
199         /**
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
202          * lightning gossip
203          * 
204          * Returns a copy of the field.
205          */
206         public byte[] get_excess_data() {
207                 byte[] ret = bindings.UnsignedChannelUpdate_get_excess_data(this.ptr);
208                 Reference.reachabilityFence(this);
209                 return ret;
210         }
211
212         /**
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
215          * lightning gossip
216          */
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);
221         }
222
223         /**
224          * Constructs a new UnsignedChannelUpdate given each field
225          */
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                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
241                 return ret_hu_conv;
242         }
243
244         long clone_ptr() {
245                 long ret = bindings.UnsignedChannelUpdate_clone_ptr(this.ptr);
246                 Reference.reachabilityFence(this);
247                 return ret;
248         }
249
250         /**
251          * Creates a copy of the UnsignedChannelUpdate
252          */
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                 ret_hu_conv.ptrs_to.add(this);
259                 return ret_hu_conv;
260         }
261
262         /**
263          * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read
264          */
265         public byte[] write() {
266                 byte[] ret = bindings.UnsignedChannelUpdate_write(this.ptr);
267                 Reference.reachabilityFence(this);
268                 return ret;
269         }
270
271         /**
272          * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write
273          */
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);
279                 return ret_hu_conv;
280         }
281
282 }