Skip to content
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

Don't leak the local time and default services in the handshake #2

Conversation

receiver: bitcoin::p2p::Address {
services: bitcoin::p2p::ServiceFlags::default(),
services: bitcoin::p2p::ServiceFlags::NONE,
address: [0; 8],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this [0; 8]? Does it create 8 zero bytes? If yes, then that should be 16 instead of 8 bytes.
https://developer.bitcoin.org/reference/p2p_networking.html#version

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address struct looks like this:

/// A message which can be sent on the Bitcoin network
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Address {
    /// Services provided by the peer whose address this is
    pub services: ServiceFlags,
    /// Network byte-order ipv6 address, or ipv4-mapped ipv6 address
    pub address: [u16; 8],
    /// Network port
    pub port: u16,
}

It is indeed 16 bytes, but for some reason rust-bitcoin defines that as 8 shorts. So the end result is the same.

@alfred-hodler alfred-hodler merged commit cb75581 into alfred-hodler:master May 23, 2024
3 checks passed
@alfred-hodler
Copy link
Owner

Useful additions, thank you.

@vasild vasild deleted the version_message_same_as_bitcoin_core branch May 23, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants