MerkleBlock class

A merkle block represents a partial/filtered view of the transactions in a block.

Because of the way that merkle tree data structures work, it is possible to have a valid data structure which is only partially populated, and to have all the remaining elements in the merkle tree be internally consistent.

Data layout of a Merkle Block

size description
80 bytes block header - The block header in the format described in BlockHeader.
4 bytes transaction count - The number of transactions in the block (including ones that don’t match the filter)
Varies hash count - The number of hashes in the following field.
Varies hashes - One or more hashes of both transactions and merkle nodes in internal byte order. Each hash is 32 bytes.
Varies flag byte count - The number of flag bytes in the following field.
Varies flags - A sequence of bits packed eight in a byte with the least significant bit first. May be padded to the nearest byte boundary but must not contain any more bits than that. Used to assign the hashes to particular nodes in the merkle tree as described below.

Constructors

MerkleBlock.fromBuffer(List<int> blockbuf)
Construct a Merkle Block from a serialized byte array
MerkleBlock.fromJSON(String blockJSON)
Construct a Merkle Block from a json string. See MerkleBlock.fromObject()
MerkleBlock.fromObject(Map<String, dynamic> blockObject)
Construct a Merkleblock from the provided structured data object.

Properties

buffer List<int>
Returns the merkle block serialized as a byte array
no setter
flags List?
Returns the bit-packed data structure showing locations of hashes in the tree
no setter
hashCode int
The hash code for this object.
no setterinherited
hashes List?
A list of all the hashes in the merkle block
no setter
Returns the block header
no setter
numTransactions int?
Total transaction count for the block. Includes transactions not in the block.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

filteredTxsHash() List<String>
hasTransaction(Transaction tx) bool
Returns true if the Merkle Tree contains the transaction
hasTransactionId(String txId) bool
Returns true if the Merkle tree contains the transaction identified by ID
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJSON() String
Serializes the Merkle Block to a JSON string
toObject() Map<String, dynamic>
Renders the Merkle Block as a structured data object
toString() String
A string representation of this object.
inherited
validMerkleTree() bool
Returns true if the Merkle tree remains consistent in spite of missing transactions.

Operators

operator ==(Object other) bool
The equality operator.
inherited