@@ -154,14 +154,21 @@ macro_rules! secp_verify_sig {
154
154
155
155
impl < C : Deref , L : Deref > RoutingMessageHandler for NetGraphMsgHandler < C , L > where C :: Target : chain:: Access , L :: Target : Logger {
156
156
fn handle_node_announcement ( & self , msg : & msgs:: NodeAnnouncement ) -> Result < bool , LightningError > {
157
- self . network_graph . write ( ) . unwrap ( ) . update_node_from_announcement ( msg, & self . secp_ctx ) ?;
157
+ let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. contents. encode( ) [ ..] ) [ ..] ) ;
158
+ secp_verify_sig ! ( self . secp_ctx, & msg_hash, & msg. signature, & msg. contents. node_id) ;
159
+ self . network_graph . write ( ) . unwrap ( ) . update_node_from_announcement_intern ( & msg. contents , Some ( & msg) ) ?;
158
160
Ok ( msg. contents . excess_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY &&
159
161
msg. contents . excess_address_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY &&
160
162
msg. contents . excess_data . len ( ) + msg. contents . excess_address_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY )
161
163
}
162
164
163
165
fn handle_channel_announcement ( & self , msg : & msgs:: ChannelAnnouncement ) -> Result < bool , LightningError > {
164
- self . network_graph . write ( ) . unwrap ( ) . update_channel_from_announcement ( msg, & self . chain_access , & self . secp_ctx ) ?;
166
+ let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. contents. encode( ) [ ..] ) [ ..] ) ;
167
+ secp_verify_sig ! ( self . secp_ctx, & msg_hash, & msg. node_signature_1, & msg. contents. node_id_1) ;
168
+ secp_verify_sig ! ( self . secp_ctx, & msg_hash, & msg. node_signature_2, & msg. contents. node_id_2) ;
169
+ secp_verify_sig ! ( self . secp_ctx, & msg_hash, & msg. bitcoin_signature_1, & msg. contents. bitcoin_key_1) ;
170
+ secp_verify_sig ! ( self . secp_ctx, & msg_hash, & msg. bitcoin_signature_2, & msg. contents. bitcoin_key_2) ;
171
+ self . network_graph . write ( ) . unwrap ( ) . update_channel_from_unsigned_announcement_intern ( & msg. contents , Some ( msg) , & self . chain_access ) ?;
165
172
log_trace ! ( self . logger, "Added channel_announcement for {}{}" , msg. contents. short_channel_id, if !msg. contents. excess_data. is_empty( ) { " with excess uninterpreted data!" } else { "" } ) ;
166
173
Ok ( msg. contents . excess_data . len ( ) <= MAX_EXCESS_BYTES_FOR_RELAY )
167
174
}
0 commit comments