Peer to peer node handshake on Bitcoin

Handling the Handshake

The handshake process is initiated by connecting to a target node, sending a version message, and expecting a version message in return. Upon successful version exchange, a verack message is sent to the node, and a verack message is expected in return to complete the handshake. wiki link here

How to run

  1. Clone this repository:
git clone https://github.com/BowTiedDeployer/bitcoin-node-handshake.git
cd bitcoin-node-handshake
  1. Build the project:
cargo build --release
  1. Run the CLI with desired commands, for example (optional argument -t for testnet):
  • To list available DNS seeds:
cargo run -- -dns [-t]
  • To fetch IPs from specified DNS seeds (optional argument -t for testnet):
cargo run -- -ips [-t] <number> <DNS> <DNS> ... <DNS>
  • To perform a handshake with specified IPs and the optional arguments:
    • -t for testnet
    • -f to log the output in output.log instead of the terminal
cargo run -- -handshake [-t] [-f] <IP> <IP> ... <IP>

How to test the Handshake

After running the handshake command, check the console (or file) output to verify that the version and verack messages were successfully exchanged with the target node(s).