[Java] Update auto-generated Java files
[ldk-java] / src / main / java / org / ldk / structs / ChannelHandshakeConfig.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  * Configuration we set when applicable.
13  * 
14  * Default::default() provides sane defaults.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelHandshakeConfig extends CommonBase {
18         ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
23         }
24
25         /**
26          * Confirmations we will wait for before considering the channel locked in.
27          * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
28          * equivalent limit applied to outbound channels).
29          * 
30          * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
31          * transaction before operation. If you wish to accept channels with zero confirmations, see
32          * [`UserConfig::manually_accept_inbound_channels`] and
33          * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
34          * 
35          * Default value: 6.
36          * 
37          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
38          * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
39          */
40         public int get_minimum_depth() {
41                 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
42                 Reference.reachabilityFence(this);
43                 return ret;
44         }
45
46         /**
47          * Confirmations we will wait for before considering the channel locked in.
48          * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
49          * equivalent limit applied to outbound channels).
50          * 
51          * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
52          * transaction before operation. If you wish to accept channels with zero confirmations, see
53          * [`UserConfig::manually_accept_inbound_channels`] and
54          * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
55          * 
56          * Default value: 6.
57          * 
58          * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
59          * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
60          */
61         public void set_minimum_depth(int val) {
62                 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * Set to the number of blocks we require our counterparty to wait to claim their money (ie
69          * the number of blocks we have to punish our counterparty if they broadcast a revoked
70          * transaction).
71          * 
72          * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
73          * be online to check for revoked transactions on-chain at least once every our_to_self_delay
74          * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
75          * possibly with time in between to RBF the spending transaction).
76          * 
77          * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
78          * case of an honest unilateral channel close, which implicitly decrease the economic value of
79          * our channel.
80          * 
81          * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
82          * can tweak config to ask for more security, not less.
83          */
84         public short get_our_to_self_delay() {
85                 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * Set to the number of blocks we require our counterparty to wait to claim their money (ie
92          * the number of blocks we have to punish our counterparty if they broadcast a revoked
93          * transaction).
94          * 
95          * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
96          * be online to check for revoked transactions on-chain at least once every our_to_self_delay
97          * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
98          * possibly with time in between to RBF the spending transaction).
99          * 
100          * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
101          * case of an honest unilateral channel close, which implicitly decrease the economic value of
102          * our channel.
103          * 
104          * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
105          * can tweak config to ask for more security, not less.
106          */
107         public void set_our_to_self_delay(short val) {
108                 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(val);
111         }
112
113         /**
114          * Set to the smallest value HTLC we will accept to process.
115          * 
116          * This value is sent to our counterparty on channel-open and we close the channel any time
117          * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
118          * 
119          * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
120          * by the protocol.
121          */
122         public long get_our_htlc_minimum_msat() {
123                 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
124                 Reference.reachabilityFence(this);
125                 return ret;
126         }
127
128         /**
129          * Set to the smallest value HTLC we will accept to process.
130          * 
131          * This value is sent to our counterparty on channel-open and we close the channel any time
132          * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
133          * 
134          * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
135          * by the protocol.
136          */
137         public void set_our_htlc_minimum_msat(long val) {
138                 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
139                 Reference.reachabilityFence(this);
140                 Reference.reachabilityFence(val);
141         }
142
143         /**
144          * Sets the percentage of the channel value we will cap the total value of outstanding inbound
145          * HTLCs to.
146          * 
147          * This can be set to a value between 1-100, where the value corresponds to the percent of the
148          * channel value in whole percentages.
149          * 
150          * Note that:
151          * If configured to another value than the default value 10, any new channels created with
152          * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
153          * `ChannelManager`.
154          * 
155          * This caps the total value for inbound HTLCs in-flight only, and there's currently
156          * no way to configure the cap for the total value of outbound HTLCs in-flight.
157          * 
158          * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
159          * are different from the non-HTLC-encumbered funds. This makes this an important knob to
160          * restrict exposure to loss due to being offline for too long.
161          * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
162          * for more information.
163          * 
164          * Default value: 10.
165          * Minimum value: 1, any values less than 1 will be treated as 1 instead.
166          * Maximum value: 100, any values larger than 100 will be treated as 100 instead.
167          */
168         public byte get_max_inbound_htlc_value_in_flight_percent_of_channel() {
169                 byte ret = bindings.ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr);
170                 Reference.reachabilityFence(this);
171                 return ret;
172         }
173
174         /**
175          * Sets the percentage of the channel value we will cap the total value of outstanding inbound
176          * HTLCs to.
177          * 
178          * This can be set to a value between 1-100, where the value corresponds to the percent of the
179          * channel value in whole percentages.
180          * 
181          * Note that:
182          * If configured to another value than the default value 10, any new channels created with
183          * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
184          * `ChannelManager`.
185          * 
186          * This caps the total value for inbound HTLCs in-flight only, and there's currently
187          * no way to configure the cap for the total value of outbound HTLCs in-flight.
188          * 
189          * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
190          * are different from the non-HTLC-encumbered funds. This makes this an important knob to
191          * restrict exposure to loss due to being offline for too long.
192          * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
193          * for more information.
194          * 
195          * Default value: 10.
196          * Minimum value: 1, any values less than 1 will be treated as 1 instead.
197          * Maximum value: 100, any values larger than 100 will be treated as 100 instead.
198          */
199         public void set_max_inbound_htlc_value_in_flight_percent_of_channel(byte val) {
200                 bindings.ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr, val);
201                 Reference.reachabilityFence(this);
202                 Reference.reachabilityFence(val);
203         }
204
205         /**
206          * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
207          * BOLTs) option for outbound private channels. This provides better privacy by not including
208          * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
209          * relay HTLCs to us using the channel's SCID alias.
210          * 
211          * If this option is set, channels may be created that will not be readable by LDK versions
212          * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
213          * [`DecodeError::InvalidValue`].
214          * 
215          * Note that setting this to true does *not* prevent us from opening channels with
216          * counterparties that do not support the `scid_alias` option; we will simply fall back to a
217          * private channel without that option.
218          * 
219          * Ignored if the channel is negotiated to be announced, see
220          * [`ChannelHandshakeConfig::announced_channel`] and
221          * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
222          * 
223          * Default value: false. This value is likely to change to true in the future.
224          * 
225          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
226          * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
227          */
228         public boolean get_negotiate_scid_privacy() {
229                 boolean ret = bindings.ChannelHandshakeConfig_get_negotiate_scid_privacy(this.ptr);
230                 Reference.reachabilityFence(this);
231                 return ret;
232         }
233
234         /**
235          * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
236          * BOLTs) option for outbound private channels. This provides better privacy by not including
237          * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
238          * relay HTLCs to us using the channel's SCID alias.
239          * 
240          * If this option is set, channels may be created that will not be readable by LDK versions
241          * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
242          * [`DecodeError::InvalidValue`].
243          * 
244          * Note that setting this to true does *not* prevent us from opening channels with
245          * counterparties that do not support the `scid_alias` option; we will simply fall back to a
246          * private channel without that option.
247          * 
248          * Ignored if the channel is negotiated to be announced, see
249          * [`ChannelHandshakeConfig::announced_channel`] and
250          * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
251          * 
252          * Default value: false. This value is likely to change to true in the future.
253          * 
254          * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
255          * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
256          */
257         public void set_negotiate_scid_privacy(boolean val) {
258                 bindings.ChannelHandshakeConfig_set_negotiate_scid_privacy(this.ptr, val);
259                 Reference.reachabilityFence(this);
260                 Reference.reachabilityFence(val);
261         }
262
263         /**
264          * Set to announce the channel publicly and notify all nodes that they can route via this
265          * channel.
266          * 
267          * This should only be set to true for nodes which expect to be online reliably.
268          * 
269          * As the node which funds a channel picks this value this will only apply for new outbound
270          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
271          * 
272          * Default value: false.
273          */
274         public boolean get_announced_channel() {
275                 boolean ret = bindings.ChannelHandshakeConfig_get_announced_channel(this.ptr);
276                 Reference.reachabilityFence(this);
277                 return ret;
278         }
279
280         /**
281          * Set to announce the channel publicly and notify all nodes that they can route via this
282          * channel.
283          * 
284          * This should only be set to true for nodes which expect to be online reliably.
285          * 
286          * As the node which funds a channel picks this value this will only apply for new outbound
287          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
288          * 
289          * Default value: false.
290          */
291         public void set_announced_channel(boolean val) {
292                 bindings.ChannelHandshakeConfig_set_announced_channel(this.ptr, val);
293                 Reference.reachabilityFence(this);
294                 Reference.reachabilityFence(val);
295         }
296
297         /**
298          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
299          * supports it, they will then enforce the mutual-close output to us matches what we provided
300          * at intialization, preventing us from closing to an alternate pubkey.
301          * 
302          * This is set to true by default to provide a slight increase in security, though ultimately
303          * any attacker who is able to take control of a channel can just as easily send the funds via
304          * lightning payments, so we never require that our counterparties support this option.
305          * 
306          * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
307          * 
308          * Default value: true.
309          * 
310          * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
311          */
312         public boolean get_commit_upfront_shutdown_pubkey() {
313                 boolean ret = bindings.ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
314                 Reference.reachabilityFence(this);
315                 return ret;
316         }
317
318         /**
319          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
320          * supports it, they will then enforce the mutual-close output to us matches what we provided
321          * at intialization, preventing us from closing to an alternate pubkey.
322          * 
323          * This is set to true by default to provide a slight increase in security, though ultimately
324          * any attacker who is able to take control of a channel can just as easily send the funds via
325          * lightning payments, so we never require that our counterparties support this option.
326          * 
327          * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
328          * 
329          * Default value: true.
330          * 
331          * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
332          */
333         public void set_commit_upfront_shutdown_pubkey(boolean val) {
334                 bindings.ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
335                 Reference.reachabilityFence(this);
336                 Reference.reachabilityFence(val);
337         }
338
339         /**
340          * The Proportion of the channel value to configure as counterparty's channel reserve,
341          * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
342          * 
343          * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
344          * on their side, at all times.
345          * This ensures that if our counterparty broadcasts a revoked state, we can punish them by
346          * claiming at least this value on chain.
347          * 
348          * Channel reserve values greater than 30% could be considered highly unreasonable, since that
349          * amount can never be used for payments.
350          * Also, if our selected channel reserve for counterparty and counterparty's selected
351          * channel reserve for us sum up to equal or greater than channel value, channel negotiations
352          * will fail.
353          * 
354          * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
355          * other than the default value.
356          * 
357          * Default value: 1% of channel value, i.e., configured as 10,000 millionths.
358          * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
359          * as 1000 sats instead, which is a safe implementation-specific lower bound.
360          * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
361          * instead, although channel negotiations will fail in that case.
362          */
363         public int get_their_channel_reserve_proportional_millionths() {
364                 int ret = bindings.ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this.ptr);
365                 Reference.reachabilityFence(this);
366                 return ret;
367         }
368
369         /**
370          * The Proportion of the channel value to configure as counterparty's channel reserve,
371          * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
372          * 
373          * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
374          * on their side, at all times.
375          * This ensures that if our counterparty broadcasts a revoked state, we can punish them by
376          * claiming at least this value on chain.
377          * 
378          * Channel reserve values greater than 30% could be considered highly unreasonable, since that
379          * amount can never be used for payments.
380          * Also, if our selected channel reserve for counterparty and counterparty's selected
381          * channel reserve for us sum up to equal or greater than channel value, channel negotiations
382          * will fail.
383          * 
384          * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
385          * other than the default value.
386          * 
387          * Default value: 1% of channel value, i.e., configured as 10,000 millionths.
388          * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
389          * as 1000 sats instead, which is a safe implementation-specific lower bound.
390          * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
391          * instead, although channel negotiations will fail in that case.
392          */
393         public void set_their_channel_reserve_proportional_millionths(int val) {
394                 bindings.ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this.ptr, val);
395                 Reference.reachabilityFence(this);
396                 Reference.reachabilityFence(val);
397         }
398
399         /**
400          * Constructs a new ChannelHandshakeConfig given each field
401          */
402         public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg, byte max_inbound_htlc_value_in_flight_percent_of_channel_arg, boolean negotiate_scid_privacy_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg, int their_channel_reserve_proportional_millionths_arg) {
403                 long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg);
404                 Reference.reachabilityFence(minimum_depth_arg);
405                 Reference.reachabilityFence(our_to_self_delay_arg);
406                 Reference.reachabilityFence(our_htlc_minimum_msat_arg);
407                 Reference.reachabilityFence(max_inbound_htlc_value_in_flight_percent_of_channel_arg);
408                 Reference.reachabilityFence(negotiate_scid_privacy_arg);
409                 Reference.reachabilityFence(announced_channel_arg);
410                 Reference.reachabilityFence(commit_upfront_shutdown_pubkey_arg);
411                 Reference.reachabilityFence(their_channel_reserve_proportional_millionths_arg);
412                 if (ret >= 0 && ret <= 4096) { return null; }
413                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
414                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
415                 return ret_hu_conv;
416         }
417
418         long clone_ptr() {
419                 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
420                 Reference.reachabilityFence(this);
421                 return ret;
422         }
423
424         /**
425          * Creates a copy of the ChannelHandshakeConfig
426          */
427         public ChannelHandshakeConfig clone() {
428                 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
429                 Reference.reachabilityFence(this);
430                 if (ret >= 0 && ret <= 4096) { return null; }
431                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
432                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
433                 return ret_hu_conv;
434         }
435
436         /**
437          * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
438          */
439         public static ChannelHandshakeConfig with_default() {
440                 long ret = bindings.ChannelHandshakeConfig_default();
441                 if (ret >= 0 && ret <= 4096) { return null; }
442                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
443                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
444                 return ret_hu_conv;
445         }
446
447 }