@@ -4936,7 +4936,7 @@ where
4936
4936
self.pending_outbound_payments.finalize_claims(sources, &self.pending_events);
4937
4937
}
4938
4938
4939
- fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32] ) {
4939
+ fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_outpoint: OutPoint ) {
4940
4940
match source {
4941
4941
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
4942
4942
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
@@ -4957,7 +4957,7 @@ where
4957
4957
fee_earned_msat,
4958
4958
claim_from_onchain_tx: from_onchain,
4959
4959
prev_channel_id: Some(prev_outpoint.to_channel_id()),
4960
- next_channel_id: Some(next_channel_id ),
4960
+ next_channel_id: Some(next_channel_outpoint.to_channel_id() ),
4961
4961
outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
4962
4962
},
4963
4963
downstream_counterparty_and_funding_outpoint: None,
@@ -5712,6 +5712,7 @@ where
5712
5712
}
5713
5713
5714
5714
fn internal_update_fulfill_htlc(&self, counterparty_node_id: &PublicKey, msg: &msgs::UpdateFulfillHTLC) -> Result<(), MsgHandleErrInternal> {
5715
+ let funding_txo;
5715
5716
let (htlc_source, forwarded_htlc_value) = {
5716
5717
let per_peer_state = self.per_peer_state.read().unwrap();
5717
5718
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
@@ -5723,12 +5724,14 @@ where
5723
5724
let peer_state = &mut *peer_state_lock;
5724
5725
match peer_state.channel_by_id.entry(msg.channel_id) {
5725
5726
hash_map::Entry::Occupied(mut chan) => {
5726
- try_chan_entry!(self, chan.get_mut().update_fulfill_htlc(&msg), chan)
5727
+ let res = try_chan_entry!(self, chan.get_mut().update_fulfill_htlc(&msg), chan);
5728
+ funding_txo = chan.get().context.get_funding_txo().expect("We won't accept a fulfill until funded");
5729
+ res
5727
5730
},
5728
5731
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))
5729
5732
}
5730
5733
};
5731
- self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, msg.channel_id );
5734
+ self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, funding_txo );
5732
5735
Ok(())
5733
5736
}
5734
5737
@@ -6103,7 +6106,7 @@ where
6103
6106
MonitorEvent::HTLCEvent(htlc_update) => {
6104
6107
if let Some(preimage) = htlc_update.payment_preimage {
6105
6108
log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", log_bytes!(preimage.0));
6106
- self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id() );
6109
+ self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint);
6107
6110
} else {
6108
6111
log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", log_bytes!(htlc_update.payment_hash.0));
6109
6112
let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id: funding_outpoint.to_channel_id() };
@@ -8815,7 +8818,7 @@ where
8815
8818
// downstream chan is closed (because we don't have a
8816
8819
// channel_id -> peer map entry).
8817
8820
counterparty_opt.is_none(),
8818
- monitor.get_funding_txo().0.to_channel_id() ))
8821
+ monitor.get_funding_txo().0))
8819
8822
} else { None }
8820
8823
} else {
8821
8824
// If it was an outbound payment, we've handled it above - if a preimage
@@ -9084,12 +9087,12 @@ where
9084
9087
channel_manager.fail_htlc_backwards_internal(&source, &payment_hash, &reason, receiver);
9085
9088
}
9086
9089
9087
- for (source, preimage, downstream_value, downstream_closed, downstream_chan_id ) in pending_claims_to_replay {
9090
+ for (source, preimage, downstream_value, downstream_closed, downstream_funding ) in pending_claims_to_replay {
9088
9091
// We use `downstream_closed` in place of `from_onchain` here just as a guess - we
9089
9092
// don't remember in the `ChannelMonitor` where we got a preimage from, but if the
9090
9093
// channel is closed we just assume that it probably came from an on-chain claim.
9091
9094
channel_manager.claim_funds_internal(source, preimage, Some(downstream_value),
9092
- downstream_closed, downstream_chan_id );
9095
+ downstream_closed, downstream_funding );
9093
9096
}
9094
9097
9095
9098
//TODO: Broadcast channel update for closed channels, but only after we've made a
0 commit comments