@@ -5083,7 +5083,7 @@ where
5083
5083
self.pending_outbound_payments.finalize_claims(sources, &self.pending_events);
5084
5084
}
5085
5085
5086
- fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32] ) {
5086
+ fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_outpoint: OutPoint ) {
5087
5087
match source {
5088
5088
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
5089
5089
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
@@ -5104,7 +5104,7 @@ where
5104
5104
fee_earned_msat,
5105
5105
claim_from_onchain_tx: from_onchain,
5106
5106
prev_channel_id: Some(prev_outpoint.to_channel_id()),
5107
- next_channel_id: Some(next_channel_id ),
5107
+ next_channel_id: Some(next_channel_outpoint.to_channel_id() ),
5108
5108
outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
5109
5109
},
5110
5110
downstream_counterparty_and_funding_outpoint: None,
@@ -5879,6 +5879,7 @@ where
5879
5879
}
5880
5880
5881
5881
fn internal_update_fulfill_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) -> Result<(), MsgHandleErrInternal> {
5882
+ let funding_txo;
5882
5883
let (htlc_source, forwarded_htlc_value) = {
5883
5884
let per_peer_state = self.per_peer_state.read().unwrap();
5884
5885
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
@@ -5890,12 +5891,14 @@ where
5890
5891
let peer_state = &mut *peer_state_lock;
5891
5892
match peer_state.channel_by_id.entry(msg.channel_id) {
5892
5893
hash_map::Entry::Occupied(mut chan) => {
5893
- try_chan_entry!(self, chan.get_mut().update_fulfill_htlc(&msg), chan)
5894
+ let res = try_chan_entry!(self, chan.get_mut().update_fulfill_htlc(&msg), chan);
5895
+ funding_txo = chan.get().context.get_funding_txo().expect("We won't accept a fulfill until funded");
5896
+ res
5894
5897
},
5895
5898
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
5896
5899
}
5897
5900
};
5898
- self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, msg.channel_id );
5901
+ self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, funding_txo );
5899
5902
Ok(())
5900
5903
}
5901
5904
@@ -6270,7 +6273,7 @@ where
6270
6273
MonitorEvent::HTLCEvent(htlc_update) => {
6271
6274
if let Some(preimage) = htlc_update.payment_preimage {
6272
6275
log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", log_bytes!(preimage.0));
6273
- self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id() );
6276
+ self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint);
6274
6277
} else {
6275
6278
log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", log_bytes!(htlc_update.payment_hash.0));
6276
6279
let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id: funding_outpoint.to_channel_id() };
@@ -8994,7 +8997,7 @@ where
8994
8997
// downstream chan is closed (because we don't have a
8995
8998
// channel_id -> peer map entry).
8996
8999
counterparty_opt.is_none(),
8997
- monitor.get_funding_txo().0.to_channel_id() ))
9000
+ monitor.get_funding_txo().0))
8998
9001
} else { None }
8999
9002
} else {
9000
9003
// If it was an outbound payment, we've handled it above - if a preimage
@@ -9263,12 +9266,12 @@ where
9263
9266
channel_manager.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
9264
9267
}
9265
9268
9266
- for (source, preimage, downstream_value, downstream_closed, downstream_chan_id ) in pending_claims_to_replay {
9269
+ for (source, preimage, downstream_value, downstream_closed, downstream_funding ) in pending_claims_to_replay {
9267
9270
// We use `downstream_closed` in place of `from_onchain` here just as a guess - we
9268
9271
// don't remember in the `ChannelMonitor` where we got a preimage from, but if the
9269
9272
// channel is closed we just assume that it probably came from an on-chain claim.
9270
9273
channel_manager.claim_funds_internal(source, preimage, Some(downstream_value),
9271
- downstream_closed, downstream_chan_id );
9274
+ downstream_closed, downstream_funding );
9272
9275
}
9273
9276
9274
9277
//TODO: Broadcast channel update for closed channels, but only after we've made a
0 commit comments