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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pushtx/src/p2p/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ pub fn client(socks_proxy: Option<SocketAddr>, network: crate::Network) -> Clien
network: network.into(),
join_handle,
our_version: VersionMessage {
version: 70015,
version: 70016,
services: bitcoin::p2p::ServiceFlags::NONE,
timestamp: crate::posix_time() as i64,
timestamp: 0,
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.

port: 8333,
port: 0,
},
sender: bitcoin::p2p::Address {
services: bitcoin::p2p::ServiceFlags::default(),
services: bitcoin::p2p::ServiceFlags::NONE,
address: [0; 8],
port: 0,
},
nonce: fastrand::u64(..),
user_agent: "".to_string(),
user_agent: "/pynode:0.0.1/".to_string(),
start_height: 0,
relay: false,
},
Expand Down
Loading