Skip to content

Commit 1c35255

Browse files
committed
Don't apply PathFailure::ChannelUpdateMessage
If we receive a channel update from an intermediary via a failure onion we shouldn't apply them in a persisted and network-observable way to our network graph, as this might introduce a privacy leak. Here, we therefore avoid applying such updates to our network graph.
1 parent 1dffb20 commit 1c35255

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lightning/src/routing/gossip.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ where U::Target: UtxoLookup, L::Target: Logger
341341

342342
impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
343343
/// Handles any network updates originating from [`Event`]s.
344+
//
345+
/// Note that this will skip applying any [`NetworkUpdate::ChannelUpdateMessage`] to avoid
346+
/// leaking possibly identifying information of the sender to the public network.
344347
///
345348
/// [`Event`]: crate::events::Event
346349
pub fn handle_network_update(&self, network_update: &NetworkUpdate) {
@@ -349,8 +352,7 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
349352
let short_channel_id = msg.contents.short_channel_id;
350353
let is_enabled = msg.contents.flags & (1 << 1) != (1 << 1);
351354
let status = if is_enabled { "enabled" } else { "disabled" };
352-
log_debug!(self.logger, "Updating channel with channel_update from a payment failure. Channel {} is {}.", short_channel_id, status);
353-
let _ = self.update_channel(msg);
355+
log_debug!(self.logger, "Skipping application of a channel update from a payment failure. Channel {} is {}.", short_channel_id, status);
354356
},
355357
NetworkUpdate::ChannelFailure { short_channel_id, is_permanent } => {
356358
if is_permanent {
@@ -2531,7 +2533,8 @@ pub(crate) mod tests {
25312533

25322534
let short_channel_id;
25332535
{
2534-
// Announce a channel we will update
2536+
// Check we won't apply an update via `handle_network_update` for privacy reasons, but
2537+
// can continue fine if we manually apply it.
25352538
let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
25362539
short_channel_id = valid_channel_announcement.contents.short_channel_id;
25372540
let chain_source: Option<&test_utils::TestChainSource> = None;
@@ -2542,10 +2545,11 @@ pub(crate) mod tests {
25422545
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
25432546

25442547
network_graph.handle_network_update(&NetworkUpdate::ChannelUpdateMessage {
2545-
msg: valid_channel_update,
2548+
msg: valid_channel_update.clone(),
25462549
});
25472550

2548-
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
2551+
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
2552+
network_graph.update_channel(&valid_channel_update).unwrap();
25492553
}
25502554

25512555
// Non-permanent failure doesn't touch the channel at all

0 commit comments

Comments
 (0)