6 namespace org { namespace ldk { namespace structs {
10 * Configuration we set when applicable.
12 * Default::default() provides sane defaults.
14 public class ChannelHandshakeConfig : CommonBase {
15 internal ChannelHandshakeConfig(object _dummy, long ptr) : base(ptr) { }
16 ~ChannelHandshakeConfig() {
17 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
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).
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`].
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
35 public int get_minimum_depth() {
36 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
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).
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`].
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
56 public void set_minimum_depth(int val) {
57 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
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
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).
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
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.
79 public short get_our_to_self_delay() {
80 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
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
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).
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
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.
102 public void set_our_to_self_delay(short val) {
103 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
109 * Set to the smallest value HTLC we will accept to process.
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.
114 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
117 public long get_our_htlc_minimum_msat() {
118 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
124 * Set to the smallest value HTLC we will accept to process.
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.
129 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
132 public void set_our_htlc_minimum_msat(long val) {
133 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
139 * Sets the percentage of the channel value we will cap the total value of outstanding inbound
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.
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
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.
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.
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.
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);
170 * Sets the percentage of the channel value we will cap the total value of outstanding inbound
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.
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
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.
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.
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.
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);
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.
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`].
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.
214 * Ignored if the channel is negotiated to be announced, see
215 * [`ChannelHandshakeConfig::announced_channel`] and
216 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
218 * Default value: false. This value is likely to change to true in the future.
220 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
221 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
223 public bool get_negotiate_scid_privacy() {
224 bool ret = bindings.ChannelHandshakeConfig_get_negotiate_scid_privacy(this.ptr);
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.
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`].
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.
243 * Ignored if the channel is negotiated to be announced, see
244 * [`ChannelHandshakeConfig::announced_channel`] and
245 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
247 * Default value: false. This value is likely to change to true in the future.
249 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
250 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
252 public void set_negotiate_scid_privacy(bool val) {
253 bindings.ChannelHandshakeConfig_set_negotiate_scid_privacy(this.ptr, val);
259 * Set to announce the channel publicly and notify all nodes that they can route via this
262 * This should only be set to true for nodes which expect to be online reliably.
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.
267 * Default value: false.
269 public bool get_announced_channel() {
270 bool ret = bindings.ChannelHandshakeConfig_get_announced_channel(this.ptr);
276 * Set to announce the channel publicly and notify all nodes that they can route via this
279 * This should only be set to true for nodes which expect to be online reliably.
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.
284 * Default value: false.
286 public void set_announced_channel(bool val) {
287 bindings.ChannelHandshakeConfig_set_announced_channel(this.ptr, val);
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.
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.
301 * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
303 * Default value: true.
305 * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey
307 public bool get_commit_upfront_shutdown_pubkey() {
308 bool ret = bindings.ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
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.
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.
322 * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
324 * Default value: true.
326 * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey
328 public void set_commit_upfront_shutdown_pubkey(bool val) {
329 bindings.ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
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.
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.
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
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.
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.
358 public int get_their_channel_reserve_proportional_millionths() {
359 int ret = bindings.ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this.ptr);
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.
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.
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
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.
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.
388 public void set_their_channel_reserve_proportional_millionths(int val) {
389 bindings.ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this.ptr, val);
395 * If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future
396 * channels. This feature requires having a reserve of onchain funds readily available to bump
397 * transactions in the event of a channel force close to avoid the possibility of losing funds.
399 * Note that if you wish accept inbound channels with anchor outputs, you must enable
400 * [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
401 * [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
402 * whether your reserve of onchain funds is enough to cover the fees for all existing and new
403 * channels featuring anchor outputs in the event of a force close.
405 * If this option is set, channels may be created that will not be readable by LDK versions
406 * prior to 0.0.116, causing [`ChannelManager`]'s read method to return a
407 * [`DecodeError::InvalidValue`].
409 * Note that setting this to true does *not* prevent us from opening channels with
410 * counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
411 * fall back to a `static_remote_key` channel.
413 * LDK will not support the legacy `option_anchors` commitment version due to a discovered
414 * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee
415 * Considered Harmful`] mailing list post.
417 * Default value: false. This value is likely to change to true in the future.
419 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
420 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
421 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
422 * [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html
424 public bool get_negotiate_anchors_zero_fee_htlc_tx() {
425 bool ret = bindings.ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(this.ptr);
431 * If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future
432 * channels. This feature requires having a reserve of onchain funds readily available to bump
433 * transactions in the event of a channel force close to avoid the possibility of losing funds.
435 * Note that if you wish accept inbound channels with anchor outputs, you must enable
436 * [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
437 * [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
438 * whether your reserve of onchain funds is enough to cover the fees for all existing and new
439 * channels featuring anchor outputs in the event of a force close.
441 * If this option is set, channels may be created that will not be readable by LDK versions
442 * prior to 0.0.116, causing [`ChannelManager`]'s read method to return a
443 * [`DecodeError::InvalidValue`].
445 * Note that setting this to true does *not* prevent us from opening channels with
446 * counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
447 * fall back to a `static_remote_key` channel.
449 * LDK will not support the legacy `option_anchors` commitment version due to a discovered
450 * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee
451 * Considered Harmful`] mailing list post.
453 * Default value: false. This value is likely to change to true in the future.
455 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
456 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
457 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
458 * [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html
460 public void set_negotiate_anchors_zero_fee_htlc_tx(bool val) {
461 bindings.ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(this.ptr, val);
467 * The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
469 * Increasing the value can help improve liquidity and stability in
470 * routing at the cost of higher long term disk / DB usage.
472 * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
473 * other than the default value.
476 * Maximum value: 483, any values larger will be treated as 483.
477 * This is the BOLT #2 spec limit on `max_accepted_htlcs`.
479 public short get_our_max_accepted_htlcs() {
480 short ret = bindings.ChannelHandshakeConfig_get_our_max_accepted_htlcs(this.ptr);
486 * The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
488 * Increasing the value can help improve liquidity and stability in
489 * routing at the cost of higher long term disk / DB usage.
491 * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
492 * other than the default value.
495 * Maximum value: 483, any values larger will be treated as 483.
496 * This is the BOLT #2 spec limit on `max_accepted_htlcs`.
498 public void set_our_max_accepted_htlcs(short val) {
499 bindings.ChannelHandshakeConfig_set_our_max_accepted_htlcs(this.ptr, val);
505 * Constructs a new ChannelHandshakeConfig given each field
507 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, bool negotiate_anchors_zero_fee_htlc_tx_arg, short our_max_accepted_htlcs_arg) {
508 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, negotiate_anchors_zero_fee_htlc_tx_arg, our_max_accepted_htlcs_arg);
509 GC.KeepAlive(minimum_depth_arg);
510 GC.KeepAlive(our_to_self_delay_arg);
511 GC.KeepAlive(our_htlc_minimum_msat_arg);
512 GC.KeepAlive(max_inbound_htlc_value_in_flight_percent_of_channel_arg);
513 GC.KeepAlive(negotiate_scid_privacy_arg);
514 GC.KeepAlive(announced_channel_arg);
515 GC.KeepAlive(commit_upfront_shutdown_pubkey_arg);
516 GC.KeepAlive(their_channel_reserve_proportional_millionths_arg);
517 GC.KeepAlive(negotiate_anchors_zero_fee_htlc_tx_arg);
518 GC.KeepAlive(our_max_accepted_htlcs_arg);
519 if (ret >= 0 && ret <= 4096) { return null; }
520 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
521 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
525 internal long clone_ptr() {
526 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
532 * Creates a copy of the ChannelHandshakeConfig
534 public ChannelHandshakeConfig clone() {
535 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
537 if (ret >= 0 && ret <= 4096) { return null; }
538 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
539 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
544 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
546 public static ChannelHandshakeConfig with_default() {
547 long ret = bindings.ChannelHandshakeConfig_default();
548 if (ret >= 0 && ret <= 4096) { return null; }
549 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
550 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };