Skip to content

Commit 85a5b31

Browse files
Add config knob for accepting underpaying HTLCs
See ChannelConfig::accept_underpaying_htlcs
1 parent 672d666 commit 85a5b31

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lightning/src/util/config.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,34 @@ pub struct ChannelConfig {
397397
/// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
398398
/// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
399399
pub force_close_avoidance_max_fee_satoshis: u64,
400+
/// If set, allows this channel's counterparty to skim an additional fee off this node's inbound
401+
/// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
402+
///
403+
/// Usage:
404+
/// - The payee will set this option and set its invoice route hints to use [intercept scids]
405+
/// generated by this channel's counterparty.
406+
/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
407+
/// [`forward_intercepted_htlc`] with less than the amount provided in
408+
/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
409+
/// actual forward amounts is their fee.
410+
// TODO: link to LSP JIT channel invoice generation spec when it's merged
411+
///
412+
/// # Note
413+
/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
414+
/// as-expected if this feature is activated, otherwise they may lose money!
415+
///
416+
/// # Note
417+
/// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
418+
///
419+
/// Default value: false.
420+
///
421+
/// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
422+
/// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
423+
/// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
424+
/// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
425+
/// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
426+
// TODO: link to bLIP when it's merged
427+
pub accept_underpaying_htlcs: bool,
400428
}
401429

402430
impl ChannelConfig {
@@ -429,12 +457,14 @@ impl Default for ChannelConfig {
429457
cltv_expiry_delta: 6 * 12, // 6 blocks/hour * 12 hours
430458
max_dust_htlc_exposure_msat: 5_000_000,
431459
force_close_avoidance_max_fee_satoshis: 1000,
460+
accept_underpaying_htlcs: false,
432461
}
433462
}
434463
}
435464

436465
impl_writeable_tlv_based!(ChannelConfig, {
437466
(0, forwarding_fee_proportional_millionths, required),
467+
(1, accept_underpaying_htlcs, (default_value, false)),
438468
(2, forwarding_fee_base_msat, required),
439469
(4, cltv_expiry_delta, required),
440470
(6, max_dust_htlc_exposure_msat, required),
@@ -543,6 +573,7 @@ impl crate::util::ser::Readable for LegacyChannelConfig {
543573
cltv_expiry_delta,
544574
force_close_avoidance_max_fee_satoshis,
545575
forwarding_fee_base_msat,
576+
accept_underpaying_htlcs: false,
546577
},
547578
announced_channel,
548579
commit_upfront_shutdown_pubkey,

0 commit comments

Comments
 (0)