What is the P2P technology/protocol used by Bitcoin to find nodes and distribute messages across them?

7

4

I am wondering if there is a standard/de facto P2P library/implementation/spec used by Bitcoin Core and other implementations of Bitcoin?

Peter Mel

Posted 2015-09-04T00:55:01.113

Reputation: 575

Answers

8

Bitcoin has its own custom wire protocol using TCP. Peer discovery is by address rumoring, where connected nodes gossip about other potential available peers. When a node is new and has nobody to gossip with, they make a DNS lookup of specific hostnames which provide a number of known-good peers to make an outgoing connection to. If DNS seeds fail and none of the known peers are good, Bitcoin Core nodes fall back to a set of hardcoded peers as a last resort.

https://bitcoin.org/en/developer-reference#p2p-network

Bitcore, BitcoinJ and python-bitcoinlib all have basic implementations of the wire protocol in JavaScript, Java and Python respectively. It is fairly simple to interact with nodes but misbehavior (such as sending invalid data) will cause the remote peer to ban you.

Anonymous

Posted 2015-09-04T00:55:01.113

Reputation: 10 054

1

I'd like to note that Bitcoin P2P libraries for C# are also available in NBitcoin and the Stratis fullnode.

Dan Gershony

Posted 2015-09-04T00:55:01.113

Reputation: 21