@@ -341,6 +341,9 @@ where U::Target: UtxoLookup, L::Target: Logger
341
341
342
342
impl < L : Deref > NetworkGraph < L > where L :: Target : Logger {
343
343
/// 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.
344
347
///
345
348
/// [`Event`]: crate::events::Event
346
349
pub fn handle_network_update ( & self , network_update : & NetworkUpdate ) {
@@ -349,8 +352,10 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
349
352
let short_channel_id = msg. contents . short_channel_id ;
350
353
let is_enabled = msg. contents . flags & ( 1 << 1 ) != ( 1 << 1 ) ;
351
354
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.
354
359
} ,
355
360
NetworkUpdate :: ChannelFailure { short_channel_id, is_permanent } => {
356
361
if is_permanent {
@@ -2531,7 +2536,8 @@ pub(crate) mod tests {
2531
2536
2532
2537
let short_channel_id;
2533
2538
{
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.
2535
2541
let valid_channel_announcement = get_signed_channel_announcement ( |_| { } , node_1_privkey, node_2_privkey, & secp_ctx) ;
2536
2542
short_channel_id = valid_channel_announcement. contents . short_channel_id ;
2537
2543
let chain_source: Option < & test_utils:: TestChainSource > = None ;
@@ -2542,10 +2548,11 @@ pub(crate) mod tests {
2542
2548
assert ! ( network_graph. read_only( ) . channels( ) . get( & short_channel_id) . unwrap( ) . one_to_two. is_none( ) ) ;
2543
2549
2544
2550
network_graph. handle_network_update ( & NetworkUpdate :: ChannelUpdateMessage {
2545
- msg : valid_channel_update,
2551
+ msg : valid_channel_update. clone ( ) ,
2546
2552
} ) ;
2547
2553
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 ( ) ;
2549
2556
}
2550
2557
2551
2558
// Non-permanent failure doesn't touch the channel at all
0 commit comments