Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I am trying to understand Bitcoin at a more fundamental level. I'd like to know how a new transaction enters and propagates across the network? I've read many Bob and Alice type scenarios where it's said that "the transaction is broadcast to the network". If there are many nodes on the Bitcoin network, how does the wallet know which node to initially broadcast the transaction to?

EDIT

Just for clarification, I'm referring to the process of sending from the client wallet (e.g. Mycelium on Android) to Node 1, before it gets propagated to all other nodes. How does my wallet know which node to send to first, or does it just randomly pick one?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I'd suggest you read this blog post about using the raw Bitcoin protocol: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

To answer your question, you should specifically read the "How to find peers" section of that post. Specifically this part:

There's a chicken-and-egg problem, though, of how to find the first peer. Bitcoin clients solve this problem with several methods. Several reliable peers are registered in DNS under the name bitseed.xf2.org. By doing a nslookup, a client gets the IP addresses of these peers, and hopefully one of them will work. If that doesn't work, a seed list of peers is hardcoded into the client.

and

The hardcoded peer list in the Bitcoin client is in chainparams.cpp in the array pnseed. For more information on finding Bitcoin peers, see How Bitcoin clients find each other or Satoshi client node discovery.

share|improve this answer
    
Exactly what I was looking for, thanks! –  QF_Developer Feb 12 at 21:59
add comment
  • A node learns about a new transaction, either from a peer or of it's own creation.
  • It announces to every one of it's peers (8+ typically) with an inventory message that it has learned about a transaction or block with a particular ID.
  • If the connected peer doesn't already know about the announced transaction, it sends a getdata request back asking for the contents of the transaction. If it already knows about the transaction, no getdata is made in response.

Within a few seconds (less than 5s on average currently) every peer in the network has the relayed transaction. This is possible because of the mesh layout of the network, every node connects to every other node through some degree of separation. The design makes it incredibly difficult to determine if a node created a transaction or is just relaying it, this is by design.

share|improve this answer
    
The type of structure is known as a "gossip network". Where nodes in network try to know as much as possible. –  Jacob Torba Feb 12 at 21:46
    
You mention it can know about a transaction "from a peer or of it's own creation", but what is meant by "of it's own creation"? I initiate a transaction from my Android wallet, how does that reach the first node? The node itself isn't creating the transaction? thanks! –  QF_Developer Feb 12 at 21:48
    
I'm not sure how the android wallet works, but it's probably different to the normal network topography. In the case of other lite clients (see, spv client on the wiki), it will announce to normal peers on the network and ignore everything else going on. It's a bit different to how normal nodes work. –  goatse Feb 12 at 22:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.