Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / ChannelHandshakeLimits.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  * Optional channel limits which are applied during channel creation.
13  * 
14  * These limits are only applied to our counterparty's limits, not our own.
15  * 
16  * Use 0/<type>::max_value() as appropriate to skip checking.
17  * 
18  * Provides sane defaults for most configurations.
19  * 
20  * Most additional limits are disabled except those with which specify a default in individual
21  * field documentation. Note that this may result in barely-usable channels, but since they
22  * are applied mostly only to incoming channels that's not much of a problem.
23  */
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class ChannelHandshakeLimits extends CommonBase {
26         ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 super.finalize();
30                 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
31         }
32
33         /**
34          * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
35          * only applies to inbound channels.
36          * 
37          * Default value: 0.
38          */
39         public long get_min_funding_satoshis() {
40                 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
41                 Reference.reachabilityFence(this);
42                 return ret;
43         }
44
45         /**
46          * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
47          * only applies to inbound channels.
48          * 
49          * Default value: 0.
50          */
51         public void set_min_funding_satoshis(long val) {
52                 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
53                 Reference.reachabilityFence(this);
54                 Reference.reachabilityFence(val);
55         }
56
57         /**
58          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
59          * you to limit the maximum minimum-size they can require.
60          * 
61          * Default value: u64::max_value.
62          */
63         public long get_max_htlc_minimum_msat() {
64                 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         /**
70          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
71          * you to limit the maximum minimum-size they can require.
72          * 
73          * Default value: u64::max_value.
74          */
75         public void set_max_htlc_minimum_msat(long val) {
76                 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
77                 Reference.reachabilityFence(this);
78                 Reference.reachabilityFence(val);
79         }
80
81         /**
82          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
83          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
84          * 
85          * Default value: 0.
86          */
87         public long get_min_max_htlc_value_in_flight_msat() {
88                 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
95          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
96          * 
97          * Default value: 0.
98          */
99         public void set_min_max_htlc_value_in_flight_msat(long val) {
100                 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The remote node will require we keep a certain amount in direct payment to ourselves at all
107          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
108          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
109          * 
110          * Default value: u64::max_value.
111          */
112         public long get_max_channel_reserve_satoshis() {
113                 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * The remote node will require we keep a certain amount in direct payment to ourselves at all
120          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
121          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
122          * 
123          * Default value: u64::max_value.
124          */
125         public void set_max_channel_reserve_satoshis(long val) {
126                 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
127                 Reference.reachabilityFence(this);
128                 Reference.reachabilityFence(val);
129         }
130
131         /**
132          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
133          * time. This allows you to set a minimum such value.
134          * 
135          * Default value: 0.
136          */
137         public short get_min_max_accepted_htlcs() {
138                 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
139                 Reference.reachabilityFence(this);
140                 return ret;
141         }
142
143         /**
144          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
145          * time. This allows you to set a minimum such value.
146          * 
147          * Default value: 0.
148          */
149         public void set_min_max_accepted_htlcs(short val) {
150                 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
151                 Reference.reachabilityFence(this);
152                 Reference.reachabilityFence(val);
153         }
154
155         /**
156          * Before a channel is usable the funding transaction will need to be confirmed by at least a
157          * certain number of blocks, specified by the node which is not the funder (as the funder can
158          * assume they aren't going to double-spend themselves).
159          * This config allows you to set a limit on the maximum amount of time to wait.
160          * 
161          * Default value: 144, or roughly one day and only applies to outbound channels.
162          */
163         public int get_max_minimum_depth() {
164                 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
165                 Reference.reachabilityFence(this);
166                 return ret;
167         }
168
169         /**
170          * Before a channel is usable the funding transaction will need to be confirmed by at least a
171          * certain number of blocks, specified by the node which is not the funder (as the funder can
172          * assume they aren't going to double-spend themselves).
173          * This config allows you to set a limit on the maximum amount of time to wait.
174          * 
175          * Default value: 144, or roughly one day and only applies to outbound channels.
176          */
177         public void set_max_minimum_depth(int val) {
178                 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
179                 Reference.reachabilityFence(this);
180                 Reference.reachabilityFence(val);
181         }
182
183         /**
184          * Set to force an incoming channel to match our announced channel preference in
185          * [`ChannelConfig::announced_channel`].
186          * 
187          * For a node which is not online reliably, this should be set to true and
188          * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
189          * channels will ever be opened.
190          * 
191          * Default value: true.
192          */
193         public boolean get_force_announced_channel_preference() {
194                 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
195                 Reference.reachabilityFence(this);
196                 return ret;
197         }
198
199         /**
200          * Set to force an incoming channel to match our announced channel preference in
201          * [`ChannelConfig::announced_channel`].
202          * 
203          * For a node which is not online reliably, this should be set to true and
204          * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
205          * channels will ever be opened.
206          * 
207          * Default value: true.
208          */
209         public void set_force_announced_channel_preference(boolean val) {
210                 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
211                 Reference.reachabilityFence(this);
212                 Reference.reachabilityFence(val);
213         }
214
215         /**
216          * Set to the amount of time we're willing to wait to claim money back to us.
217          * 
218          * Not checking this value would be a security issue, as our peer would be able to set it to
219          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
220          * 
221          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
222          * reduce the loss of having useless locked funds (if your peer accepts)
223          */
224         public short get_their_to_self_delay() {
225                 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
226                 Reference.reachabilityFence(this);
227                 return ret;
228         }
229
230         /**
231          * Set to the amount of time we're willing to wait to claim money back to us.
232          * 
233          * Not checking this value would be a security issue, as our peer would be able to set it to
234          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
235          * 
236          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
237          * reduce the loss of having useless locked funds (if your peer accepts)
238          */
239         public void set_their_to_self_delay(short val) {
240                 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
241                 Reference.reachabilityFence(this);
242                 Reference.reachabilityFence(val);
243         }
244
245         /**
246          * Constructs a new ChannelHandshakeLimits given each field
247          */
248         public static ChannelHandshakeLimits of(long min_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, int max_minimum_depth_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) {
249                 long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
250                 Reference.reachabilityFence(min_funding_satoshis_arg);
251                 Reference.reachabilityFence(max_htlc_minimum_msat_arg);
252                 Reference.reachabilityFence(min_max_htlc_value_in_flight_msat_arg);
253                 Reference.reachabilityFence(max_channel_reserve_satoshis_arg);
254                 Reference.reachabilityFence(min_max_accepted_htlcs_arg);
255                 Reference.reachabilityFence(max_minimum_depth_arg);
256                 Reference.reachabilityFence(force_announced_channel_preference_arg);
257                 Reference.reachabilityFence(their_to_self_delay_arg);
258                 if (ret >= 0 && ret <= 4096) { return null; }
259                 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
260                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
261                 return ret_hu_conv;
262         }
263
264         long clone_ptr() {
265                 long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr);
266                 Reference.reachabilityFence(this);
267                 return ret;
268         }
269
270         /**
271          * Creates a copy of the ChannelHandshakeLimits
272          */
273         public ChannelHandshakeLimits clone() {
274                 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
275                 Reference.reachabilityFence(this);
276                 if (ret >= 0 && ret <= 4096) { return null; }
277                 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
278                 ret_hu_conv.ptrs_to.add(this);
279                 return ret_hu_conv;
280         }
281
282         /**
283          * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
284          */
285         public static ChannelHandshakeLimits with_default() {
286                 long ret = bindings.ChannelHandshakeLimits_default();
287                 if (ret >= 0 && ret <= 4096) { return null; }
288                 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
289                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
290                 return ret_hu_conv;
291         }
292
293 }