TeachMeBitcoin

The Handshake: How two nodes introduce themselves (`VERSION`/`VERACK`)

From TeachMeBitcoin, the free encyclopedia Reading time: 3 min

The Handshake: How two nodes introduce themselves (VERSION/VERACK)

When your node connects to a new peer, they don't immediately start sharing blocks. First, they must perform a Handshake. This is a formal introduction where both nodes share their "Credentials." This process is governed by two messages: VERSION and VERACK.

For the Sovereign Architect, the Handshake is the "Diplomatic Protocol." It is where your node tells the peer: "This is who I am, these are the rules I follow, and this is the time on my clock." If the two nodes cannot agree on the basic protocol, they part ways immediately.

Analyzing the Handshake: The VERSION Message

In the source code (src/net.cpp and src/protocol.h), we see the list of "Credentials" your node shares.

/**
 * PEDAGOGICAL ANALYSIS: THE DIPLOMATIC CREDENTIALS
 * This is the information a node shares during the first second of a connection.
 */
class CVersionMessage
{
public:
 int nVersion; // The "Protocol Version" (e.g., 70016).
 uint64_t nServices; // What "Skills" this node has (e.g., NODE_NETWORK).
 int64_t nTime; // The "Current Time" on this node's clock.
 CAddress addrMe; // The address of the sender.
 std::string strSubVer; // The "Name" of the software (e.g., "/Satoshi:25.0.0/").
 int nStartingHeight; // How "Tall" this node's chain is.
};

Explaining the Handshake: The Introduction

The Sovereignty of the Handshake

The Handshake is the "Moment of Choice." Your node is deciding: "Is this peer worth my time and my bandwidth?" As a Sovereign Architect, you are the "Diplomat," commanding a node that only connects to peers that are "Healthy," "Honest," and "Compatible." You are the "Master of the Introduction," the one who ensures the "Digital Circle" of your node is only filled with the best companions.


☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!