X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelConfig.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelConfig.java;h=a62a87952c06f97daea9c3fc9fbe9cb095b2077f;hb=8fa2bcb208a51fa352d04981f1387d8bceced107;hp=bdeef3038ab41467db483e19a83c3536b5e3eda4;hpb=7da1092518e5ea1518255a4473c178f52549fd81;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelConfig.java b/src/main/java/org/ldk/structs/ChannelConfig.java index bdeef303..a62a8795 100644 --- a/src/main/java/org/ldk/structs/ChannelConfig.java +++ b/src/main/java/org/ldk/structs/ChannelConfig.java @@ -157,19 +157,22 @@ public class ChannelConfig extends CommonBase { * channel negotiated throughout the channel open process, along with the fees required to have * a broadcastable HTLC spending transaction. When a channel supports anchor outputs * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into - * account the HTLC transaction fee as it is zero. + * account the HTLC transaction fee as it is zero. Because of this, you may want to set this + * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier + * variant is primarily intended for use with pre-anchor channels. * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. + * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. * - * Default value: 5_000_000 msat. + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. */ - public long get_max_dust_htlc_exposure_msat() { - long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure_msat(this.ptr); + public MaxDustHTLCExposure get_max_dust_htlc_exposure() { + long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure(this.ptr); Reference.reachabilityFence(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** @@ -186,19 +189,20 @@ public class ChannelConfig extends CommonBase { * channel negotiated throughout the channel open process, along with the fees required to have * a broadcastable HTLC spending transaction. When a channel supports anchor outputs * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into - * account the HTLC transaction fee as it is zero. + * account the HTLC transaction fee as it is zero. Because of this, you may want to set this + * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier + * variant is primarily intended for use with pre-anchor channels. * - * This limit is applied for sent, forwarded, and received HTLCs and limits the total - * exposure across all three types per-channel. Setting this too low may prevent the - * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very - * important to prevent stealing of dust HTLCs by miners. + * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total + * exposure across all three types per-channel. * - * Default value: 5_000_000 msat. + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. */ - public void set_max_dust_htlc_exposure_msat(long val) { - bindings.ChannelConfig_set_max_dust_htlc_exposure_msat(this.ptr, val); + public void set_max_dust_htlc_exposure(org.ldk.structs.MaxDustHTLCExposure val) { + bindings.ChannelConfig_set_max_dust_htlc_exposure(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -261,19 +265,95 @@ public class ChannelConfig extends CommonBase { Reference.reachabilityFence(val); } + /** + * If set, allows this channel's counterparty to skim an additional fee off this node's inbound + * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + * + * Usage: + * - The payee will set this option and set its invoice route hints to use [intercept scids] + * generated by this channel's counterparty. + * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call + * [`forward_intercepted_htlc`] with less than the amount provided in + * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and + * actual forward amounts is their fee. + * + * # Note + * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is + * as-expected if this feature is activated, otherwise they may lose money! + * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the + * counterparty. + * + * # Note + * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. + * Unsetting this flag between restarts may lead to payment receive failures. + * + * Default value: false. + * + * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat + * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat + */ + public boolean get_accept_underpaying_htlcs() { + boolean ret = bindings.ChannelConfig_get_accept_underpaying_htlcs(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * If set, allows this channel's counterparty to skim an additional fee off this node's inbound + * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + * + * Usage: + * - The payee will set this option and set its invoice route hints to use [intercept scids] + * generated by this channel's counterparty. + * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call + * [`forward_intercepted_htlc`] with less than the amount provided in + * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and + * actual forward amounts is their fee. + * + * # Note + * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is + * as-expected if this feature is activated, otherwise they may lose money! + * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the + * counterparty. + * + * # Note + * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. + * Unsetting this flag between restarts may lead to payment receive failures. + * + * Default value: false. + * + * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc + * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat + * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat + */ + public void set_accept_underpaying_htlcs(boolean val) { + bindings.ChannelConfig_set_accept_underpaying_htlcs(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + /** * Constructs a new ChannelConfig given each field */ - public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, long max_dust_htlc_exposure_msat_arg, long force_close_avoidance_max_fee_satoshis_arg) { - long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg); + public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, org.ldk.structs.MaxDustHTLCExposure max_dust_htlc_exposure_arg, long force_close_avoidance_max_fee_satoshis_arg, boolean accept_underpaying_htlcs_arg) { + long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_arg.ptr, force_close_avoidance_max_fee_satoshis_arg, accept_underpaying_htlcs_arg); Reference.reachabilityFence(forwarding_fee_proportional_millionths_arg); Reference.reachabilityFence(forwarding_fee_base_msat_arg); Reference.reachabilityFence(cltv_expiry_delta_arg); - Reference.reachabilityFence(max_dust_htlc_exposure_msat_arg); + Reference.reachabilityFence(max_dust_htlc_exposure_arg); Reference.reachabilityFence(force_close_avoidance_max_fee_satoshis_arg); + Reference.reachabilityFence(accept_underpaying_htlcs_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(max_dust_htlc_exposure_arg); }; return ret_hu_conv; } @@ -312,6 +392,16 @@ public class ChannelConfig extends CommonBase { if (!(o instanceof ChannelConfig)) return false; return this.eq((ChannelConfig)o); } + /** + * Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`]. + */ + public void apply(org.ldk.structs.ChannelConfigUpdate update) { + bindings.ChannelConfig_apply(this.ptr, update == null ? 0 : update.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(update); + if (this != null) { this.ptrs_to.add(update); }; + } + /** * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */