merkletree — A NEO specific Merkle Patricia Tree implementation

This is a pure python implementation of a Merkle Patricia Tree that works on and returns hashes using NEOs UInt256 types.

For more information on the usage within the NEO system see their website.

class neo3.core.cryptography.merkletree.MerkleTree(hashes)

Bases: object

Parameters

hashes (List[UInt256]) – the list of hashes to build the tree from.

Raises

ValueError – if the hashes list is empty.

static compute_root(hashes)

Compute the Merkle root hash from a list of hashes.

Parameters

hashes (List[UInt256]) –

Raises

ValueError – if the hashes list is empty.

Return type

UInt256

to_hash_array()

Create a list of hashes the Merkle tree is build up from.

Note: does not include the Merkle root hash.

Return type

List[UInt256]