@@ -481,6 +481,7 @@ impl PendingAddHTLCInfo {
481481 HTLCPreviousHopData {
482482 prev_outbound_scid_alias: self.prev_outbound_scid_alias,
483483 user_channel_id: Some(self.prev_user_channel_id),
484+ amount_msat: self.forward_info.incoming_amt_msat,
484485 outpoint: self.prev_funding_outpoint,
485486 channel_id: self.prev_channel_id,
486487 counterparty_node_id: Some(self.prev_counterparty_node_id),
@@ -944,6 +945,7 @@ mod fuzzy_channelmanager {
944945 pub struct HTLCPreviousHopData {
945946 pub prev_outbound_scid_alias: u64,
946947 pub user_channel_id: Option<u128>,
948+ pub amount_msat: Option<u64>,
947949 pub htlc_id: u64,
948950 pub incoming_packet_shared_secret: [u8; 32],
949951 pub phantom_shared_secret: Option<[u8; 32]>,
@@ -960,12 +962,13 @@ mod fuzzy_channelmanager {
960962 pub cltv_expiry: Option<u32>,
961963 }
962964
963- impl From<& HTLCPreviousHopData> for events::HTLCLocator {
964- fn from(value: &HTLCPreviousHopData ) -> Self {
965+ impl HTLCPreviousHopData {
966+ pub(super) fn htlc_locator(&self, amount_msat: Option<u64> ) -> events::HTLCLocator {
965967 events::HTLCLocator {
966- channel_id: value.channel_id,
967- user_channel_id: value.user_channel_id,
968- node_id: value.counterparty_node_id,
968+ channel_id: self.channel_id,
969+ amount_msat,
970+ user_channel_id: self.user_channel_id,
971+ node_id: self.counterparty_node_id,
969972 }
970973 }
971974 }
@@ -8860,6 +8863,7 @@ impl<
88608863 let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
88618864 prev_outbound_scid_alias: prev_hop.prev_outbound_scid_alias,
88628865 user_channel_id: prev_hop.user_channel_id,
8866+ amount_msat: Some(value),
88638867 counterparty_node_id: prev_hop.counterparty_node_id,
88648868 channel_id: prev_channel_id,
88658869 outpoint: prev_funding_outpoint,
@@ -10522,7 +10526,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1052210526 }
1052310527 },
1052410528 HTLCSource::PreviousHopData(hop_data) => {
10525- let prev_htlcs = vec![events::HTLCLocator::from(& hop_data)] ;
10529+ let event_prev_hop_data = hop_data.clone() ;
1052610530 self.claim_funds_from_htlc_forward_hop(
1052710531 payment_preimage,
1052810532 |htlc_claim_value_msat: Option<u64>| -> Option<events::Event> {
@@ -10536,11 +10540,16 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1053610540 skimmed_fee_msat <= total_fee_earned_msat,
1053710541 "skimmed_fee_msat must always be included in total_fee_earned_msat"
1053810542 );
10543+ let prev_htlc_amount_msat =
10544+ event_prev_hop_data.amount_msat.or(htlc_claim_value_msat);
1053910545
1054010546 Some(events::Event::PaymentForwarded {
10541- prev_htlcs,
10547+ prev_htlcs: vec![
10548+ event_prev_hop_data.htlc_locator(prev_htlc_amount_msat)
10549+ ],
1054210550 next_htlcs: vec![events::HTLCLocator {
1054310551 channel_id: next_channel_id,
10552+ amount_msat: Some(forwarded_htlc_value_msat),
1054410553 user_channel_id: next_user_channel_id,
1054510554 node_id: Some(next_channel_counterparty_node_id),
1054610555 }],
@@ -10561,20 +10570,29 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1056110570 },
1056210571 HTLCSource::TrampolineForward { previous_hop_data, .. } => {
1056310572 // Only emit a single event for trampoline claims.
10564- let prev_htlcs: Vec<events::HTLCLocator> =
10565- previous_hop_data.iter().map(Into::into).collect();
10573+ let mut event_prev_htlcs = Some(
10574+ previous_hop_data.iter().map(|hop| hop.htlc_locator(hop.amount_msat)).collect(),
10575+ );
1056610576 for (i, current_previous_hop_data) in previous_hop_data.into_iter().enumerate() {
1056710577 self.claim_funds_from_htlc_forward_hop(
1056810578 payment_preimage,
1056910579 |_: Option<u64>| -> Option<events::Event> {
1057010580 if i == 0 {
10581+ let Some(prev_htlcs) = event_prev_htlcs.take() else {
10582+ debug_assert!(
10583+ false,
10584+ "trampoline forward event already emitted"
10585+ );
10586+ return None;
10587+ };
1057110588 Some(events::Event::PaymentForwarded {
10572- prev_htlcs: prev_htlcs.clone() ,
10589+ prev_htlcs,
1057310590 // TODO: When trampoline payments are tracked in our
1057410591 // pending_outbound_payments, we'll be able to provide all the
1057510592 // outgoing htlcs for this forward.
1057610593 next_htlcs: vec![events::HTLCLocator {
1057710594 channel_id: next_channel_id,
10595+ amount_msat: Some(forwarded_htlc_value_msat),
1057810596 user_channel_id: next_user_channel_id,
1057910597 node_id: Some(next_channel_counterparty_node_id),
1058010598 }],
@@ -18343,6 +18361,7 @@ impl_ser_tlv_based!(HTLCPreviousHopData, {
1834318361 (9, channel_id, (default_value, ChannelId::v1_from_funding_outpoint(outpoint.0.unwrap()))),
1834418362 (11, counterparty_node_id, option),
1834518363 (13, trampoline_shared_secret, option),
18364+ (15, amount_msat, option),
1834618365});
1834718366
1834818367fn write_claimable_htlc<W: Writer>(
0 commit comments