Skip to content

Commit 84f5ab4

Browse files
committed
Enforce that node_ids are sorted in channel_announcements
We already enforced that nodes can't have a chanel with themselves, but the spec was updated to require strict ordering at lightning/bolts#1333 so we enforce this as well.
1 parent 311ad94 commit 84f5ab4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lightning/src/routing/gossip.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,9 +2011,9 @@ where
20112011
&self, short_channel_id: u64, capacity_sats: Option<u64>, timestamp: u64,
20122012
features: ChannelFeatures, node_id_1: NodeId, node_id_2: NodeId,
20132013
) -> Result<(), LightningError> {
2014-
if node_id_1 == node_id_2 {
2014+
if node_id_1 >= node_id_2 {
20152015
return Err(LightningError {
2016-
err: "Channel announcement node had a channel with itself".to_owned(),
2016+
err: "node_ids in channel_announcements must be sorted".to_owned(),
20172017
action: ErrorAction::IgnoreError,
20182018
});
20192019
};
@@ -2123,6 +2123,13 @@ where
21232123
{
21242124
let channels = self.channels.read().unwrap();
21252125

2126+
if msg.node_id_1 >= msg.node_id_2 {
2127+
return Err(LightningError {
2128+
err: "node_ids in channel_announcements must be sorted".to_owned(),
2129+
action: ErrorAction::IgnoreError,
2130+
});
2131+
}
2132+
21262133
if let Some(chan) = channels.get(&msg.short_channel_id) {
21272134
if chan.capacity_sats.is_some() {
21282135
// If we'd previously looked up the channel on-chain and checked the script

0 commit comments

Comments
 (0)