- Bitcoin & Blockchain/
- BCH Specification/
- Protocol Upgrades/
- P2P Network
- Connect Handshake
- Get Addrsses
- Send Compact CTL
- SPV Bloom Filter
- Strings Encoding
Bitcoin Cash Specification
Response: Merkle Block (“merkleblock”)
Provides a block header and partial merkle proof tree to show that the selected transaction hashes exist in the block.
Transactions are selected by honest servers if they match the bloom filter installed by the client. However, note that servers can omit transactions and this cannot be detected except by receiving a merkleblock message from an honest server.
All selected transactions are subsequently sent as separate tx messages. Due to multi-threading on the server, clients should not assume that these transaction messages directly follow the merkleblock message.
|block header||80 bytes||block header||The header of the block.|
|transaction count||4 bytes||unsigned integer(LE)||The number of transactions in the block.|
|filtered transaction count||variable||variable length integer||The number of transactions matching the client’s bloom filter.|
||bytes(LE)||The hashes of the full set of transactions in the block, in the the order they appear in the block (i.e. depth-first order with respect to the merkle tree).|
|flag byte count||variable||variable length integer||The number of flags bytes to follow.|
||bytes||Flag bits, collected into bytes (zero-padded to a full byte as necessary) indicating inclusion information with respect to traversal of the partial merkle tree of matches. See partial merkle tree flag bits.|
Partial Merkle Tree Flag Bits
The partial merkle tree flag bits effectively create a variable-width bitfield, indicating which transaction hashes from the block the merkleblock message pertains to actually matched the client’s bloom filter. If you picture the merkle tree root at the top, the flag bits represent a top-down yes/no approach to whether the a given branch (or leaf node) of the tree includes any matching transactions.
For full details, see BIP-37: Partial Merkle Branch Format.