Related: how do transactions get to miners, but I'm looking for a slightly (and only slightly) more technical discussion.

Say I download a lightweight bitcoin client and set up a wallet on machine A. From another machine B, I send a coin to this new wallet.

  1. How does my transaction reach a miner? Presumably, the client on machine B sends a message out to the internet ... but doesn't it have to specify which IP address to send such a message? Which IP addresses does it send to?
  2. Similarly, how does machine A learn of the transaction? Is the client continually pinging the network to query for new transactions to its address? How does it know what IP addresses to ping the first time it executes?

1 Answer 1


How does my transaction reach a miner?

First, when you start up your wallet, it will connect to several other nodes on the network using the mechanism described here. These connections are TCP connections, so they are data streams from one computer directly to another; the IP addresses are known and data transmission is handled by the TCP layer.

Over this TCP connection, the two nodes will begin exchanging data. This first consists of some initial handshake stuff like version messages, various filters for the other node to apply before sending data to the other node, etc. Then it consists of block and transaction data. These are typically first announced via an inv message (basically just says "I have this piece of data"), requested with a getdata message (says "please give me this piece of data"), and sent with the appropriate message type (block, tx, etc.).

So when you send a transaction, your node announces via an inv message to the nodes that it is connected to that it has a transaction. The other nodes request it and the transaction is sent. Then those nodes repeat the same process; they announce to their peers that they have a transaction, it is requested and then sent. That is how a transaction propagates through the network. Eventually it will reach a nodes which belong to miners so the miners will be able to include your transaction in their next block.

Similarly, how does machine A learn of the transaction?

Since the TCP connections are bi-directional, your node is also receiving blocks and transactions from its peers. For full nodes, it will receive every block and transaction that its peers knows of, which, in general, will be every block and transaction on the network. It can then interpret each transaction and find the ones which pertain to your wallet.

For a lightweight wallet, it will use a special set of messages which allow it to set a filter on the transactions it receives. This filter is sent to the nodes it is connected to and those nodes will only send to your wallet the transactions that match this filter. Then your wallet will do additional filtering locally to find exactly which transactions pertain to it (the filters set can have false positives).

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .