X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelHandshakeConfig.java;h=69348fc316ca3c19fbd02ebcb9a70274745484e4;hb=4a36fa97d4eee96099c4a176ea845c52db27e64c;hp=f6a3bfb625d6a0f0c8b6a12fc1bf3f169df915c9;hpb=9aa1eebc40df06586c7ab12f7c8eb22ebcb8b365;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java index f6a3bfb6..69348fc3 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java @@ -27,7 +27,15 @@ public class ChannelHandshakeConfig extends CommonBase { * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the * equivalent limit applied to outbound channels). * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ public int get_minimum_depth() { int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr); @@ -40,7 +48,15 @@ public class ChannelHandshakeConfig extends CommonBase { * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the * equivalent limit applied to outbound channels). * + * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * transaction before operation. If you wish to accept channels with zero confirmations, see + * [`UserConfig::manually_accept_inbound_channels`] and + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. + * * Default value: 6. + * + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf */ public void set_minimum_depth(int val) { bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val); @@ -124,6 +140,68 @@ public class ChannelHandshakeConfig extends CommonBase { Reference.reachabilityFence(val); } + /** + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + */ + public byte get_max_inbound_htlc_value_in_flight_percent_of_channel() { + byte ret = bindings.ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Sets the percentage of the channel value we will cap the total value of outstanding inbound + * HTLCs to. + * + * This can be set to a value between 1-100, where the value corresponds to the percent of the + * channel value in whole percentages. + * + * Note that: + * If configured to another value than the default value 10, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. + * + * This caps the total value for inbound HTLCs in-flight only, and there's currently + * no way to configure the cap for the total value of outbound HTLCs in-flight. + * + * The requirements for your node being online to ensure the safety of HTLC-encumbered funds + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: 10. + * Minimum value: 1, any values less than 1 will be treated as 1 instead. + * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + */ + public void set_max_inbound_htlc_value_in_flight_percent_of_channel(byte val) { + bindings.ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + /** * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the * BOLTs) option for outbound private channels. This provides better privacy by not including @@ -132,20 +210,20 @@ public class ChannelHandshakeConfig extends CommonBase { * * If this option is set, channels may be created that will not be readable by LDK versions * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a - * [`DecodeError:InvalidValue`]. + * [`DecodeError::InvalidValue`]. * * Note that setting this to true does *not* prevent us from opening channels with * counterparties that do not support the `scid_alias` option; we will simply fall back to a * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announced_channel`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * * Default value: false. This value is likely to change to true in the future. * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue */ public boolean get_negotiate_scid_privacy() { boolean ret = bindings.ChannelHandshakeConfig_get_negotiate_scid_privacy(this.ptr); @@ -161,20 +239,20 @@ public class ChannelHandshakeConfig extends CommonBase { * * If this option is set, channels may be created that will not be readable by LDK versions * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a - * [`DecodeError:InvalidValue`]. + * [`DecodeError::InvalidValue`]. * * Note that setting this to true does *not* prevent us from opening channels with * counterparties that do not support the `scid_alias` option; we will simply fall back to a * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announced_channel`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * * Default value: false. This value is likely to change to true in the future. * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue + * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue */ public void set_negotiate_scid_privacy(boolean val) { bindings.ChannelHandshakeConfig_set_negotiate_scid_privacy(this.ptr, val); @@ -182,18 +260,197 @@ public class ChannelHandshakeConfig extends CommonBase { Reference.reachabilityFence(val); } + /** + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. + */ + public boolean get_announced_channel() { + boolean ret = bindings.ChannelHandshakeConfig_get_announced_channel(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Set to announce the channel publicly and notify all nodes that they can route via this + * channel. + * + * This should only be set to true for nodes which expect to be online reliably. + * + * As the node which funds a channel picks this value this will only apply for new outbound + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. + * + * Default value: false. + */ + public void set_announced_channel(boolean val) { + bindings.ChannelHandshakeConfig_set_announced_channel(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + */ + public boolean get_commit_upfront_shutdown_pubkey() { + boolean ret = bindings.ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty + * supports it, they will then enforce the mutual-close output to us matches what we provided + * at intialization, preventing us from closing to an alternate pubkey. + * + * This is set to true by default to provide a slight increase in security, though ultimately + * any attacker who is able to take control of a channel can just as easily send the funds via + * lightning payments, so we never require that our counterparties support this option. + * + * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. + * + * Default value: true. + * + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + */ + public void set_commit_upfront_shutdown_pubkey(boolean val) { + bindings.ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. + */ + public int get_their_channel_reserve_proportional_millionths() { + int ret = bindings.ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * The Proportion of the channel value to configure as counterparty's channel reserve, + * i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels. + * + * `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain + * on their side, at all times. + * This ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * Channel reserve values greater than 30% could be considered highly unreasonable, since that + * amount can never be used for payments. + * Also, if our selected channel reserve for counterparty and counterparty's selected + * channel reserve for us sum up to equal or greater than channel value, channel negotiations + * will fail. + * + * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve + * other than the default value. + * + * Default value: 1% of channel value, i.e., configured as 10,000 millionths. + * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated + * as 1000 sats instead, which is a safe implementation-specific lower bound. + * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) + * instead, although channel negotiations will fail in that case. + */ + public void set_their_channel_reserve_proportional_millionths(int val) { + bindings.ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + */ + public short get_our_max_accepted_htlcs() { + short ret = bindings.ChannelHandshakeConfig_get_our_max_accepted_htlcs(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * The maximum number of HTLCs in-flight from our counterparty towards us at the same time. + * + * Increasing the value can help improve liquidity and stability in + * routing at the cost of higher long term disk / DB usage. + * + * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration + * other than the default value. + * + * Default value: 50 + * Maximum value: 483, any values larger will be treated as 483. + * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + */ + public void set_our_max_accepted_htlcs(short val) { + bindings.ChannelHandshakeConfig_set_our_max_accepted_htlcs(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + /** * Constructs a new ChannelHandshakeConfig given each field */ - public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg, boolean negotiate_scid_privacy_arg) { - long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg); + 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, short our_max_accepted_htlcs_arg) { + 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, our_max_accepted_htlcs_arg); Reference.reachabilityFence(minimum_depth_arg); Reference.reachabilityFence(our_to_self_delay_arg); Reference.reachabilityFence(our_htlc_minimum_msat_arg); + Reference.reachabilityFence(max_inbound_htlc_value_in_flight_percent_of_channel_arg); Reference.reachabilityFence(negotiate_scid_privacy_arg); + Reference.reachabilityFence(announced_channel_arg); + Reference.reachabilityFence(commit_upfront_shutdown_pubkey_arg); + Reference.reachabilityFence(their_channel_reserve_proportional_millionths_arg); + Reference.reachabilityFence(our_max_accepted_htlcs_arg); if (ret >= 0 && ret <= 4096) { return null; } - ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); } - ret_hu_conv.ptrs_to.add(ret_hu_conv); + org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } @@ -210,8 +467,8 @@ public class ChannelHandshakeConfig extends CommonBase { long ret = bindings.ChannelHandshakeConfig_clone(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); } - ret_hu_conv.ptrs_to.add(this); + org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -221,8 +478,8 @@ public class ChannelHandshakeConfig extends CommonBase { public static ChannelHandshakeConfig with_default() { long ret = bindings.ChannelHandshakeConfig_default(); if (ret >= 0 && ret <= 4096) { return null; } - ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); } - ret_hu_conv.ptrs_to.add(ret_hu_conv); + org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; }