@@ -341,6 +341,9 @@ where U::Target: UtxoLookup, L::Target: Logger
341341
342342impl < 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,10 @@ 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) ;
356+ // While the `ChannelUpdateMessage` variant is available in tests we don't apply
357+ // them to the network graph to avoid having our test behavior diverge too much
358+ // from the production case.
354359 } ,
355360 NetworkUpdate :: ChannelFailure { short_channel_id, is_permanent } => {
356361 if is_permanent {
@@ -2531,7 +2536,8 @@ pub(crate) mod tests {
25312536
25322537 let short_channel_id;
25332538 {
2534- // Announce a channel we will update
2539+ // Check we won't apply an update via `handle_network_update` for privacy reasons, but
2540+ // can continue fine if we manually apply it.
25352541 let valid_channel_announcement = get_signed_channel_announcement ( |_| { } , node_1_privkey, node_2_privkey, & secp_ctx) ;
25362542 short_channel_id = valid_channel_announcement. contents . short_channel_id ;
25372543 let chain_source: Option < & test_utils:: TestChainSource > = None ;
@@ -2542,10 +2548,11 @@ pub(crate) mod tests {
25422548 assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
25432549
25442550 network_graph. handle_network_update ( & NetworkUpdate :: ChannelUpdateMessage {
2545- msg : valid_channel_update,
2551+ msg : valid_channel_update. clone ( ) ,
25462552 } ) ;
25472553
2548- assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_some( ) ) ;
2554+ assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
2555+ network_graph. update_channel ( & valid_channel_update) . unwrap ( ) ;
25492556 }
25502557
25512558 // Non-permanent failure doesn't touch the channel at all
0 commit comments