Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Gdns8476 on March 07, 2021, 04:32:02 PM



Title: Bitcoin wallet
Post by: Gdns8476 on March 07, 2021, 04:32:02 PM
Hi, how the wallet knows IP & port of available node?


Title: Re: Bitcoin wallet
Post by: BrewMaster on March 07, 2021, 04:34:06 PM
bitcoin nodes start by first connecting to a set of hard coded seeders that have a list of bitcoin node's IP addresses. then it will get and construct a list of its own from any node that it connects to so that in the future it can choose one from that list for future connections.


Title: Re: Bitcoin wallet
Post by: NotATether on March 08, 2021, 06:15:05 PM
When you start Bitcoin Core, it reads a file on disk called peers.dat which contain the IP addresses of all peers that is has ever connected to. It will start with 10 outgoing connections to peers and at least 10 incoming connections which grows over time as more nodes are discovered, and added to the peers.dat file appropriately.

You can also use the -addnode option on the command line or the addnode directive in the bitcoin.conf configuration file to manually add nodes that you want it to keep a connection to in addition to the discovered peers and the ones contained in peers.dat.


Title: Re: Bitcoin wallet
Post by: ranochigo on March 09, 2021, 01:36:17 AM
When you start Bitcoin Core, it reads a file on disk called peers.dat which contain the IP addresses of all peers that is has ever connected to. It will start with 10 outgoing connections to peers and at least 10 incoming connections which grows over time as more nodes are discovered, and added to the peers.dat file appropriately.
There isn't a requirement to maintain incoming connections nor can the node decide whether other nodes should connect to it. Outgoing connections is capped at 10 but can be lower as well. Incoming connection doesn't change with the discovery of other nodes but the knowledge of your node by others. 2 of the peers are reserved as block-relay only nodes which is read from anchors.dat.