cea0ccc54fe02fa8f76462796e13c0a4ac7bb429
[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          * [`ChannelConfig::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          * [`ChannelConfig::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          * Constructs a new ChannelHandshakeConfig given each field
265          */
266         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) {
267                 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);
268                 Reference.reachabilityFence(minimum_depth_arg);
269                 Reference.reachabilityFence(our_to_self_delay_arg);
270                 Reference.reachabilityFence(our_htlc_minimum_msat_arg);
271                 Reference.reachabilityFence(max_inbound_htlc_value_in_flight_percent_of_channel_arg);
272                 Reference.reachabilityFence(negotiate_scid_privacy_arg);
273                 if (ret >= 0 && ret <= 4096) { return null; }
274                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
275                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
276                 return ret_hu_conv;
277         }
278
279         long clone_ptr() {
280                 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
281                 Reference.reachabilityFence(this);
282                 return ret;
283         }
284
285         /**
286          * Creates a copy of the ChannelHandshakeConfig
287          */
288         public ChannelHandshakeConfig clone() {
289                 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
290                 Reference.reachabilityFence(this);
291                 if (ret >= 0 && ret <= 4096) { return null; }
292                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
293                 ret_hu_conv.ptrs_to.add(this);
294                 return ret_hu_conv;
295         }
296
297         /**
298          * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
299          */
300         public static ChannelHandshakeConfig with_default() {
301                 long ret = bindings.ChannelHandshakeConfig_default();
302                 if (ret >= 0 && ret <= 4096) { return null; }
303                 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
304                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
305                 return ret_hu_conv;
306         }
307
308 }