[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ChannelUpdateInfo.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  * Details about one direction of a channel as received within a [`ChannelUpdate`].
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelUpdateInfo extends CommonBase {
16         ChannelUpdateInfo(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelUpdateInfo_free(ptr); }
21         }
22
23         /**
24          * When the last update to the channel direction was issued.
25          * Value is opaque, as set in the announcement.
26          */
27         public int get_last_update() {
28                 int ret = bindings.ChannelUpdateInfo_get_last_update(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * When the last update to the channel direction was issued.
35          * Value is opaque, as set in the announcement.
36          */
37         public void set_last_update(int val) {
38                 bindings.ChannelUpdateInfo_set_last_update(this.ptr, val);
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * Whether the channel can be currently used for payments (in this one direction).
45          */
46         public boolean get_enabled() {
47                 boolean ret = bindings.ChannelUpdateInfo_get_enabled(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * Whether the channel can be currently used for payments (in this one direction).
54          */
55         public void set_enabled(boolean val) {
56                 bindings.ChannelUpdateInfo_set_enabled(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The difference in CLTV values that you must have when routing through this channel.
63          */
64         public short get_cltv_expiry_delta() {
65                 short ret = bindings.ChannelUpdateInfo_get_cltv_expiry_delta(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The difference in CLTV values that you must have when routing through this channel.
72          */
73         public void set_cltv_expiry_delta(short val) {
74                 bindings.ChannelUpdateInfo_set_cltv_expiry_delta(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The minimum value, which must be relayed to the next hop via the channel
81          */
82         public long get_htlc_minimum_msat() {
83                 long ret = bindings.ChannelUpdateInfo_get_htlc_minimum_msat(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The minimum value, which must be relayed to the next hop via the channel
90          */
91         public void set_htlc_minimum_msat(long val) {
92                 bindings.ChannelUpdateInfo_set_htlc_minimum_msat(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * The maximum value which may be relayed to the next hop via the channel.
99          */
100         public long get_htlc_maximum_msat() {
101                 long ret = bindings.ChannelUpdateInfo_get_htlc_maximum_msat(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * The maximum value which may be relayed to the next hop via the channel.
108          */
109         public void set_htlc_maximum_msat(long val) {
110                 bindings.ChannelUpdateInfo_set_htlc_maximum_msat(this.ptr, val);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113         }
114
115         /**
116          * Fees charged when the channel is used for routing
117          */
118         public RoutingFees get_fees() {
119                 long ret = bindings.ChannelUpdateInfo_get_fees(this.ptr);
120                 Reference.reachabilityFence(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Fees charged when the channel is used for routing
129          */
130         public void set_fees(org.ldk.structs.RoutingFees val) {
131                 bindings.ChannelUpdateInfo_set_fees(this.ptr, val == null ? 0 : val.ptr);
132                 Reference.reachabilityFence(this);
133                 Reference.reachabilityFence(val);
134                 if (this != null) { this.ptrs_to.add(val); };
135         }
136
137         /**
138          * Most recent update for the channel received from the network
139          * Mostly redundant with the data we store in fields explicitly.
140          * Everything else is useful only for sending out for initial routing sync.
141          * Not stored if contains excess data to prevent DoS.
142          * 
143          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
144          */
145         @Nullable
146         public ChannelUpdate get_last_update_message() {
147                 long ret = bindings.ChannelUpdateInfo_get_last_update_message(this.ptr);
148                 Reference.reachabilityFence(this);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Most recent update for the channel received from the network
157          * Mostly redundant with the data we store in fields explicitly.
158          * Everything else is useful only for sending out for initial routing sync.
159          * Not stored if contains excess data to prevent DoS.
160          * 
161          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
162          */
163         public void set_last_update_message(@Nullable org.ldk.structs.ChannelUpdate val) {
164                 bindings.ChannelUpdateInfo_set_last_update_message(this.ptr, val == null ? 0 : val.ptr);
165                 Reference.reachabilityFence(this);
166                 Reference.reachabilityFence(val);
167                 if (this != null) { this.ptrs_to.add(val); };
168         }
169
170         /**
171          * Constructs a new ChannelUpdateInfo given each field
172          * 
173          * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
174          */
175         public static ChannelUpdateInfo of(int last_update_arg, boolean enabled_arg, short cltv_expiry_delta_arg, long htlc_minimum_msat_arg, long htlc_maximum_msat_arg, org.ldk.structs.RoutingFees fees_arg, @Nullable org.ldk.structs.ChannelUpdate last_update_message_arg) {
176                 long ret = bindings.ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg == null ? 0 : fees_arg.ptr, last_update_message_arg == null ? 0 : last_update_message_arg.ptr);
177                 Reference.reachabilityFence(last_update_arg);
178                 Reference.reachabilityFence(enabled_arg);
179                 Reference.reachabilityFence(cltv_expiry_delta_arg);
180                 Reference.reachabilityFence(htlc_minimum_msat_arg);
181                 Reference.reachabilityFence(htlc_maximum_msat_arg);
182                 Reference.reachabilityFence(fees_arg);
183                 Reference.reachabilityFence(last_update_message_arg);
184                 if (ret >= 0 && ret <= 4096) { return null; }
185                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
186                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
187                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fees_arg); };
188                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(last_update_message_arg); };
189                 return ret_hu_conv;
190         }
191
192         long clone_ptr() {
193                 long ret = bindings.ChannelUpdateInfo_clone_ptr(this.ptr);
194                 Reference.reachabilityFence(this);
195                 return ret;
196         }
197
198         /**
199          * Creates a copy of the ChannelUpdateInfo
200          */
201         public ChannelUpdateInfo clone() {
202                 long ret = bindings.ChannelUpdateInfo_clone(this.ptr);
203                 Reference.reachabilityFence(this);
204                 if (ret >= 0 && ret <= 4096) { return null; }
205                 org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); }
206                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
207                 return ret_hu_conv;
208         }
209
210         /**
211          * Checks if two ChannelUpdateInfos contain equal inner contents.
212          * This ignores pointers and is_owned flags and looks at the values in fields.
213          * Two objects with NULL inner values will be considered "equal" here.
214          */
215         public boolean eq(org.ldk.structs.ChannelUpdateInfo b) {
216                 boolean ret = bindings.ChannelUpdateInfo_eq(this.ptr, b == null ? 0 : b.ptr);
217                 Reference.reachabilityFence(this);
218                 Reference.reachabilityFence(b);
219                 if (this != null) { this.ptrs_to.add(b); };
220                 return ret;
221         }
222
223         @Override public boolean equals(Object o) {
224                 if (!(o instanceof ChannelUpdateInfo)) return false;
225                 return this.eq((ChannelUpdateInfo)o);
226         }
227         /**
228          * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read
229          */
230         public byte[] write() {
231                 byte[] ret = bindings.ChannelUpdateInfo_write(this.ptr);
232                 Reference.reachabilityFence(this);
233                 return ret;
234         }
235
236         /**
237          * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write
238          */
239         public static Result_ChannelUpdateInfoDecodeErrorZ read(byte[] ser) {
240                 long ret = bindings.ChannelUpdateInfo_read(ser);
241                 Reference.reachabilityFence(ser);
242                 if (ret >= 0 && ret <= 4096) { return null; }
243                 Result_ChannelUpdateInfoDecodeErrorZ ret_hu_conv = Result_ChannelUpdateInfoDecodeErrorZ.constr_from_ptr(ret);
244                 return ret_hu_conv;
245         }
246
247 }