Bitcoin Forum

Other => Beginners & Help => Topic started by: bitcoinrevelacio on April 22, 2013, 04:41:07 AM



Title: How do wallets connect to nodes?
Post by: bitcoinrevelacio on April 22, 2013, 04:41:07 AM
Hello all,
I have been watching and learning about bitcoin for a short while now. I think I understand the basics of bitcoin. However, I do not understand how my wallet (or anyone's for that matter) connects to the network. Is there a default list of connections that the wallet connects to? Or what is going on here?
For some reason this small part is really bugging me.

-bitcoinrevelacio


Title: Re: How do wallets connect to nodes?
Post by: scintill on April 22, 2013, 05:05:51 AM
https://en.bitcoin.it/wiki/FAQ#How_does_the_peer_finding_mechanism_work.3F

Current DNS names in the source code (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1174):

seed.bitcoin.sipa.be
dnsseed.bluematt.me
dnsseed.bitcoin.dashjr.org
bitseed.xf2.org

There are also hard-coded seed node IP addresses (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1231) (in hexadecimal form) in case DNS and IRC fail or the user configures not to use them.


Title: Re: How do wallets connect to nodes?
Post by: blackriver on April 22, 2013, 06:01:33 AM
and if it is to be changed (the dns), how and who would make such a change?? i don't understand very well


Title: Re: How do wallets connect to nodes?
Post by: downying on April 22, 2013, 07:27:20 AM
The bootstrap process finds nodes in many channels such as irc, dns. They are hardcoded though, if they all are taken down at once, the network dies.


Title: Re: How do wallets connect to nodes?
Post by: bitcoinrevelacio on April 22, 2013, 02:39:43 PM
https://en.bitcoin.it/wiki/FAQ#How_does_the_peer_finding_mechanism_work.3F

Current DNS names in the source code (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1174):

seed.bitcoin.sipa.be
dnsseed.bluematt.me
dnsseed.bitcoin.dashjr.org
bitseed.xf2.org

There are also hard-coded seed node IP addresses (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1231) (in hexadecimal form) in case DNS and IRC fail or the user configures not to use them.

So, once a wallet connects to the nodes specified in the source code it receives a list of all other known nodes. Does the wallet save all of these addresses or does it just download them each time it connects?
Downying seems to say that if all of the hardcoded nodes leave at once no one can connect? In other words the wallet does not save addresses. Is that accurate?


Title: Re: How do wallets connect to nodes?
Post by: DannyHamilton on April 22, 2013, 03:42:20 PM
If necessary, I believe you can also configure specific addresses that you want to connect to in a ".conf" file of some sort?


Title: Re: How do wallets connect to nodes?
Post by: scintill on April 22, 2013, 08:39:17 PM
and if it is to be changed (the dns), how and who would make such a change?? i don't understand very well

I think all those DNS names are controlled by core Bitcoin developers sipa, BlueMatt, Luke-Jr, and jgarzik (https://bitcointalk.org/index.php?topic=5632.0) (who seems to own xf2.org).  So they would each have to make the change.  I don't know the procedure, or how often it is updated, which nodes they put on those lists, etc.

The bootstrap process finds nodes in many channels such as irc, dns. They are hardcoded though, if they all are taken down at once, the network dies.

Only people connecting to the network for the first time would be catastrophically affected.  Actually, I just found that IRC seeding has been removed (https://github.com/bitcoin/bitcoin/commit/c2efd981aa14e94cce4a0a888b6ee1f4e4347924).  It is unlikely that 4 different DNS servers on 3 top-level domains would all be out.  And if they are, there are also dozens of hardcoded seed IP addresses that are contacted, so those would also all have to be down.  I don't know how those seeds were chosen, but I trust it's a pretty solid selection.  Really, if it's that bad, you may as well say there's no Bitcoin network left to connect to anyway.  Also, as long as you can manually find one peer's IP address, you can use that to find everyone else it knows about.

So, once a wallet connects to the nodes specified in the source code it receives a list of all other known nodes. Does the wallet save all of these addresses or does it just download them each time it connects?
Downying seems to say that if all of the hardcoded nodes leave at once no one can connect? In other words the wallet does not save addresses. Is that accurate?

The addresses are saved, in either peers.dat or addr.dat (peers in newer versions).  The bootstrapping/seed process is only used if the file doesn't exist or none of the nodes in it can be connected to.  And once you've connected to a node you get a list of all the nodes it knows about, and you remember them in peers.dat.

If necessary, I believe you can also configure specific addresses that you want to connect to in a ".conf" file of some sort?

Yes, if you run bitcoin-qt --help you can see all the configuration options, which can be specified on the commandline or in the .conf file.  There is -connect (connect only to the specified nodes) and -seednode (use the specified node to get a list of nodes to connect to) that I see being relevant to this, maybe more I missed.


Title: Re: How do wallets connect to nodes?
Post by: AprilShowers on April 22, 2013, 08:41:34 PM
https://en.bitcoin.it/wiki/FAQ#How_does_the_peer_finding_mechanism_work.3F

Current DNS names in the source code (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1174):

seed.bitcoin.sipa.be
dnsseed.bluematt.me
dnsseed.bitcoin.dashjr.org
bitseed.xf2.org

There are also hard-coded seed node IP addresses (https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1231) (in hexadecimal form) in case DNS and IRC fail or the user configures not to use them.

Would it be possible to DDoS all these and cripple everything?  Or am I missing something


Title: Re: How do wallets connect to nodes?
Post by: DannyHamilton on April 22, 2013, 09:00:42 PM
- snip -
Would it be possible to DDoS all these and cripple everything?  Or am I missing something

- snip -

Only people connecting to the network for the first time would be catastrophically affected.

- snip -

The addresses are saved, in either peers.dat or addr.dat (peers in newer versions).  The bootstrapping/seed process is only used if the file doesn't exist or none of the nodes in it can be connected to.  And once you've connected to a node you get a list of all the nodes it knows about, and you remember them in peers.dat.

- snip -



Title: Re: How do wallets connect to nodes?
Post by: scintill on April 22, 2013, 09:42:09 PM
For accuracy, I just checked the FAQ entry I originally linked, and it also says "each node saves a database of peers that it's aware of, for future use."  So DDoSing those DNS servers wouldn't hurt many users.


Title: Re: How do wallets connect to nodes?
Post by: rarkenin on April 22, 2013, 09:44:41 PM
The system still isn't fully decentralized, though. If it was, there would need to be a sort of distributed peer tracker(akin to torrent DHT). Still, there's no true way to bootstrap without a seed node unless one were to try scanning the entire IPv4 internet for nodes.


Title: Re: How do wallets connect to nodes?
Post by: bitcoinrevelacio on April 23, 2013, 12:53:15 AM
The system still isn't fully decentralized, though. If it was, there would need to be a sort of distributed peer tracker(akin to torrent DHT). Still, there's no true way to bootstrap without a seed node unless one were to try scanning the entire IPv4 internet for nodes.

Well if I am understanding this correctly you do not have to go through the nodes listed in the source code. You can easily specify a different node. This list of nodes however makes it easier for new users to get connected by having several connections ready to connect to. From what I understand it is still completely decentralized. You do not have to use bitcoin-qt. There are other wallets. Therefore, if you think bitcoin-qt is promoting a bad blockchain, then you use a different client. If you think a certain node is promoting a bad blockchain you can specify to connect to a different node.
However, there is no reason to think that any of the nodes or bitcoin-qt are doing anything wrong so it is easier for simplicity. The moment someone discovers something is wrong, there will be a big outcry. Things will get fixed or worked around.

I hope I got it right and it makes sense. Please, correct any mistakes.