@@ -397,6 +397,34 @@ pub struct ChannelConfig {
397
397
/// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
398
398
/// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
399
399
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 ,
400
428
}
401
429
402
430
impl ChannelConfig {
@@ -429,12 +457,14 @@ impl Default for ChannelConfig {
429
457
cltv_expiry_delta : 6 * 12 , // 6 blocks/hour * 12 hours
430
458
max_dust_htlc_exposure_msat : 5_000_000 ,
431
459
force_close_avoidance_max_fee_satoshis : 1000 ,
460
+ accept_underpaying_htlcs : false ,
432
461
}
433
462
}
434
463
}
435
464
436
465
impl_writeable_tlv_based ! ( ChannelConfig , {
437
466
( 0 , forwarding_fee_proportional_millionths, required) ,
467
+ ( 1 , accept_underpaying_htlcs, ( default_value, false ) ) ,
438
468
( 2 , forwarding_fee_base_msat, required) ,
439
469
( 4 , cltv_expiry_delta, required) ,
440
470
( 6 , max_dust_htlc_exposure_msat, required) ,
@@ -543,6 +573,7 @@ impl crate::util::ser::Readable for LegacyChannelConfig {
543
573
cltv_expiry_delta,
544
574
force_close_avoidance_max_fee_satoshis,
545
575
forwarding_fee_base_msat,
576
+ accept_underpaying_htlcs : false ,
546
577
} ,
547
578
announced_channel,
548
579
commit_upfront_shutdown_pubkey,
0 commit comments