Inv Message (Inventory Message)
An inv message is a Bitcoin P2P network message that advertises new transactions or blocks to peers, triggering data exchange through the gossip protocol.
Key Takeaways
- An inv message is how Bitcoin nodes announce new transactions and blocks to their peers: rather than sending full data immediately, nodes first advertise what they have using compact inventory vectors, and peers request only what they need.
- Each inventory vector is 36 bytes: a 4-byte type field (MSG_TX, MSG_BLOCK, or others) followed by a 32-byte hash identifying the object. A single inv message can carry up to 50,000 inventory vectors.
- The inv/getdata pattern is central to Bitcoin's gossip protocol, and Erlay (BIP-330) improves it by replacing most flooding-based announcements with bandwidth-efficient set reconciliation.
What Is an Inv Message?
An inv message (short for inventory message) is a peer-to-peer network message in the Bitcoin protocol that tells connected nodes about transactions or blocks the sender knows about. When a Bitcoin node receives or validates a new transaction or block, it does not immediately broadcast the full data to every peer. Instead, it sends a lightweight inv message containing only the type and hash of each object, allowing recipients to decide whether they need the full data.
This advertise-then-request pattern is fundamental to how Bitcoin propagates information across its decentralized network. It conserves bandwidth by ensuring nodes only download data they do not already have, rather than receiving redundant copies of every transaction and block from every peer.
The inv message works in tandem with the getdata message: a node sends inv to announce available objects, and interested peers respond with getdata to request the full content. This two-step handshake is at the core of Bitcoin's gossip protocol.
How It Works
When a node has new data to share, the inv/getdata exchange follows a predictable sequence:
- A node validates a new transaction or block (either received from a peer or submitted locally)
- The node constructs an inv message containing one or more inventory vectors describing the new objects
- The node sends the inv message to its connected peers
- Each receiving peer checks the inventory vectors against its own mempool and block database
- For any objects the peer does not already have, it sends a
getdatamessage back requesting the full data - The original node responds with the appropriate message: a
txmessage for transactions or ablockmessage for blocks
If the node cannot provide the requested data (for example, the transaction has already been evicted from the mempool), it replies with a notfound message.
Inventory Vector Structure
Each inventory vector within an inv message is exactly 36 bytes, consisting of two fields:
| Field | Size | Description |
|---|---|---|
| type | 4 bytes | Identifies the object type (little-endian uint32) |
| hash | 32 bytes | The SHA-256 double hash of the object |
The inv message itself begins with a compact-size encoded count of inventory vectors, followed by the vectors themselves. A single inv message can contain up to 50,000 inventory entries, though typical messages are much smaller.
Inventory Types
The 4-byte type field identifies what kind of object the hash refers to. The core inventory types defined in the Bitcoin protocol are:
| Type | Value | Description |
|---|---|---|
| ERROR | 0 | Can be ignored; used as a placeholder |
| MSG_TX | 1 | Hash refers to a transaction |
| MSG_BLOCK | 2 | Hash refers to a block |
| MSG_FILTERED_BLOCK | 3 | Hash refers to a block; peer responds with a filtered block (merkleblock) |
| MSG_CMPCT_BLOCK | 4 | Hash refers to a block; peer responds with a compact block |
| MSG_WTX | 5 | Witness transaction identifier (BIP 339), used for SegWit transaction announcements |
Additionally, BIP-144 defines witness-flagged types for getdata requests specifically. These set bit 30 of the type field: MSG_WITNESS_TX (0x40000001) and MSG_WITNESS_BLOCK (0x40000002). These witness types are used in getdata messages to request witness-serialized data, but inv messages themselves use the standard types.
Wire Format Example
An inv message advertising a single transaction looks like this on the wire:
# Inv message payload
01 # count: 1 inventory vector
01000000 # type: MSG_TX (1, little-endian)
a1b2c3d4e5f6... # 32-byte transaction hash (txid)
# Total payload: 1 + 4 + 32 = 37 bytesFor a message containing two items (a transaction and a block), the payload would start with a count of 02, followed by two 36-byte inventory vectors, totaling 73 bytes.
Role in Transaction Relay
Transaction relay is the process by which new transactions propagate across the peer-to-peer network from the node that first receives them to every other node. The inv message is the starting point of this process: when a node accepts a transaction into its mempool, it announces it to peers via inv, and those peers propagate it further.
In the traditional flooding model, a node sends an inv for each new transaction to every connected peer. With a typical node maintaining 8 outbound and up to 125 inbound connections, each transaction generates many redundant announcements across the network. Research has shown that roughly 88% of transaction announcement bandwidth is redundant under this model, since most peers already have the transaction by the time they receive later inv messages.
Block Announcements
Blocks can also be announced via inv messages, though modern Bitcoin nodes more commonly use the compact block relay protocol (BIP-152) for faster block propagation. In compact block mode, peers negotiate high-bandwidth mode during the version handshake and receive compact blocks directly without the inv/getdata round trip. The inv-based block relay path remains available as a fallback.
Erlay: Improving Inv Efficiency
Erlay, defined in BIP-330, fundamentally changes how transaction announcements work. Instead of flooding inv messages to every peer, Erlay splits relay into two phases:
- Flooding phase: the node sends inv messages to a small subset of outbound peers (approximately 8), ensuring fast initial propagation
- Reconciliation phase: for all remaining peers, the node periodically runs a set reconciliation protocol using minisketch (a library for efficient set difference computation) to determine which transactions each side is missing
The reconciliation approach replaces per-transaction inv messages with periodic sketch exchanges. According to the original research, Erlay reduces transaction announcement bandwidth by approximately 84%. Because bandwidth costs scale with peer count under flooding but remain nearly constant under reconciliation, Erlay allows nodes to maintain more peer connections without proportionally increasing bandwidth usage.
More peer connections strengthen the network against eclipse attacks, where an attacker tries to isolate a node by monopolizing all its connections. For a deeper look at Erlay's design and trade-offs, see the Erlay transaction relay protocol analysis.
Use Cases
- Transaction propagation: when a user broadcasts a transaction, their node sends inv messages to peers, which propagate it across the network until it reaches miners for inclusion in a block
- Block announcement: newly mined blocks are advertised via inv (or compact block relay) so all nodes can update their copy of the blockchain
- Initial block download: during initial sync, a node uses getblocks/inv exchanges to discover which blocks it needs to download from peers
- Mempool synchronization: nodes use inv messages to converge on a consistent view of unconfirmed transactions, which is important for fee estimation and block template construction
- Network health monitoring: the pattern and timing of inv messages can be analyzed to study network topology and propagation latency
Risks and Considerations
Bandwidth Overhead
Under the traditional flooding model, inv messages represent a significant portion of a node's bandwidth usage. Each transaction generates inv messages to every connected peer, and most of these are redundant because peers typically already have the transaction from another connection. This is the primary motivation behind Erlay and the reason bandwidth is a bottleneck for running a full node.
Privacy Implications
The timing and pattern of inv messages can reveal information about network topology and transaction origin. An adversary monitoring multiple nodes can observe which node first announces a transaction via inv and attempt to identify the original sender. Privacy protocols like Dandelion address this by adding a stem phase before the flood phase, obscuring the transaction's origin node.
Bitcoin Core's BIP-324 encrypted transport protects inv message content from passive network observers, but it does not hide timing patterns from peers themselves. For more on how encrypted transport strengthens peer connections, see the BIP-324 progress analysis.
Eclipse Attack Surface
If an attacker controls all of a node's peer connections, they can manipulate which inv messages the node sees: withholding blocks, hiding transactions, or feeding stale data. The inv/getdata model means a node only learns about objects that peers choose to announce. More details on these risks are covered in the eclipse attack mitigation research.
Spam and Rate Limiting
Because inv messages are unsolicited, a malicious peer could send large volumes of inv messages containing hashes for nonexistent or invalid objects, wasting the recipient's bandwidth and processing time on futile getdata requests. Bitcoin Core implements rate limiting and peer scoring to mitigate this: peers that consistently send invalid inventory are penalized and eventually disconnected.
This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.