03f164eef192ad39f1818b48b227014f6826c1c8
[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          * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
59          * only applies to inbound channels.
60          * 
61          * Default value: 2^24 - 1.
62          */
63         public long get_max_funding_satoshis() {
64                 long ret = bindings.ChannelHandshakeLimits_get_max_funding_satoshis(this.ptr);
65                 Reference.reachabilityFence(this);
66                 return ret;
67         }
68
69         /**
70          * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
71          * only applies to inbound channels.
72          * 
73          * Default value: 2^24 - 1.
74          */
75         public void set_max_funding_satoshis(long val) {
76                 bindings.ChannelHandshakeLimits_set_max_funding_satoshis(this.ptr, val);
77                 Reference.reachabilityFence(this);
78                 Reference.reachabilityFence(val);
79         }
80
81         /**
82          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
83          * you to limit the maximum minimum-size they can require.
84          * 
85          * Default value: u64::max_value.
86          */
87         public long get_max_htlc_minimum_msat() {
88                 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
95          * you to limit the maximum minimum-size they can require.
96          * 
97          * Default value: u64::max_value.
98          */
99         public void set_max_htlc_minimum_msat(long val) {
100                 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
107          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
108          * 
109          * Default value: 0.
110          */
111         public long get_min_max_htlc_value_in_flight_msat() {
112                 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
113                 Reference.reachabilityFence(this);
114                 return ret;
115         }
116
117         /**
118          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
119          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
120          * 
121          * Default value: 0.
122          */
123         public void set_min_max_htlc_value_in_flight_msat(long val) {
124                 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
125                 Reference.reachabilityFence(this);
126                 Reference.reachabilityFence(val);
127         }
128
129         /**
130          * The remote node will require we keep a certain amount in direct payment to ourselves at all
131          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
132          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
133          * 
134          * Default value: u64::max_value.
135          */
136         public long get_max_channel_reserve_satoshis() {
137                 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * The remote node will require we keep a certain amount in direct payment to ourselves at all
144          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
145          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
146          * 
147          * Default value: u64::max_value.
148          */
149         public void set_max_channel_reserve_satoshis(long val) {
150                 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
151                 Reference.reachabilityFence(this);
152                 Reference.reachabilityFence(val);
153         }
154
155         /**
156          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
157          * time. This allows you to set a minimum such value.
158          * 
159          * Default value: 0.
160          */
161         public short get_min_max_accepted_htlcs() {
162                 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
163                 Reference.reachabilityFence(this);
164                 return ret;
165         }
166
167         /**
168          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
169          * time. This allows you to set a minimum such value.
170          * 
171          * Default value: 0.
172          */
173         public void set_min_max_accepted_htlcs(short val) {
174                 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
175                 Reference.reachabilityFence(this);
176                 Reference.reachabilityFence(val);
177         }
178
179         /**
180          * Before a channel is usable the funding transaction will need to be confirmed by at least a
181          * certain number of blocks, specified by the node which is not the funder (as the funder can
182          * assume they aren't going to double-spend themselves).
183          * This config allows you to set a limit on the maximum amount of time to wait.
184          * 
185          * Default value: 144, or roughly one day and only applies to outbound channels.
186          */
187         public int get_max_minimum_depth() {
188                 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
189                 Reference.reachabilityFence(this);
190                 return ret;
191         }
192
193         /**
194          * Before a channel is usable the funding transaction will need to be confirmed by at least a
195          * certain number of blocks, specified by the node which is not the funder (as the funder can
196          * assume they aren't going to double-spend themselves).
197          * This config allows you to set a limit on the maximum amount of time to wait.
198          * 
199          * Default value: 144, or roughly one day and only applies to outbound channels.
200          */
201         public void set_max_minimum_depth(int val) {
202                 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
203                 Reference.reachabilityFence(this);
204                 Reference.reachabilityFence(val);
205         }
206
207         /**
208          * Whether we implicitly trust funding transactions generated by us for our own outbound
209          * channels to not be double-spent.
210          * 
211          * If this is set, we assume that our own funding transactions are *never* double-spent, and
212          * thus we can trust them without any confirmations. This is generally a reasonable
213          * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
214          * control of the signing keys).
215          * 
216          * You may wish to un-set this if you allow the user to (or do in an automated fashion)
217          * double-spend the funding transaction to RBF with an alternative channel open.
218          * 
219          * This only applies if our counterparty set their confirmations-required value to 0, and we
220          * always trust our own funding transaction at 1 confirmation irrespective of this value.
221          * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
222          * `true` (0) and `false` (1).
223          * 
224          * Default value: true
225          */
226         public boolean get_trust_own_funding_0conf() {
227                 boolean ret = bindings.ChannelHandshakeLimits_get_trust_own_funding_0conf(this.ptr);
228                 Reference.reachabilityFence(this);
229                 return ret;
230         }
231
232         /**
233          * Whether we implicitly trust funding transactions generated by us for our own outbound
234          * channels to not be double-spent.
235          * 
236          * If this is set, we assume that our own funding transactions are *never* double-spent, and
237          * thus we can trust them without any confirmations. This is generally a reasonable
238          * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
239          * control of the signing keys).
240          * 
241          * You may wish to un-set this if you allow the user to (or do in an automated fashion)
242          * double-spend the funding transaction to RBF with an alternative channel open.
243          * 
244          * This only applies if our counterparty set their confirmations-required value to 0, and we
245          * always trust our own funding transaction at 1 confirmation irrespective of this value.
246          * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
247          * `true` (0) and `false` (1).
248          * 
249          * Default value: true
250          */
251         public void set_trust_own_funding_0conf(boolean val) {
252                 bindings.ChannelHandshakeLimits_set_trust_own_funding_0conf(this.ptr, val);
253                 Reference.reachabilityFence(this);
254                 Reference.reachabilityFence(val);
255         }
256
257         /**
258          * Set to force an incoming channel to match our announced channel preference in
259          * [`ChannelConfig::announced_channel`].
260          * 
261          * For a node which is not online reliably, this should be set to true and
262          * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
263          * channels will ever be opened.
264          * 
265          * Default value: true.
266          */
267         public boolean get_force_announced_channel_preference() {
268                 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
269                 Reference.reachabilityFence(this);
270                 return ret;
271         }
272
273         /**
274          * Set to force an incoming channel to match our announced channel preference in
275          * [`ChannelConfig::announced_channel`].
276          * 
277          * For a node which is not online reliably, this should be set to true and
278          * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
279          * channels will ever be opened.
280          * 
281          * Default value: true.
282          */
283         public void set_force_announced_channel_preference(boolean val) {
284                 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
285                 Reference.reachabilityFence(this);
286                 Reference.reachabilityFence(val);
287         }
288
289         /**
290          * Set to the amount of time we're willing to wait to claim money back to us.
291          * 
292          * Not checking this value would be a security issue, as our peer would be able to set it to
293          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
294          * 
295          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
296          * reduce the loss of having useless locked funds (if your peer accepts)
297          */
298         public short get_their_to_self_delay() {
299                 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
300                 Reference.reachabilityFence(this);
301                 return ret;
302         }
303
304         /**
305          * Set to the amount of time we're willing to wait to claim money back to us.
306          * 
307          * Not checking this value would be a security issue, as our peer would be able to set it to
308          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
309          * 
310          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
311          * reduce the loss of having useless locked funds (if your peer accepts)
312          */
313         public void set_their_to_self_delay(short val) {
314                 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
315                 Reference.reachabilityFence(this);
316                 Reference.reachabilityFence(val);
317         }
318
319         /**
320          * Constructs a new ChannelHandshakeLimits given each field
321          */
322         public static ChannelHandshakeLimits of(long min_funding_satoshis_arg, long max_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 trust_own_funding_0conf_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) {
323                 long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_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, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
324                 Reference.reachabilityFence(min_funding_satoshis_arg);
325                 Reference.reachabilityFence(max_funding_satoshis_arg);
326                 Reference.reachabilityFence(max_htlc_minimum_msat_arg);
327                 Reference.reachabilityFence(min_max_htlc_value_in_flight_msat_arg);
328                 Reference.reachabilityFence(max_channel_reserve_satoshis_arg);
329                 Reference.reachabilityFence(min_max_accepted_htlcs_arg);
330                 Reference.reachabilityFence(max_minimum_depth_arg);
331                 Reference.reachabilityFence(trust_own_funding_0conf_arg);
332                 Reference.reachabilityFence(force_announced_channel_preference_arg);
333                 Reference.reachabilityFence(their_to_self_delay_arg);
334                 if (ret >= 0 && ret <= 4096) { return null; }
335                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
336                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
337                 return ret_hu_conv;
338         }
339
340         long clone_ptr() {
341                 long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr);
342                 Reference.reachabilityFence(this);
343                 return ret;
344         }
345
346         /**
347          * Creates a copy of the ChannelHandshakeLimits
348          */
349         public ChannelHandshakeLimits clone() {
350                 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
351                 Reference.reachabilityFence(this);
352                 if (ret >= 0 && ret <= 4096) { return null; }
353                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
354                 ret_hu_conv.ptrs_to.add(this);
355                 return ret_hu_conv;
356         }
357
358         /**
359          * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
360          */
361         public static ChannelHandshakeLimits with_default() {
362                 long ret = bindings.ChannelHandshakeLimits_default();
363                 if (ret >= 0 && ret <= 4096) { return null; }
364                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
365                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
366                 return ret_hu_conv;
367         }
368
369 }