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