<blockquote>
  <p>How does my transaction reach a miner?</p>
</blockquote>

<p>First, when you start up your wallet, it will connect to several other nodes on the network using the mechanism described <a href="https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other">here</a>. 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.</p>

<p>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 <code>inv</code> message (basically just says "I have this piece of data"), requested with a <code>getdata</code> message (says "please give me this piece of data"), and sent with the appropriate message type (<code>block</code>, <code>tx</code>, etc.).</p>

<p>So when you send a transaction, your node announces via an <code>inv</code> 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.</p>

<blockquote>
  <p>Similarly, how does machine A learn of the transaction?</p>
</blockquote>

<p>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.</p>

<p>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).</p>

CC BY-SA 3.0
2018-03-21T17:16:54.140Z
2018-03-21T17:16:54.140Z
Ava Chow
<p>Related: <a href="https://bitcoin.stackexchange.com/questions/9563/how-do-transactions-get-to-miners">how do transactions get to miners</a>, but I'm looking for a slightly (and only slightly) more technical discussion.</p>

<p>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. </p>

<ol>
<li>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? </li>
<li>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? </li>
</ol>

CC BY-SA 3.0
2018-03-21T16:13:04.487Z
This discussion appears to answer the bulk of the question. A summary overview could still be helpful: https://bitcoin.stackexchange.com/questions/53260/what-precisely-are-vseeds-seednodes-how-to-they-work-how-to-create-one-for-a?rq=1
zkurtz
<transactions><network>
Where do transactions get sent?
zkurtz
# Where do transactions get sent?

(Asked by: username_0 on 2018-03-21)

Related: [how do transactions get to miners](https://bitcoin.stackexchange.com/questions/9563/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?

**Tags:** transactions, network

> **Comments:**
> **username_0**: This discussion appears to answer the bulk of the question. A summary overview could still be helpful: https://bitcoin.stackexchange.com/questions/53260/what-precisely-are-vseeds-seednodes-how-to-they-work-how-to-create-one-for-a?rq=1  

---

## 1 answers

### Answer by username_1 on 2018-03-21. Score: 1 | Accepted answer

> 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](https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other). 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).


---

