<blockquote>
<p>want to capture all the transactions propagated over the main network and detect if a new block mined. I don't want to become a full-node or spv-node. Technically, I know this is exactly the way all the full/spv nodes do every now and then. However, I could not found a good reference to teach me how.</p>
</blockquote>
<p>Clearly, full nodes and SPV nodes must get their information from somewhere. And that somewhere is simply other nodes on the P2P network.</p>
<p>The P2P protocol is what nodes use to communicate with each other. There is some documentation on <a href="https://developer.bitcoin.org/devguide/p2p_network.html" rel="nofollow noreferrer">https://developer.bitcoin.org/devguide/p2p_network.html</a>, some older but more detailed documentation on <a href="https://en.bitcoin.it/wiki/Protocol_documentation" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Protocol_documentation</a>). Modern changes to it are proposed as BIPs (<a href="https://github.com/bitcoin/bips" rel="nofollow noreferrer">https://github.com/bitcoin/bips</a>), which are usually backward compatible changes, only used between clients that support it.</p>
<p>Specifically, transactions are relayed by first announcing their hash using an &quot;inv&quot; message. The receiver then chooses which peer to fetch the full transaction data from, and sends a &quot;getdata' message. The selected peer then responds with a &quot;tx&quot; message. There are other mechanisms available such as the old (and largely abandoned) BIP37 transaction filtering, and the newer BIP157 client-side filtering.</p>
<p>For blocks, it is a bit more complicated. The sequence there is first requesting block information using &quot;getblocks&quot;, then responding with &quot;inv&quot;s for the blocks, &quot;getdata&quot; to request the full data, and &quot;block&quot; for the full blocks themselves. BIP152 compact blocks provides a far more efficient mechanism that allows the receiver to avoid receiving transactions in blocks they already have. BIP130 sendheaders enables an alternative where blocks are announced using &quot;header&quot; messages instead of &quot;inv&quot; messages.</p>
<p>So what distinguishes a full node from an SPV node or other nodes? The level of validation they perform. A full node will fully validate all blocks and transactions it receives. If you don't want to do that, just don't - if you're ok with trusting whomever you're connecting to. You can implement the P2P protocol yourself, or use existing implementations (there exist ones in many languages), connect to whatever peers you like, and if you do it right they'll start giving you a stream of blocks and transactions.</p>

CC BY-SA 4.0
2021-05-30T20:58:30.343Z
2021-05-30T20:58:30.343Z
Pieter Wuille
<p>You might find my question rather quixotic or nonsense. But I have to ask it here.</p>
<p>I want to capture all the transactions propagated over the main network and detect if a new block mined. I don't want to become a full-node or spv-node. Technically, I know this is exactly the way all the full/spv nodes do every now and then. However, I could not found a good reference to teach me how.</p>
<p>Is it a way to do so? Any technical resources would be appreciated.</p>

CC BY-SA 4.0
2021-05-30T12:30:23.837Z
@Prayank Sounds good. Would you please elaborate on this?
Davood
<client><network>
Is it possible to capture network events without going full-node?
Davood
# Is it possible to capture network events without going full-node?

(Asked by: username_0 on 2021-05-29)

You might find my question rather quixotic or nonsense. But I have to ask it here.

I want to capture all the transactions propagated over the main network and detect if a new block mined. I don't want to become a full-node or spv-node. Technically, I know this is exactly the way all the full/spv nodes do every now and then. However, I could not found a good reference to teach me how.

Is it a way to do so? Any technical resources would be appreciated.

**Tags:** client, network

> **Comments:**
> **username_0**: @Prayank Sounds good. Would you please elaborate on this?  

---

## 1 answers

### Answer by username_1 on 2021-05-30. Score: 4 | Accepted answer

> want to capture all the transactions propagated over the main network and detect if a new block mined. I don't want to become a full-node or spv-node. Technically, I know this is exactly the way all the full/spv nodes do every now and then. However, I could not found a good reference to teach me how.

Clearly, full nodes and SPV nodes must get their information from somewhere. And that somewhere is simply other nodes on the P2P network.

The P2P protocol is what nodes use to communicate with each other. There is some documentation on <https://developer.bitcoin.org/devguide/p2p_network.html>, some older but more detailed documentation on <https://en.bitcoin.it/wiki/Protocol_documentation>). Modern changes to it are proposed as BIPs (<https://github.com/bitcoin/bips>), which are usually backward compatible changes, only used between clients that support it.

Specifically, transactions are relayed by first announcing their hash using an "inv" message. The receiver then chooses which peer to fetch the full transaction data from, and sends a "getdata' message. The selected peer then responds with a "tx" message. There are other mechanisms available such as the old (and largely abandoned) BIP37 transaction filtering, and the newer BIP157 client-side filtering.

For blocks, it is a bit more complicated. The sequence there is first requesting block information using "getblocks", then responding with "inv"s for the blocks, "getdata" to request the full data, and "block" for the full blocks themselves. BIP152 compact blocks provides a far more efficient mechanism that allows the receiver to avoid receiving transactions in blocks they already have. BIP130 sendheaders enables an alternative where blocks are announced using "header" messages instead of "inv" messages.

So what distinguishes a full node from an SPV node or other nodes? The level of validation they perform. A full node will fully validate all blocks and transactions it receives. If you don't want to do that, just don't - if you're ok with trusting whomever you're connecting to. You can implement the P2P protocol yourself, or use existing implementations (there exist ones in many languages), connect to whatever peers you like, and if you do it right they'll start giving you a stream of blocks and transactions.


---

