51 lines
2.1 KiB
Markdown
51 lines
2.1 KiB
Markdown
title: Messages
|
|
description: A superclass for the messages of the bitcoin network
|
|
---
|
|
# Messages
|
|
|
|
The bitcoin protocol specifies a set of [messages](https://en.bitcoin.it/wiki/Protocol_specification) that can be sent from peer to peer. `bitcore-p2p` provides support for some of these messages.
|
|
|
|
## List of Messages
|
|
|
|
### Version
|
|
|
|
The version message (`ver`) is used on connection creation, to advertise the type of node. The remote node will respond with its version, and no communication is possible until both peers have exchanged their versions. By default, bitcore advertises itself as named `bitcore` with the current version of the `bitcore-p2p` package.
|
|
|
|
### VerAck
|
|
|
|
Finishes the connection handshake started by the `ver` message.
|
|
|
|
### Inventory
|
|
|
|
From the bitcoin protocol spec: "Allows a node to advertise its knowledge of one or more objects. It can be received unsolicited, or in reply to getblocks.".
|
|
|
|
### GetData
|
|
|
|
From the bitcoin protocol spec: `getdata` is used in response to `inv`, to retrieve the content of a specific object, and is usually sent after receiving an `inv` packet, after filtering known elements. It can be used to retrieve transactions, but only if they are in the memory pool or relay set - arbitrary access to transactions in the chain is not allowed to avoid having clients start to depend on nodes having full transaction indexes (which modern nodes do not).
|
|
|
|
GetData inherits from Inventory, as they both have the same structure.
|
|
|
|
### Ping
|
|
|
|
Sent to another peer mainly to check the connection is still alive.
|
|
|
|
### Pong
|
|
|
|
Sent in response to a `ping` message.
|
|
|
|
### Address and GetAddresses
|
|
|
|
Provides information on known nodes of the network. `GetAddresses` is used to query another peer for known addresses.
|
|
|
|
### GetHeaders and Headers
|
|
|
|
`getheaders` allows a peer to query another about blockheaders. `headers` is sent in response to a `getheaders` message, containing information about block headers.
|
|
|
|
### GetBlocks and Block
|
|
|
|
Same as `getheaders` and `headers`, but the response comes one block at the time.
|
|
|
|
### Transaction
|
|
|
|
Message that contains a transaction.
|