Skip to content

Commit 0ce0d48

Browse files
committed
Add missing counterparty node id metadata to logs in HTLC decoding
1 parent f57295f commit 0ce0d48

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ where
29702970
}
29712971

29722972
fn decode_update_add_htlc_onion(
2973-
&self, msg: &msgs::UpdateAddHTLC
2973+
&self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey,
29742974
) -> Result<
29752975
(onion_utils::Hop, [u8; 32], Option<Result<PublicKey, secp256k1::Error>>), HTLCFailureMsg
29762976
> {
@@ -2989,7 +2989,7 @@ where
29892989
($msg: expr, $err_code: expr, $data: expr) => {
29902990
{
29912991
log_info!(
2992-
WithContext::from(&self.logger, None, Some(msg.channel_id)),
2992+
WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id)),
29932993
"Failed to accept/forward incoming HTLC: {}", $msg
29942994
);
29952995
let (err_code, err_data) = if is_blinded {
@@ -3136,13 +3136,15 @@ where
31363136
}
31373137

31383138
fn construct_pending_htlc_status<'a>(
3139-
&self, msg: &msgs::UpdateAddHTLC, shared_secret: [u8; 32], decoded_hop: onion_utils::Hop,
3140-
allow_underpay: bool, next_packet_pubkey_opt: Option<Result<PublicKey, secp256k1::Error>>
3139+
&self, msg: &msgs::UpdateAddHTLC, counterparty_node_id: &PublicKey, shared_secret: [u8; 32],
3140+
decoded_hop: onion_utils::Hop, allow_underpay: bool,
3141+
next_packet_pubkey_opt: Option<Result<PublicKey, secp256k1::Error>>,
31413142
) -> PendingHTLCStatus {
31423143
macro_rules! return_err {
31433144
($msg: expr, $err_code: expr, $data: expr) => {
31443145
{
3145-
log_info!(WithContext::from(&self.logger, None, Some(msg.channel_id)), "Failed to accept/forward incoming HTLC: {}", $msg);
3146+
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id));
3147+
log_info!(logger, "Failed to accept/forward incoming HTLC: {}", $msg);
31463148
return PendingHTLCStatus::Fail(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {
31473149
channel_id: msg.channel_id,
31483150
htlc_id: msg.htlc_id,
@@ -6458,7 +6460,7 @@ where
64586460
// Note that the ChannelManager is NOT re-persisted on disk after this (unless we error
64596461
// closing a channel), so any changes are likely to be lost on restart!
64606462

6461-
let decoded_hop_res = self.decode_update_add_htlc_onion(msg);
6463+
let decoded_hop_res = self.decode_update_add_htlc_onion(msg, counterparty_node_id);
64626464
let per_peer_state = self.per_peer_state.read().unwrap();
64636465
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
64646466
.ok_or_else(|| {
@@ -6472,8 +6474,10 @@ where
64726474
if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
64736475
let pending_forward_info = match decoded_hop_res {
64746476
Ok((next_hop, shared_secret, next_packet_pk_opt)) =>
6475-
self.construct_pending_htlc_status(msg, shared_secret, next_hop,
6476-
chan.context.config().accept_underpaying_htlcs, next_packet_pk_opt),
6477+
self.construct_pending_htlc_status(
6478+
msg, counterparty_node_id, shared_secret, next_hop,
6479+
chan.context.config().accept_underpaying_htlcs, next_packet_pk_opt,
6480+
),
64776481
Err(e) => PendingHTLCStatus::Fail(e)
64786482
};
64796483
let create_pending_htlc_status = |chan: &Channel<SP>, pending_forward_info: PendingHTLCStatus, error_code: u16| {

0 commit comments

Comments
 (0)