]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add node id to remaining `RoutingMessageHandler::handle_` methods
authorElias Rohrer <dev@tnull.de>
Wed, 4 Sep 2024 13:39:20 +0000 (15:39 +0200)
committerElias Rohrer <dev@tnull.de>
Wed, 11 Sep 2024 16:01:33 +0000 (18:01 +0200)
Previously, some `RoutingMessageHandler::handle_` methods (in particular
the ones handling node and channel announcements, as well as channel
updates, omitted the `their_node_id` argument. This didn't allow
implementors to discern *who* sent a particular method.

Here, we add `their_node_id: Option<&PublicKey>` to have them learn who
sent a message, and set `None` if our own node it the originator of a
broadcast operation.

12 files changed:
lightning-net-tokio/src/lib.rs
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/msgs.rs
lightning/src/ln/offers_tests.rs
lightning/src/ln/peer_handler.rs
lightning/src/ln/priv_short_conf_tests.rs
lightning/src/ln/reload_tests.rs
lightning/src/routing/gossip.rs
lightning/src/routing/test_utils.rs
lightning/src/util/test_utils.rs

index a5f4de470dfbc1afac159cbf5a1b00ce098baba6..3ca6552dd7273ff945f5149b1a9e949140f9836d 100644 (file)
@@ -660,16 +660,18 @@ mod tests {
        }
        impl RoutingMessageHandler for MsgHandler {
                fn handle_node_announcement(
-                       &self, _msg: &NodeAnnouncement,
+                       &self, _their_node_id: Option<&PublicKey>, _msg: &NodeAnnouncement,
                ) -> Result<bool, LightningError> {
                        Ok(false)
                }
                fn handle_channel_announcement(
-                       &self, _msg: &ChannelAnnouncement,
+                       &self, _their_node_id: Option<&PublicKey>, _msg: &ChannelAnnouncement,
                ) -> Result<bool, LightningError> {
                        Ok(false)
                }
-               fn handle_channel_update(&self, _msg: &ChannelUpdate) -> Result<bool, LightningError> {
+               fn handle_channel_update(
+                       &self, _their_node_id: Option<&PublicKey>, _msg: &ChannelUpdate,
+               ) -> Result<bool, LightningError> {
                        Ok(false)
                }
                fn get_next_channel_announcement(
index c4bfac1dd97e49d04ae11287e768d4a6b37bf790..160a6e7a89930449c653589858e7462f7a8db205 100644 (file)
@@ -1945,10 +1945,11 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
                let (channel_ready, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]);
                (channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &channel_ready))
        };
-       for node in nodes.iter() {
-               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
-               node.gossip_sync.handle_channel_update(&as_update).unwrap();
-               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
+       for (i, node) in nodes.iter().enumerate() {
+               let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
+               assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
        }
 
        if !restore_b_before_lock {
index 6b0a8a23182609fe5f70206a81554186d8db25b0..96fbdedb4eb11667a5553490799802a579e37a83 100644 (file)
@@ -1501,14 +1501,16 @@ pub fn create_unannounced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &
 
 pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, ann: &msgs::ChannelAnnouncement, upd_1: &msgs::ChannelUpdate, upd_2: &msgs::ChannelUpdate) {
        for node in nodes {
-               assert!(node.gossip_sync.handle_channel_announcement(ann).unwrap());
-               node.gossip_sync.handle_channel_update(upd_1).unwrap();
-               node.gossip_sync.handle_channel_update(upd_2).unwrap();
+               let node_id_a = nodes[a].node.get_our_node_id();
+               let node_id_b = nodes[b].node.get_our_node_id();
+               assert!(node.gossip_sync.handle_channel_announcement(None, ann).unwrap());
+               node.gossip_sync.handle_channel_update(Some(&node_id_a), upd_1).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&node_id_b), upd_2).unwrap();
 
                // Note that channel_updates are also delivered to ChannelManagers to ensure we have
                // forwarding info for local channels even if its not accepted in the network graph.
-               node.node.handle_channel_update(&nodes[a].node.get_our_node_id(), &upd_1);
-               node.node.handle_channel_update(&nodes[b].node.get_our_node_id(), &upd_2);
+               node.node.handle_channel_update(&node_id_a, &upd_1);
+               node.node.handle_channel_update(&node_id_b, &upd_2);
        }
 }
 
@@ -3512,9 +3514,10 @@ pub fn handle_announce_close_broadcast_events<'a, 'b, 'c>(nodes: &Vec<Node<'a, '
        if dummy_connected {
                disconnect_dummy_node(&nodes[b]);
        }
+       let node_id_a = nodes[a].node.get_our_node_id();
        for node in nodes {
-               node.gossip_sync.handle_channel_update(&as_update).unwrap();
-               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&node_id_a), &as_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&node_id_a), &bs_update).unwrap();
        }
 }
 
index 22b7df1ed388d9aa19f61a47923247dcf850e0ed..54461b8975b273ca88a88bc7db04ad3ee7b8242f 100644 (file)
@@ -2461,14 +2461,16 @@ fn channel_monitor_network_test() {
                check_preimage_claim(&nodes[4], &node_txn);
                (close_chan_update_1, close_chan_update_2)
        };
-       nodes[3].gossip_sync.handle_channel_update(&close_chan_update_2).unwrap();
-       nodes[4].gossip_sync.handle_channel_update(&close_chan_update_1).unwrap();
+       let node_id_4 = nodes[4].node.get_our_node_id();
+       let node_id_3 = nodes[3].node.get_our_node_id();
+       nodes[3].gossip_sync.handle_channel_update(Some(&node_id_4), &close_chan_update_2).unwrap();
+       nodes[4].gossip_sync.handle_channel_update(Some(&node_id_3), &close_chan_update_1).unwrap();
        assert_eq!(nodes[3].node.list_channels().len(), 0);
        assert_eq!(nodes[4].node.list_channels().len(), 0);
 
        assert_eq!(nodes[3].chain_monitor.chain_monitor.watch_channel(OutPoint { txid: chan_3.3.compute_txid(), index: 0 }, chan_3_mon),
                Ok(ChannelMonitorUpdateStatus::Completed));
-       check_closed_event!(nodes[3], 1, ClosureReason::HTLCsTimedOut, [nodes[4].node.get_our_node_id()], 100000);
+       check_closed_event!(nodes[3], 1, ClosureReason::HTLCsTimedOut, [node_id_4], 100000);
 }
 
 #[test]
index c176a8669d3cfe2ccba41b7d8bfe4c73af89d3fe..657a7f13a9f8b8a4ea7aab47e809d080d3d9166b 100644 (file)
@@ -1617,13 +1617,19 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
 pub trait RoutingMessageHandler : MessageSendEventsProvider {
        /// Handle an incoming `node_announcement` message, returning `true` if it should be forwarded on,
        /// `false` or returning an `Err` otherwise.
-       fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
+       ///
+       /// If `their_node_id` is `None`, the message was generated by our own local node.
+       fn handle_node_announcement(&self, their_node_id: Option<&PublicKey>, msg: &NodeAnnouncement) -> Result<bool, LightningError>;
        /// Handle a `channel_announcement` message, returning `true` if it should be forwarded on, `false`
        /// or returning an `Err` otherwise.
-       fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result<bool, LightningError>;
+       ///
+       /// If `their_node_id` is `None`, the message was generated by our own local node.
+       fn handle_channel_announcement(&self, their_node_id: Option<&PublicKey>, msg: &ChannelAnnouncement) -> Result<bool, LightningError>;
        /// Handle an incoming `channel_update` message, returning true if it should be forwarded on,
        /// `false` or returning an `Err` otherwise.
-       fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<bool, LightningError>;
+       ///
+       /// If `their_node_id` is `None`, the message was generated by our own local node.
+       fn handle_channel_update(&self, their_node_id: Option<&PublicKey>, msg: &ChannelUpdate) -> Result<bool, LightningError>;
        /// Gets channel announcements and updates required to dump our routing table to a remote node,
        /// starting at the `short_channel_id` indicated by `starting_point` and including announcements
        /// for a single channel.
index 8bbf9a0ad7df3e14caa557a5e58451bed5cd2d73..c45660b10a12ee4549446dda5f89f973d02d56f6 100644 (file)
@@ -134,9 +134,10 @@ fn announce_node_address<'a, 'b, 'c>(
                contents: announcement
        };
 
-       node.gossip_sync.handle_node_announcement(&msg).unwrap();
+       let node_pubkey = node.node.get_our_node_id();
+       node.gossip_sync.handle_node_announcement(None, &msg).unwrap();
        for peer in peers {
-               peer.gossip_sync.handle_node_announcement(&msg).unwrap();
+               peer.gossip_sync.handle_node_announcement(Some(&node_pubkey), &msg).unwrap();
        }
 }
 
index 80c9c78101e7eb33bdbf3abded9524f8d34d1b88..585d0a2619f477abcef3d688e9bdcf04a0539014 100644 (file)
@@ -111,9 +111,9 @@ impl MessageSendEventsProvider for IgnoringMessageHandler {
        fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> { Vec::new() }
 }
 impl RoutingMessageHandler for IgnoringMessageHandler {
-       fn handle_node_announcement(&self, _msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
-       fn handle_channel_announcement(&self, _msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
-       fn handle_channel_update(&self, _msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
+       fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> { Ok(false) }
+       fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> { Ok(false) }
+       fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> { Ok(false) }
        fn get_next_channel_announcement(&self, _starting_point: u64) ->
                Option<(msgs::ChannelAnnouncement, Option<msgs::ChannelUpdate>, Option<msgs::ChannelUpdate>)> { None }
        fn get_next_node_announcement(&self, _starting_point: Option<&NodeId>) -> Option<msgs::NodeAnnouncement> { None }
@@ -1887,22 +1887,22 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                                self.message_handler.chan_handler.handle_announcement_signatures(&their_node_id, &msg);
                        },
                        wire::Message::ChannelAnnouncement(msg) => {
-                               if self.message_handler.route_handler.handle_channel_announcement(&msg)
+                               if self.message_handler.route_handler.handle_channel_announcement(Some(their_node_id), &msg)
                                                .map_err(|e| -> MessageHandlingError { e.into() })? {
                                        should_forward = Some(wire::Message::ChannelAnnouncement(msg));
                                }
                                self.update_gossip_backlogged();
                        },
                        wire::Message::NodeAnnouncement(msg) => {
-                               if self.message_handler.route_handler.handle_node_announcement(&msg)
+                               if self.message_handler.route_handler.handle_node_announcement(Some(their_node_id), &msg)
                                                .map_err(|e| -> MessageHandlingError { e.into() })? {
                                        should_forward = Some(wire::Message::NodeAnnouncement(msg));
                                }
                                self.update_gossip_backlogged();
                        },
                        wire::Message::ChannelUpdate(msg) => {
-                               self.message_handler.chan_handler.handle_channel_update(&their_node_id, &msg);
-                               if self.message_handler.route_handler.handle_channel_update(&msg)
+                               self.message_handler.chan_handler.handle_channel_update(their_node_id, &msg);
+                               if self.message_handler.route_handler.handle_channel_update(Some(their_node_id), &msg)
                                                .map_err(|e| -> MessageHandlingError { e.into() })? {
                                        should_forward = Some(wire::Message::ChannelUpdate(msg));
                                }
@@ -2285,13 +2285,13 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                                                },
                                                MessageSendEvent::BroadcastChannelAnnouncement { msg, update_msg } => {
                                                        log_debug!(self.logger, "Handling BroadcastChannelAnnouncement event in peer_handler for short channel id {}", msg.contents.short_channel_id);
-                                                       match self.message_handler.route_handler.handle_channel_announcement(&msg) {
+                                                       match self.message_handler.route_handler.handle_channel_announcement(None, &msg) {
                                                                Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
                                                                        self.forward_broadcast_msg(peers, &wire::Message::ChannelAnnouncement(msg), None),
                                                                _ => {},
                                                        }
                                                        if let Some(msg) = update_msg {
-                                                               match self.message_handler.route_handler.handle_channel_update(&msg) {
+                                                               match self.message_handler.route_handler.handle_channel_update(None, &msg) {
                                                                        Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
                                                                                self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(msg), None),
                                                                        _ => {},
@@ -2300,7 +2300,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                                                },
                                                MessageSendEvent::BroadcastChannelUpdate { msg } => {
                                                        log_debug!(self.logger, "Handling BroadcastChannelUpdate event in peer_handler for contents {:?}", msg.contents);
-                                                       match self.message_handler.route_handler.handle_channel_update(&msg) {
+                                                       match self.message_handler.route_handler.handle_channel_update(None, &msg) {
                                                                Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
                                                                        self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(msg), None),
                                                                _ => {},
@@ -2308,7 +2308,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                                                },
                                                MessageSendEvent::BroadcastNodeAnnouncement { msg } => {
                                                        log_debug!(self.logger, "Handling BroadcastNodeAnnouncement event in peer_handler for node {}", msg.contents.node_id);
-                                                       match self.message_handler.route_handler.handle_node_announcement(&msg) {
+                                                       match self.message_handler.route_handler.handle_node_announcement(None, &msg) {
                                                                Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
                                                                        self.forward_broadcast_msg(peers, &wire::Message::NodeAnnouncement(msg), None),
                                                                _ => {},
@@ -2674,7 +2674,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                };
 
                log_debug!(self.logger, "Broadcasting NodeAnnouncement after passing it to our own RoutingMessageHandler.");
-               let _ = self.message_handler.route_handler.handle_node_announcement(&msg);
+               let _ = self.message_handler.route_handler.handle_node_announcement(None, &msg);
                self.forward_broadcast_msg(&*self.peers.read().unwrap(), &wire::Message::NodeAnnouncement(msg), None);
        }
 }
index 83ff296e17727e7c7a6cfbb3031a040627a20867..1614b49019f0ed4a11a451a5df3e4b2475482c8c 100644 (file)
@@ -207,10 +207,11 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
        } else { panic!("Unexpected event"); };
        assert_eq!(announcement, bs_announcement);
 
-       for node in nodes {
-               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
-               node.gossip_sync.handle_channel_update(&as_update).unwrap();
-               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
+       for (i, node) in nodes.iter().enumerate() {
+               let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
+               assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
        }
 }
 #[test]
index a17f8495a9a87eddb4ead69a396a99abc17d658a..79caef0c77ff86ddd7a70621f9972f84486e5bc9 100644 (file)
@@ -165,9 +165,10 @@ fn test_funding_peer_disconnect() {
        };
 
        // Provide the channel announcement and public updates to the network graph
-       nodes[0].gossip_sync.handle_channel_announcement(&chan_announcement).unwrap();
-       nodes[0].gossip_sync.handle_channel_update(&bs_update).unwrap();
-       nodes[0].gossip_sync.handle_channel_update(&as_update).unwrap();
+       let node_1_pubkey = nodes[1].node.get_our_node_id();
+       nodes[0].gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &chan_announcement).unwrap();
+       nodes[0].gossip_sync.handle_channel_update(Some(&node_1_pubkey), &bs_update).unwrap();
+       nodes[0].gossip_sync.handle_channel_update(Some(&node_1_pubkey), &as_update).unwrap();
 
        let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
        let payment_preimage = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000).0;
@@ -219,10 +220,11 @@ fn test_no_txn_manager_serialize_deserialize() {
 
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
-       for node in nodes.iter() {
-               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
-               node.gossip_sync.handle_channel_update(&as_update).unwrap();
-               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
+       for (i, node) in nodes.iter().enumerate() {
+               let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
+               assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
@@ -309,10 +311,11 @@ fn test_manager_serialize_deserialize_events() {
 
        let (channel_ready, _) = create_chan_between_nodes_with_value_confirm(&nodes[0], &nodes[1], &tx);
        let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &channel_ready);
-       for node in nodes.iter() {
-               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
-               node.gossip_sync.handle_channel_update(&as_update).unwrap();
-               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
+       for (i, node) in nodes.iter().enumerate() {
+               let counterparty_node_id = nodes[(i + 1) % 2].node.get_our_node_id();
+               assert!(node.gossip_sync.handle_channel_announcement(Some(&counterparty_node_id), &announcement).unwrap());
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &as_update).unwrap();
+               node.gossip_sync.handle_channel_update(Some(&counterparty_node_id), &bs_update).unwrap();
        }
 
        send_payment(&nodes[0], &[&nodes[1]], 1000000);
index a1060a7acde94a223003fd55cabe817cc4a6ea19..2c0ed9332278498b92bb63fe09186162897920cf 100644 (file)
@@ -484,19 +484,19 @@ pub fn verify_channel_announcement<C: Verification>(msg: &ChannelAnnouncement, s
 impl<G: Deref<Target=NetworkGraph<L>>, U: Deref, L: Deref> RoutingMessageHandler for P2PGossipSync<G, U, L>
 where U::Target: UtxoLookup, L::Target: Logger
 {
-       fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
+       fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::NodeAnnouncement) -> Result<bool, LightningError> {
                self.network_graph.update_node_from_announcement(msg)?;
                Ok(msg.contents.excess_data.len() <=  MAX_EXCESS_BYTES_FOR_RELAY &&
                   msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY &&
                   msg.contents.excess_data.len() + msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
        }
 
-       fn handle_channel_announcement(&self, msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> {
+       fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::ChannelAnnouncement) -> Result<bool, LightningError> {
                self.network_graph.update_channel_from_announcement(msg, &*self.utxo_lookup.read().unwrap())?;
                Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
        }
 
-       fn handle_channel_update(&self, msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> {
+       fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, msg: &msgs::ChannelUpdate) -> Result<bool, LightningError> {
                self.network_graph.update_channel(msg)?;
                Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY)
        }
@@ -2568,11 +2568,12 @@ pub(crate) mod tests {
                let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let zero_hash = Sha256dHash::hash(&[0; 32]);
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!("No existing channels for node_announcement", e.err)
                };
@@ -2580,7 +2581,7 @@ pub(crate) mod tests {
                {
                        // Announce a channel to add a corresponding node.
                        let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(res) => assert!(res),
                                _ => panic!()
                        };
@@ -2588,6 +2589,7 @@ pub(crate) mod tests {
 
                let fake_msghash = hash_to_message!(zero_hash.as_byte_array());
                match gossip_sync.handle_node_announcement(
+                       Some(&node_1_pubkey),
                        &NodeAnnouncement {
                                signature: secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey),
                                contents: valid_announcement.contents.clone()
@@ -2596,7 +2598,7 @@ pub(crate) mod tests {
                        Err(e) => assert_eq!(e.err, "Invalid signature on node_announcement message")
                };
 
-               match gossip_sync.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(res) => assert!(res),
                        Err(_) => panic!()
                };
@@ -2606,7 +2608,7 @@ pub(crate) mod tests {
                        unsigned_announcement.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data.
-               match gossip_sync.handle_node_announcement(&announcement_with_data) {
+               match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement_with_data) {
                        Ok(res) => assert!(!res),
                        Err(_) => panic!()
                };
@@ -2616,7 +2618,7 @@ pub(crate) mod tests {
                let outdated_announcement = get_signed_node_announcement(|unsigned_announcement| {
                        unsigned_announcement.timestamp += 1000 - 10;
                }, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_node_announcement(&outdated_announcement) {
+               match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &outdated_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update older than last processed update")
                };
@@ -2628,6 +2630,7 @@ pub(crate) mod tests {
                let logger = test_utils::TestLogger::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                let good_script = get_channel_script(&secp_ctx);
@@ -2636,7 +2639,7 @@ pub(crate) mod tests {
                // Test if the UTXO lookups were not supported
                let network_graph = NetworkGraph::new(Network::Testnet, &logger);
                let mut gossip_sync = P2PGossipSync::new(&network_graph, None, &logger);
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -2650,7 +2653,7 @@ pub(crate) mod tests {
 
                // If we receive announcement for the same channel (with UTXO lookups disabled),
                // drop new one on the floor, since we can't see any changes.
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Already have non-chain-validated channel")
                };
@@ -2664,7 +2667,7 @@ pub(crate) mod tests {
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 1;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announced without corresponding UTXO entry")
                };
@@ -2675,7 +2678,7 @@ pub(crate) mod tests {
                let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.short_channel_id += 2;
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
@@ -2691,7 +2694,7 @@ pub(crate) mod tests {
                // chain, we simply ignore all new (duplicate) announcements.
                *chain_source.utxo_ret.lock().unwrap() =
                        UtxoResult::Sync(Ok(TxOut { value: Amount::ZERO, script_pubkey: good_script }));
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Already have chain-validated channel")
                };
@@ -2708,7 +2711,7 @@ pub(crate) mod tests {
                        let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                                unsigned_announcement.short_channel_id += 3;
                        }, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(_) => panic!(),
                                Err(e) => assert_eq!(e.err, "Channel with SCID 3 or one of its nodes was removed from our network graph recently")
                        }
@@ -2716,7 +2719,7 @@ pub(crate) mod tests {
                        gossip_sync.network_graph().remove_stale_channels_and_tracking_with_time(tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS);
 
                        // The above channel announcement should be handled as per normal now.
-                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(res) => assert!(res),
                                _ => panic!()
                        }
@@ -2729,19 +2732,19 @@ pub(crate) mod tests {
 
                let mut invalid_sig_announcement = valid_excess_data_announcement.clone();
                invalid_sig_announcement.contents.excess_data = Vec::new();
-               match gossip_sync.handle_channel_announcement(&invalid_sig_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &invalid_sig_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_announcement message")
                };
 
                // Don't relay valid channels with excess data
-               match gossip_sync.handle_channel_announcement(&valid_excess_data_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_excess_data_announcement) {
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
 
                let channel_to_itself_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_announcement(&channel_to_itself_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &channel_to_itself_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announcement node had a channel with itself")
                };
@@ -2751,7 +2754,7 @@ pub(crate) mod tests {
                let incorrect_chain_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                        unsigned_announcement.chain_hash = ChainHash::using_genesis_block(Network::Bitcoin);
                }, node_1_privkey, node_2_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_announcement(&incorrect_chain_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &incorrect_chain_announcement) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel announcement chain hash does not match genesis hash")
                };
@@ -2766,6 +2769,7 @@ pub(crate) mod tests {
                let gossip_sync = P2PGossipSync::new(&network_graph, Some(&chain_source), &logger);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                let amount_sats = Amount::from_sat(1000_000);
@@ -2779,7 +2783,7 @@ pub(crate) mod tests {
 
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
-                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -2788,7 +2792,7 @@ pub(crate) mod tests {
 
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
                network_graph.verify_channel_update(&valid_channel_update).unwrap();
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(res) => assert!(res),
                        _ => panic!(),
                };
@@ -2808,7 +2812,7 @@ pub(crate) mod tests {
                        unsigned_channel_update.excess_data.resize(MAX_EXCESS_BYTES_FOR_RELAY + 1, 0);
                }, node_1_privkey, &secp_ctx);
                // Return false because contains excess data
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(res) => assert!(!res),
                        _ => panic!()
                };
@@ -2817,7 +2821,7 @@ pub(crate) mod tests {
                        unsigned_channel_update.timestamp += 110;
                        unsigned_channel_update.short_channel_id += 1;
                }, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Couldn't find channel for update")
                };
@@ -2826,7 +2830,7 @@ pub(crate) mod tests {
                        unsigned_channel_update.htlc_maximum_msat = MAX_VALUE_MSAT + 1;
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than maximum possible msats")
                };
@@ -2835,7 +2839,7 @@ pub(crate) mod tests {
                        unsigned_channel_update.htlc_maximum_msat = amount_sats.to_sat() * 1000 + 1;
                        unsigned_channel_update.timestamp += 110;
                }, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "htlc_maximum_msat is larger than channel capacity or capacity is bogus")
                };
@@ -2845,7 +2849,7 @@ pub(crate) mod tests {
                let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                        unsigned_channel_update.timestamp += 100;
                }, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_update(&valid_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Update had same timestamp as last processed update")
                };
@@ -2856,7 +2860,7 @@ pub(crate) mod tests {
                let zero_hash = Sha256dHash::hash(&[0; 32]);
                let fake_msghash = hash_to_message!(zero_hash.as_byte_array());
                invalid_sig_channel_update.signature = secp_ctx.sign_ecdsa(&fake_msghash, node_1_privkey);
-               match gossip_sync.handle_channel_update(&invalid_sig_channel_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &invalid_sig_channel_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Invalid signature on channel_update message")
                };
@@ -2867,7 +2871,7 @@ pub(crate) mod tests {
                        unsigned_channel_update.chain_hash = ChainHash::using_genesis_block(Network::Bitcoin);
                }, node_1_privkey, &secp_ctx);
 
-               match gossip_sync.handle_channel_update(&incorrect_chain_update) {
+               match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &incorrect_chain_update) {
                        Ok(_) => panic!(),
                        Err(e) => assert_eq!(e.err, "Channel update chain hash does not match genesis hash")
                };
@@ -2978,6 +2982,7 @@ pub(crate) mod tests {
                let secp_ctx = Secp256k1::new();
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
@@ -2988,11 +2993,11 @@ pub(crate) mod tests {
 
                // Submit two channel updates for each channel direction (update.flags bit).
                let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
-               assert!(gossip_sync.handle_channel_update(&valid_channel_update).is_ok());
+               assert!(gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update).is_ok());
                assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
 
                let valid_channel_update_2 = get_signed_channel_update(|update| {update.channel_flags |=1;}, node_2_privkey, &secp_ctx);
-               gossip_sync.handle_channel_update(&valid_channel_update_2).unwrap();
+               gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update_2).unwrap();
                assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().two_to_one.is_some());
 
                network_graph.remove_stale_channels_and_tracking_with_time(100 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
@@ -3024,7 +3029,7 @@ pub(crate) mod tests {
                        let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                                unsigned_channel_update.timestamp = (announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS) as u32;
                        }, node_1_privkey, &secp_ctx);
-                       assert!(gossip_sync.handle_channel_update(&valid_channel_update).is_ok());
+                       assert!(gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update).is_ok());
                        assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_some());
                        network_graph.remove_stale_channels_and_tracking_with_time(announcement_time + 1 + STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS);
                        // Make sure removed channels are tracked.
@@ -3107,6 +3112,7 @@ pub(crate) mod tests {
                let network_graph = create_network_graph();
                let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Channels were not announced yet.
@@ -3118,7 +3124,7 @@ pub(crate) mod tests {
                        // Announce a channel we will update
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
                        short_channel_id = valid_channel_announcement.contents.short_channel_id;
-                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -3139,7 +3145,7 @@ pub(crate) mod tests {
                        let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
                                unsigned_channel_update.timestamp = 101;
                        }, node_1_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_update(&valid_channel_update) {
+                       match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -3161,7 +3167,7 @@ pub(crate) mod tests {
                                unsigned_channel_update.timestamp = 102;
                                unsigned_channel_update.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_1_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_update(&valid_channel_update) {
+                       match gossip_sync.handle_channel_update(Some(&node_1_pubkey), &valid_channel_update) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -3187,6 +3193,7 @@ pub(crate) mod tests {
                let network_graph = create_network_graph();
                let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id_1 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
 
@@ -3197,7 +3204,7 @@ pub(crate) mod tests {
                {
                        // Announce a channel to add 2 nodes
                        let valid_channel_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_announcement(&valid_channel_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_channel_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -3209,13 +3216,13 @@ pub(crate) mod tests {
 
                {
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-                       match gossip_sync.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
 
                        let valid_announcement = get_signed_node_announcement(|_| {}, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(_) => (),
                                Err(_) => panic!()
                        };
@@ -3234,7 +3241,7 @@ pub(crate) mod tests {
                                unsigned_announcement.timestamp += 10;
                                unsigned_announcement.excess_data = [1; MAX_EXCESS_BYTES_FOR_RELAY + 1].to_vec();
                        }, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_node_announcement(&valid_announcement) {
+                       match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(res) => assert!(!res),
                                Err(_) => panic!()
                        };
@@ -3250,17 +3257,18 @@ pub(crate) mod tests {
                let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
 
                // Announce a channel to add a corresponding node.
                let valid_announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-               match gossip_sync.handle_channel_announcement(&valid_announcement) {
+               match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(res) => assert!(res),
                        _ => panic!()
                };
 
                let valid_announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-               match gossip_sync.handle_node_announcement(&valid_announcement) {
+               match gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &valid_announcement) {
                        Ok(_) => (),
                        Err(_) => panic!()
                };
@@ -3338,6 +3346,7 @@ pub(crate) mod tests {
 
                let chain_hash = ChainHash::using_genesis_block(Network::Testnet);
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_id_2 = PublicKey::from_secret_key(&secp_ctx, node_2_privkey);
 
@@ -3358,7 +3367,7 @@ pub(crate) mod tests {
                        let valid_announcement = get_signed_channel_announcement(|unsigned_announcement| {
                                unsigned_announcement.short_channel_id = scid;
                        }, node_1_privkey, node_2_privkey, &secp_ctx);
-                       match gossip_sync.handle_channel_announcement(&valid_announcement) {
+                       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                                Ok(_) => (),
                                _ => panic!()
                        };
@@ -3816,11 +3825,12 @@ pub(crate) mod tests {
                let (secp_ctx, gossip_sync) = create_gossip_sync(&network_graph);
 
                let node_1_privkey = &SecretKey::from_slice(&[42; 32]).unwrap();
+               let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
                let node_2_privkey = &SecretKey::from_slice(&[41; 32]).unwrap();
                let node_1_id = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
 
                let announcement = get_signed_channel_announcement(|_| {}, node_1_privkey, node_2_privkey, &secp_ctx);
-               gossip_sync.handle_channel_announcement(&announcement).unwrap();
+               gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &announcement).unwrap();
 
                let tcp_ip_v4 = SocketAddress::TcpIpV4 {
                        addr: [255, 254, 253, 252],
@@ -3845,7 +3855,7 @@ pub(crate) mod tests {
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(|_| {}, node_1_privkey, &secp_ctx);
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3858,7 +3868,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3870,7 +3880,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3882,7 +3892,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3892,7 +3902,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3902,7 +3912,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
 
                let announcement = get_signed_node_announcement(
@@ -3912,7 +3922,7 @@ pub(crate) mod tests {
                        },
                        node_1_privkey, &secp_ctx
                );
-               gossip_sync.handle_node_announcement(&announcement).unwrap();
+               gossip_sync.handle_node_announcement(Some(&node_1_pubkey), &announcement).unwrap();
                assert!(!network_graph.read_only().node(&node_1_id).unwrap().is_tor_only());
        }
 }
index cf991ed0a4042c7b6efeab2d02112fb9b90d853f..d38b505c79da2b29892de1d0246b341c6124bd5f 100644 (file)
@@ -32,7 +32,8 @@ pub(crate) fn add_channel(
        gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
        secp_ctx: &Secp256k1<All>, node_1_privkey: &SecretKey, node_2_privkey: &SecretKey, features: ChannelFeatures, short_channel_id: u64
 ) {
-       let node_id_1 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_privkey));
+       let node_1_pubkey = PublicKey::from_secret_key(&secp_ctx, node_1_privkey);
+       let node_id_1 = NodeId::from_pubkey(&node_1_pubkey);
        let node_id_2 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_2_privkey));
 
        let unsigned_announcement = UnsignedChannelAnnouncement {
@@ -54,7 +55,7 @@ pub(crate) fn add_channel(
                bitcoin_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_privkey),
                contents: unsigned_announcement.clone(),
        };
-       match gossip_sync.handle_channel_announcement(&valid_announcement) {
+       match gossip_sync.handle_channel_announcement(Some(&node_1_pubkey), &valid_announcement) {
                Ok(res) => assert!(res),
                _ => panic!()
        };
@@ -64,7 +65,8 @@ pub(crate) fn add_or_update_node(
        gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
        secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, features: NodeFeatures, timestamp: u32
 ) {
-       let node_id = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_privkey));
+       let node_pubkey = PublicKey::from_secret_key(&secp_ctx, node_privkey);
+       let node_id = NodeId::from_pubkey(&node_pubkey);
        let unsigned_announcement = UnsignedNodeAnnouncement {
                features,
                timestamp,
@@ -81,7 +83,7 @@ pub(crate) fn add_or_update_node(
                contents: unsigned_announcement.clone()
        };
 
-       match gossip_sync.handle_node_announcement(&valid_announcement) {
+       match gossip_sync.handle_node_announcement(Some(&node_pubkey), &valid_announcement) {
                Ok(_) => (),
                Err(_) => panic!()
        };
@@ -91,13 +93,14 @@ pub(crate) fn update_channel(
        gossip_sync: &P2PGossipSync<Arc<NetworkGraph<Arc<test_utils::TestLogger>>>, Arc<test_utils::TestChainSource>, Arc<test_utils::TestLogger>>,
        secp_ctx: &Secp256k1<All>, node_privkey: &SecretKey, update: UnsignedChannelUpdate
 ) {
+       let node_pubkey = PublicKey::from_secret_key(&secp_ctx, node_privkey);
        let msghash = hash_to_message!(&Sha256dHash::hash(&update.encode()[..])[..]);
        let valid_channel_update = ChannelUpdate {
                signature: secp_ctx.sign_ecdsa(&msghash, node_privkey),
                contents: update.clone()
        };
 
-       match gossip_sync.handle_channel_update(&valid_channel_update) {
+       match gossip_sync.handle_channel_update(Some(&node_pubkey), &valid_channel_update) {
                Ok(res) => assert!(res),
                Err(_) => panic!()
        };
index 7252162e269015a295546b7fd29537ac361b4f60..78ce627be0552908c1b8a30497847ee5c8538413 100644 (file)
@@ -1023,14 +1023,14 @@ impl TestRoutingMessageHandler {
        }
 }
 impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
-       fn handle_node_announcement(&self, _msg: &msgs::NodeAnnouncement) -> Result<bool, msgs::LightningError> {
+       fn handle_node_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::NodeAnnouncement) -> Result<bool, msgs::LightningError> {
                Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
        }
-       fn handle_channel_announcement(&self, _msg: &msgs::ChannelAnnouncement) -> Result<bool, msgs::LightningError> {
+       fn handle_channel_announcement(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelAnnouncement) -> Result<bool, msgs::LightningError> {
                self.chan_anns_recvd.fetch_add(1, Ordering::AcqRel);
                Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
        }
-       fn handle_channel_update(&self, _msg: &msgs::ChannelUpdate) -> Result<bool, msgs::LightningError> {
+       fn handle_channel_update(&self, _their_node_id: Option<&PublicKey>, _msg: &msgs::ChannelUpdate) -> Result<bool, msgs::LightningError> {
                self.chan_upds_recvd.fetch_add(1, Ordering::AcqRel);
                Err(msgs::LightningError { err: "".to_owned(), action: msgs::ErrorAction::IgnoreError })
        }