-
Notifications
You must be signed in to change notification settings - Fork 457
Enforce that node_ids are sorted in channel_announcements #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2014,9 +2014,9 @@ impl<L: Logger> NetworkGraph<L> { | |
| &self, short_channel_id: u64, capacity_sats: Option<u64>, timestamp: u64, | ||
| features: ChannelFeatures, node_id_1: NodeId, node_id_2: NodeId, | ||
| ) -> Result<(), LightningError> { | ||
| if node_id_1 == node_id_2 { | ||
| if node_id_1 >= node_id_2 { | ||
| return Err(LightningError { | ||
| err: "Channel announcement node had a channel with itself".to_owned(), | ||
| err: "node_ids in channel_announcements must be sorted".to_owned(), | ||
| action: ErrorAction::IgnoreError, | ||
| }); | ||
| }; | ||
|
|
@@ -2123,6 +2123,13 @@ impl<L: Logger> NetworkGraph<L> { | |
| ) -> Result<(), LightningError> { | ||
| let channels = self.channels.read().unwrap(); | ||
|
|
||
| if msg.node_id_1 >= msg.node_id_2 { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: The All callers implicitly rely on the key values ( Consider adding sorting logic to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's address this comment ? |
||
| return Err(LightningError { | ||
| err: "node_ids in channel_announcements must be sorted".to_owned(), | ||
| action: ErrorAction::IgnoreError, | ||
| }); | ||
| } | ||
|
|
||
| if let Some(chan) = channels.get(&msg.short_channel_id) { | ||
| if chan.capacity_sats.is_some() { | ||
| // If we'd previously looked up the channel on-chain and checked the script | ||
|
|
@@ -3126,7 +3133,7 @@ pub(crate) mod tests { | |
| .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"), | ||
| Err(e) => assert_eq!(e.err, "node_ids in channel_announcements must be sorted"), | ||
| }; | ||
|
|
||
| // Test that channel announcements with the wrong chain hash are ignored (network graph is testnet, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.