Skip to content

lean-apple/node-handshake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P2P Handshake with Bitcoin Protocol

Test Bitcoin Protcol handshake, an important step to establish communication between two nodes on the Bitcoin network.

It contains 2 major steps after initializing the communication between two nodes :

  • Sending a version message to the node
  • Receiving a vertrack response

Complete documentation on the global Bitcoin message, version and vertrack messages can be found here : Official Bitcoin Wiki.

Run

Set-up for local run

The work lies on running in parallel a Bitcoin node for the regtest Network.

You need to download up a bitcoin node implementation depending on your OS.

Once it is done, Bitcoin node can be launched :

bitcoind -regtest

It will listen by default on 18444 port.

and then you can launch the run :

cargo run

GHA run

All the steps mentionned to set up a Bitcoin node and run the handshake code on Linux env are launched through the GHA's ci. It can help also to see how to set up the Bitcoin.conf configuration file.

Test

A couple of tests are available either as unit tests for modules or either for the ones related to handshake at the following path : /test/test.rs.

You can launch them by this way :

cargo test

Code architecture considerations

As explained in next steps, the code is run only at the moment for regtest Network and has been simplified for the purpose.

Some ideas to improve it, would be to :

  • Add cargo command arguments to launch it dependeding on the network and also ideally pick a specific IP
  • Optimize link between different kinds of message to move more easily from BitcoinMessage to verack
  • Make error handling more consistent
  • Test it through multiple nodes scheme

About

Testing Bitcoin handshake communication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages