@@ -5740,7 +5740,7 @@ where
5740
5740
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
5741
5741
forwarded_htlc_value_msat: Option<u64>, skimmed_fee_msat: Option<u64>, from_onchain: bool,
5742
5742
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>,
5744
5744
) {
5745
5745
match source {
5746
5746
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
@@ -5759,11 +5759,10 @@ where
5759
5759
},
5760
5760
HTLCSource::PreviousHopData(hop_data) => {
5761
5761
let prev_channel_id = hop_data.channel_id;
5762
+ let prev_user_channel_id = hop_data.user_channel_id;
5762
5763
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
5763
5764
#[cfg(debug_assertions)]
5764
5765
let claiming_chan_funding_outpoint = hop_data.outpoint;
5765
- #[cfg(debug_assertions)]
5766
- let claiming_channel_id = hop_data.channel_id;
5767
5766
let res = self.claim_funds_from_hop(hop_data, payment_preimage,
5768
5767
|htlc_claim_value_msat, definitely_duplicate| {
5769
5768
let chan_to_release =
@@ -5821,7 +5820,7 @@ where
5821
5820
BackgroundEvent::MonitorUpdatesComplete {
5822
5821
channel_id, ..
5823
5822
} =>
5824
- *channel_id == claiming_channel_id ,
5823
+ *channel_id == prev_channel_id ,
5825
5824
}
5826
5825
}), "{:?}", *background_events);
5827
5826
}
@@ -5845,12 +5844,14 @@ where
5845
5844
"skimmed_fee_msat must always be included in total_fee_earned_msat");
5846
5845
Some(MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
5847
5846
event: events::Event::PaymentForwarded {
5848
- total_fee_earned_msat,
5849
- claim_from_onchain_tx: from_onchain,
5850
5847
prev_channel_id: Some(prev_channel_id),
5851
5848
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,
5853
5852
skimmed_fee_msat,
5853
+ claim_from_onchain_tx: from_onchain,
5854
+ outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
5854
5855
},
5855
5856
downstream_counterparty_and_funding_outpoint: chan_to_release,
5856
5857
})
@@ -6824,6 +6825,7 @@ where
6824
6825
6825
6826
fn internal_update_fulfill_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) -> Result<(), MsgHandleErrInternal> {
6826
6827
let funding_txo;
6828
+ let next_user_channel_id;
6827
6829
let (htlc_source, forwarded_htlc_value, skimmed_fee_msat) = {
6828
6830
let per_peer_state = self.per_peer_state.read().unwrap();
6829
6831
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
@@ -6853,6 +6855,7 @@ where
6853
6855
// outbound HTLC is claimed. This is guaranteed to all complete before we
6854
6856
// process the RAA as messages are processed from single peers serially.
6855
6857
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();
6856
6859
res
6857
6860
} else {
6858
6861
return try_chan_phase_entry!(self, Err(ChannelError::Close(
@@ -6864,7 +6867,7 @@ where
6864
6867
};
6865
6868
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(),
6866
6869
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),
6868
6871
);
6869
6872
6870
6873
Ok(())
@@ -7366,7 +7369,7 @@ where
7366
7369
log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
7367
7370
self.claim_funds_internal(htlc_update.source, preimage,
7368
7371
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 );
7370
7373
} else {
7371
7374
log_trace!(logger, "Failing HTLC with hash {} from our monitor", &htlc_update.payment_hash);
7372
7375
let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id };
@@ -11386,7 +11389,9 @@ where
11386
11389
// don't remember in the `ChannelMonitor` where we got a preimage from, but if the
11387
11390
// channel is closed we just assume that it probably came from an on-chain claim.
11388
11391
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
+ );
11390
11395
}
11391
11396
11392
11397
//TODO: Broadcast channel update for closed channels, but only after we've made a
0 commit comments