Skip to content

Commit 2fc79cb

Browse files
committed
Include next-hop counterparty node id in log metadata when sending
1 parent 0ce0d48 commit 2fc79cb

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,23 +3281,33 @@ where
32813281
} = args;
32823282
// The top-level caller should hold the total_consistency_lock read lock.
32833283
debug_assert!(self.total_consistency_lock.try_write().is_err());
3284-
log_trace!(WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None),
3285-
"Attempting to send payment with payment hash {} along path with next hop {}",
3286-
payment_hash, path.hops.first().unwrap().short_channel_id);
32873284
let prng_seed = self.entropy_source.get_secure_random_bytes();
32883285
let session_priv = SecretKey::from_slice(&session_priv_bytes[..]).expect("RNG is busted");
32893286

32903287
let (onion_packet, htlc_msat, htlc_cltv) = onion_utils::create_payment_onion(
32913288
&self.secp_ctx, &path, &session_priv, total_value, recipient_onion, cur_height,
32923289
payment_hash, keysend_preimage, prng_seed
3293-
)?;
3290+
).map_err(|e| {
3291+
let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None);
3292+
log_error!(logger, "Failed to build an onion for path for payment hash {}", payment_hash);
3293+
e
3294+
})?;
32943295

32953296
let err: Result<(), _> = loop {
32963297
let (counterparty_node_id, id) = match self.short_to_chan_info.read().unwrap().get(&path.hops.first().unwrap().short_channel_id) {
3297-
None => return Err(APIError::ChannelUnavailable{err: "No channel available with first hop!".to_owned()}),
3298+
None => {
3299+
let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None);
3300+
log_error!(logger, "Failed to find first-hop for payment hash {}", payment_hash);
3301+
return Err(APIError::ChannelUnavailable{err: "No channel available with first hop!".to_owned()})
3302+
},
32983303
Some((cp_id, chan_id)) => (cp_id.clone(), chan_id.clone()),
32993304
};
33003305

3306+
let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(id));
3307+
log_trace!(logger,
3308+
"Attempting to send payment with payment hash {} along path with next hop {}",
3309+
payment_hash, path.hops.first().unwrap().short_channel_id);
3310+
33013311
let per_peer_state = self.per_peer_state.read().unwrap();
33023312
let peer_state_mutex = per_peer_state.get(&counterparty_node_id)
33033313
.ok_or_else(|| APIError::ChannelUnavailable{err: "No peer matching the path's first hop found!".to_owned() })?;

0 commit comments

Comments
 (0)