This is a simple lib for the Bitcoin network. It is used to establish a connection between two nodes and to exchange information about the current state of the node.
To run the handshake example, run the following command:
cargo run --example handshake
It is possible to run the handshake example in a docker container. To do so, run the following commands:
docker build -t btc_handshake:latest .
docker run --rm btc_handshake:latest
Implementation follows Bitcoin p2p networking specification at https://developer.bitcoin.org/reference/p2p_networking.html
- Version message: Is sent by the initiator of the connection. It contains information about the node and its current state.
- Verack message: Is sent by the responder of the connection. It is a simple acknowledgement of the version message.
- Lookup at DNS seeds for a list of nodes.
- The initiator sends a version message to the nodes in the list.
- The nodes respond with a valid version message.
- The initiator sends a verack message to the nodes that responded to a valid version message.
- After this point other messages can be exchange between the nodes.