-
Notifications
You must be signed in to change notification settings - Fork 26
Include funding amounts in channel announcements #102
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ use crate::config; | |
| use crate::lookup::{DeltaSet, DirectedUpdateDelta, NodeDeltaSet}; | ||
|
|
||
| pub(super) struct SerializationSet { | ||
| pub(super) announcements: Vec<UnsignedChannelAnnouncement>, | ||
| pub(super) announcements: Vec<(UnsignedChannelAnnouncement, u64)>, | ||
| pub(super) updates: Vec<UpdateSerialization>, | ||
| pub(super) full_update_defaults: DefaultUpdateValues, | ||
| pub(super) node_announcement_feature_defaults: Vec<NodeFeatures>, | ||
|
|
@@ -166,7 +166,8 @@ pub(super) fn serialize_delta_set(channel_delta_set: DeltaSet, node_delta_set: N | |
| let send_announcement = is_new_announcement || is_newly_included_announcement; | ||
| if send_announcement { | ||
| serialization_set.latest_seen = max(serialization_set.latest_seen, current_announcement_seen); | ||
| serialization_set.announcements.push(channel_delta.announcement.unwrap().announcement); | ||
| let announcement_delta = channel_delta.announcement.unwrap(); | ||
| serialization_set.announcements.push((announcement_delta.announcement, announcement_delta.funding_sats)); | ||
| } | ||
|
|
||
| let direction_a_updates = channel_delta.updates.0; | ||
|
|
@@ -266,7 +267,7 @@ pub(super) fn serialize_delta_set(channel_delta_set: DeltaSet, node_delta_set: N | |
| serialization_set | ||
| } | ||
|
|
||
| pub fn serialize_stripped_channel_announcement(announcement: &UnsignedChannelAnnouncement, node_id_a_index: usize, node_id_b_index: usize, previous_scid: u64) -> Vec<u8> { | ||
| pub fn serialize_stripped_channel_announcement(announcement: &UnsignedChannelAnnouncement, funding_sats: u64, node_id_a_index: usize, node_id_b_index: usize, previous_scid: u64, version: u8) -> Vec<u8> { | ||
| let mut stripped_announcement = vec![]; | ||
|
|
||
| announcement.features.write(&mut stripped_announcement).unwrap(); | ||
|
|
@@ -279,7 +280,19 @@ pub fn serialize_stripped_channel_announcement(announcement: &UnsignedChannelAnn | |
|
|
||
| // write indices of node ids rather than the node IDs themselves | ||
| BigSize(node_id_a_index as u64).write(&mut stripped_announcement).unwrap(); | ||
| BigSize(node_id_b_index as u64).write(&mut stripped_announcement).unwrap(); | ||
|
|
||
| let mut node_id_b_index = node_id_b_index as u64; | ||
| if version >= 2 { | ||
| // Set the "extra data" bit so that we can write the funding amount below. | ||
| node_id_b_index |= 1 << 63; | ||
|
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. Does the client reset this bit when looking up the node id?
Contributor
Author
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. |
||
| } | ||
| BigSize(node_id_b_index).write(&mut stripped_announcement).unwrap(); | ||
|
|
||
| if version >= 2 { | ||
| let mut funding_sats_vec = Vec::with_capacity(8); | ||
| BigSize(funding_sats).write(&mut funding_sats_vec).unwrap(); | ||
| funding_sats_vec.write(&mut stripped_announcement).unwrap(); | ||
| } | ||
|
|
||
| // println!("serialized CA: {}, \n{:?}\n{:?}\n", announcement.short_channel_id, announcement.node_id_1, announcement.node_id_2); | ||
| stripped_announcement | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it we'll always use the second node index for indicating extra data follows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, https://github.com/lightningdevkit/rust-lightning/blob/main/lightning-rapid-gossip-sync/src/processing.rs#L253