@@ -5740,7 +5740,7 @@ where
57405740 fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
57415741 forwarded_htlc_value_msat: Option<u64>, skimmed_fee_msat: Option<u64>, from_onchain: bool,
57425742 startup_replay: bool, next_channel_counterparty_node_id: Option<PublicKey>,
5743- next_channel_outpoint: OutPoint, next_channel_id: ChannelId,
5743+ next_channel_outpoint: OutPoint, next_channel_id: ChannelId, next_user_channel_id: Option<u128>,
57445744 ) {
57455745 match source {
57465746 HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
@@ -5759,11 +5759,10 @@ where
57595759 },
57605760 HTLCSource::PreviousHopData(hop_data) => {
57615761 let prev_channel_id = hop_data.channel_id;
5762+ let prev_user_channel_id = hop_data.user_channel_id;
57625763 let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
57635764 #[cfg(debug_assertions)]
57645765 let claiming_chan_funding_outpoint = hop_data.outpoint;
5765- #[cfg(debug_assertions)]
5766- let claiming_channel_id = hop_data.channel_id;
57675766 let res = self.claim_funds_from_hop(hop_data, payment_preimage,
57685767 |htlc_claim_value_msat, definitely_duplicate| {
57695768 let chan_to_release =
@@ -5821,7 +5820,7 @@ where
58215820 BackgroundEvent::MonitorUpdatesComplete {
58225821 channel_id, ..
58235822 } =>
5824- *channel_id == claiming_channel_id ,
5823+ *channel_id == prev_channel_id ,
58255824 }
58265825 }), "{:?}", *background_events);
58275826 }
@@ -5845,12 +5844,14 @@ where
58455844 "skimmed_fee_msat must always be included in total_fee_earned_msat");
58465845 Some(MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
58475846 event: events::Event::PaymentForwarded {
5848- total_fee_earned_msat,
5849- claim_from_onchain_tx: from_onchain,
58505847 prev_channel_id: Some(prev_channel_id),
58515848 next_channel_id: Some(next_channel_id),
5852- outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
5849+ prev_user_channel_id,
5850+ next_user_channel_id,
5851+ total_fee_earned_msat,
58535852 skimmed_fee_msat,
5853+ claim_from_onchain_tx: from_onchain,
5854+ outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
58545855 },
58555856 downstream_counterparty_and_funding_outpoint: chan_to_release,
58565857 })
@@ -6824,6 +6825,7 @@ where
68246825
68256826 fn internal_update_fulfill_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) -> Result<(), MsgHandleErrInternal> {
68266827 let funding_txo;
6828+ let next_user_channel_id;
68276829 let (htlc_source, forwarded_htlc_value, skimmed_fee_msat) = {
68286830 let per_peer_state = self.per_peer_state.read().unwrap();
68296831 let peer_state_mutex = per_peer_state.get(counterparty_node_id)
@@ -6853,6 +6855,7 @@ where
68536855 // outbound HTLC is claimed. This is guaranteed to all complete before we
68546856 // process the RAA as messages are processed from single peers serially.
68556857 funding_txo = chan.context.get_funding_txo().expect("We won't accept a fulfill until funded");
6858+ next_user_channel_id = chan.context.get_user_id();
68566859 res
68576860 } else {
68586861 return try_chan_phase_entry!(self, Err(ChannelError::Close(
@@ -6864,7 +6867,7 @@ where
68646867 };
68656868 self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
68666869 Some(forwarded_htlc_value), skimmed_fee_msat, false, false, Some(*counterparty_node_id),
6867- funding_txo, msg.channel_id
6870+ funding_txo, msg.channel_id, Some(next_user_channel_id),
68686871 );
68696872
68706873 Ok(())
@@ -7366,7 +7369,7 @@ where
73667369 log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
73677370 self.claim_funds_internal(htlc_update.source, preimage,
73687371 htlc_update.htlc_value_satoshis.map(|v| v * 1000), None, true,
7369- false, counterparty_node_id, funding_outpoint, channel_id);
7372+ false, counterparty_node_id, funding_outpoint, channel_id, None );
73707373 } else {
73717374 log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
73727375 let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id };
@@ -11386,7 +11389,9 @@ where
1138611389 // don't remember in the `ChannelMonitor` where we got a preimage from, but if the
1138711390 // channel is closed we just assume that it probably came from an on-chain claim.
1138811391 channel_manager.claim_funds_internal(source, preimage, Some(downstream_value), None,
11389- downstream_closed, true, downstream_node_id, downstream_funding, downstream_channel_id);
11392+ downstream_closed, true, downstream_node_id, downstream_funding,
11393+ downstream_channel_id, None
11394+ );
1139011395 }
1139111396
1139211397 //TODO: Broadcast channel update for closed channels, but only after we've made a
0 commit comments