Skip to content

Commit d5a0eb4

Browse files
authored
Merge pull request #2715 from valentinewallace/2023-11-skimmed-fees
Complete underpaying HTLCs support
2 parents 9854477 + 0edd645 commit d5a0eb4

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lightning/src/events/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,15 @@ pub struct ClaimedHTLC {
102102
pub cltv_expiry: u32,
103103
/// The amount (in msats) of this part of an MPP.
104104
pub value_msat: u64,
105+
/// The extra fee our counterparty skimmed off the top of this HTLC, if any.
106+
///
107+
/// This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to
108+
/// 0.0.119.
109+
pub counterparty_skimmed_fee_msat: u64,
105110
}
106111
impl_writeable_tlv_based!(ClaimedHTLC, {
107112
(0, channel_id, required),
113+
(1, counterparty_skimmed_fee_msat, (default_value, 0u64)),
108114
(2, user_channel_id, required),
109115
(4, cltv_expiry, required),
110116
(6, value_msat, required),

lightning/src/ln/channelmanager.rs

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl From<&ClaimableHTLC> for events::ClaimedHTLC {
238238
user_channel_id: val.prev_hop.user_channel_id.unwrap_or(0),
239239
cltv_expiry: val.cltv_expiry,
240240
value_msat: val.value,
241+
counterparty_skimmed_fee_msat: val.counterparty_skimmed_fee_msat.unwrap_or(0),
241242
}
242243
}
243244
}

lightning/src/util/config.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,9 @@ pub struct ChannelConfig {
462462
/// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
463463
/// [`forward_intercepted_htlc`] with less than the amount provided in
464464
/// [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
465-
/// actual forward amounts is their fee.
466-
// TODO: link to LSP JIT channel invoice generation spec when it's merged
465+
/// actual forward amounts is their fee. See
466+
/// <https://github.com/BitcoinAndLightningLayerSpecs/lsp/tree/main/LSPS2#flow-lsp-trusts-client-model>
467+
/// for how this feature may be used in the LSP use case.
467468
///
468469
/// # Note
469470
/// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is

0 commit comments

Comments
 (0)