Files
specification/protocol/network/messages/version.md
T

137 lines
7.5 KiB
Markdown
Raw Normal View History

2019-12-09 18:24:44 -05:00
2019-12-03 16:12:55 -05:00
# Handshake: Version (“version”)
2019-12-03 16:11:19 -05:00
2019-12-06 10:33:09 -05:00
The version message is a part of the node connection [handshake](/protocol/network/node-handshake) and indicates various connection settings, networking information, and the services provided by the sending node (see Services Bitmask [below](#services-bitmask)).
2019-12-05 11:08:18 -05:00
2019-12-05 13:20:52 -05:00
The node connection is not considered established until both nodes have sent and received both a <code>version</code> and [verack](/protocol/network/messages/verack) message.
2019-12-05 12:52:18 -05:00
2019-12-05 11:08:18 -05:00
## Message Format
2019-12-05 11:27:44 -05:00
| Field | Length | Format | Description |
|--|--|--|--|
2019-12-11 16:15:00 -05:00
| version number | 4 bytes | unsigned integer<sup>[(LE)](/protocol/misc/endian/little)</sup> | The version number supported by the sending node. |
2019-12-05 14:32:12 -05:00
| services | 8 bytes | bitmask<sup>[(LE)](/protocol/misc/endian/little)</sup> | An indication of the services supported by the sending node. See Services Bitmask section below. |
| timestamp | 8 bytes | unix timestamp<sup>[(LE)](/protocol/misc/endian/little)</sup> | The time the message was generated on the sending node. |
| remote address | 26 bytes | [network address](/protocol/formats/network-address) | The network address of the remote node. <p>_NOTE: this does not contain the timestamp normally included with network addresses._</p> |
| local address | 26 bytes | [network address](/protocol/formats/network-address) | The network address of the sending node. <p>_NOTE: this does not contain the timestamp normally included with network addresses._</p> |
| nonce | 8 bytes | bytes<sup>[(LE)](/protocol/misc/endian/little)</sup> | Random nonce for the connection, used to detect connections to self. |
| user agent | variable | [variable length string](/protocol/formats/variable-length-string) | A user agent string identifying the node implementation. |
| block height | 4 bytes | unsigned integer<sup>[(LE)](/protocol/misc/endian/little)</sup> | The height of the block with the highest height known to the sending node. |
2019-12-12 14:12:14 -05:00
| relay flag | 1 byte | boolean | Indicates whether the sending node would like all broadcasted transactions relayed to it. See [BIP-37](/protocol/forks/bip-0037). This flag is sometimes referred to as "fRelay". |
Note: appending extra data after the `relay flag` is ignored. Historically, extra data after the `relay flag` would sometimes result in the connection being banned, although this is no longer standard behavior.
2019-12-05 11:27:44 -05:00
2019-12-11 16:15:00 -05:00
## Version Number
2019-12-06 11:08:36 -05:00
2019-12-09 18:24:44 -05:00
The most recent version of the network protocol is `70015`. The `version` value often correlates to new behavior, parsing formats, and available services; for more details review the network protocol's [version history](/history/protocol-version). Nodes should use `version` and the `services` bitmask to determine if the node should accept the incoming connection. Related: [node connection handshake](/protocol/network/node-handshake).
2019-12-06 11:08:36 -05:00
2019-12-03 16:11:19 -05:00
## Services Bitmask
The services field is an 8 byte little-endian-serialized bitfield that described peer capabilities. The following capabilities are defined, by bit position:
### Standard Services
* 0: NODE_NETWORK
The node is capable of serving the complete block chain. It is currently set by all full nodes, and is unset by SPV clients or other peers that just want network services but don't provide them.
* 2: NODE_BLOOM
The node is capable and willing to handle bloom-filtered connections.
* 3: NODE_WITNESS
Indicates that a node can be asked for blocks and transactions including witness data.
*Bitcoin Cash nodes do not have witness data so this flag should be ignored on receipt and set to 0 when sent*
* 5: NODE_BITCOIN_CASH
The node supports the BCH chain. This is intended to be just a temporary service bit until the BTC/BCH fork actually happens.
2019-12-03 16:31:23 -05:00
* 24-31: Reserved for experimental changes
These bits are reserved for temporary experiments. Just pick a bit that isn't getting used, or one not being used much, and notify the community. Remember that service bits are just unauthenticated advertisements, so your code must be robust against collisions and other cases where nodes may be advertising a service they do not actually support.
2019-12-11 17:05:01 -05:00
## Example Serialized Data
2019-12-12 15:36:19 -05:00
Net Magic<sup>[(BE)](/protocol/misc/endian/little)</sup>
2019-12-11 17:05:01 -05:00
`E3E1F3E8`
Command String ("version")<sup>[(BE)](/protocol/misc/endian/big)</sup>
`76657273696F6E0000000000`
Payload Byte Count<sup>[(LE)](/protocol/misc/endian/little)</sup>
`6A000000`
Payload Checksum<sup>[(LE)](/protocol/network/messages/message-checksum)</sup>
`8FC7709F`
Version Number
`7F110100`
Node Features
`3500000000000000`
2019-12-11 17:19:00 -05:00
**Timestamp** *("1576101548")*
2019-12-11 17:05:01 -05:00
`AC66F15D00000000`
2019-12-11 17:19:00 -05:00
**Remote Address** *("5.6.7.8:8333")*
2019-12-11 17:05:01 -05:00
`240000000000000000000000000000000000FFFF0506070820`
2019-12-11 17:19:00 -05:00
**Local Address** *("1.2.3.4:8333")*
2019-12-11 17:05:01 -05:00
`8D350000000000000000000000000000000000FFFF01020304`
2019-12-11 17:19:00 -05:00
**Nonce**
2019-12-11 17:05:01 -05:00
`208D00F0E6495B9B`
2019-12-11 17:19:00 -05:00
**User Agent** *("/Bitcoin Node:1.2.3/")*
2019-12-11 17:05:01 -05:00
`4350142F426974636F696E204E6F64653A312E322E332F`
2019-12-11 17:19:00 -05:00
**Current Block Height** *("612918L")*
2019-12-11 17:05:01 -05:00
`365A0900`
2019-12-11 17:19:00 -05:00
**Relay Transactions Flag** *("true")*
2019-12-11 17:05:01 -05:00
`01`
2019-12-03 16:16:42 -05:00
### Node Specific Messages
2019-12-05 13:31:42 -05:00
#### Bitcoin ABC
2019-12-18 11:45:22 -05:00
* 10: NODE_NETWORK_LIMITED <img src="/_static_/images/warning.png" />
2019-12-05 14:48:23 -05:00
This means the same as NODE_NETWORK with the limitation of only serving a small subset of the blockchain. See [BIP159](/protocol/forks/bip-0159) for details on how this is implemented.
2019-12-05 13:31:42 -05:00
2019-12-03 16:16:42 -05:00
#### Bitcoin Unlimited
2019-12-18 11:45:22 -05:00
* 4: NODE_XTHIN <img src="/_static_/images/warning.png" />
2019-12-03 16:11:19 -05:00
The node supports Xtreme Thinblocks
2019-12-18 11:45:22 -05:00
* 6: NODE_GRAPHENE <img src="/_static_/images/warning.png" />
2019-12-03 16:11:19 -05:00
The node supports Graphene blocks. If this is turned off then the node will not service graphene requests nor make graphene requests.
2019-12-18 11:45:22 -05:00
* 10: NODE_NETWORK_LIMITED <img src="/_static_/images/warning.png" />
2019-12-05 14:48:23 -05:00
This means the same as NODE_NETWORK with the limitation of only serving a small subset of the blockchain. See [BIP159](/protocol/forks/bip-0159) for details on how this is implemented.
2019-12-05 13:31:42 -05:00
2019-12-03 16:31:23 -05:00
#### Bitcoin Verde
2019-12-18 11:45:22 -05:00
* 7: BLOCKCHAIN_INDEX_ENABLED <img src="/_static_/images/warning.png" />
2019-12-03 16:31:23 -05:00
Indicates that the node is an indexing node and supports returning information custom to the requesting user's addresses.
2019-12-18 11:45:22 -05:00
* 8: SLP_INDEX_ENABLED <img src="/_static_/images/warning.png" />
2019-12-03 16:31:23 -05:00
Indicates that the node tracks Simple Ledger Protocol validity and supports returning this status for individual transactions.
2019-12-05 11:08:18 -05:00
#### Other Proposed/Previously Used Service Flags
2019-12-18 11:45:22 -05:00
* 1: NODE_GETUTXO <img src="/_static_/images/warning.png" />
2019-12-05 14:48:23 -05:00
The node is capable of responding to the getutxo protocol request. See [BIP 64](/protocol/forks/bip-0064) for details on how this is implemented. _Was previously supported by Bitcoin XT only._
2019-12-03 16:16:42 -05:00
2019-12-18 11:45:22 -05:00
* 7: NODE_WEAKBLOCKS <img src="/_static_/images/warning.png" />
2019-12-03 16:11:19 -05:00
The node supports Storm weak block (currently no node supports these in production, so this is a placeholder).
2019-12-18 11:45:22 -05:00
* 8: NODE_CF <img src="/_static_/images/warning.png" />
2019-12-05 14:48:23 -05:00
Indicates the node is capable of serving compact block filters to SPV clients, AKA the "Neutrino" protocol ([BIP157](/protocol/forks/bip-0157), and [BIP158](/protocol/forks/bip-0158)).
2019-12-03 16:11:19 -05:00
2019-12-05 11:08:18 -05:00
## Node-Specific Behavior
Generally, though node implementations may be aware of services they do not provide, they generally ignore those they don't supported. Any notable deviations from that behavior are documented below.
### Bitcoin ABC
2019-12-12 14:12:14 -05:00
Bitcoin ABC nodes may, once they have reached their maximum number of peers, selectively disconnect from nodes that do not supported "desired services", though it appears currently this just <code>NODE_NETWORK</code> and/or <code>NODE_NETWORK_LIMITED</code>. That is, it may prefer nodes that store and serve blocks.
### Bitcoin Verde
Bitcoin Verde nodes ignores any data after the `relay flag` field.