Class: MerkleBlock

primitives~MerkleBlock(options)

Merkle Block Represents a merkle (filtered) block.

Constructor

new MerkleBlock(options)

Create a merkle block.

Extends:
  • AbstractBlock
Parameters:
Name Type Description
options Object
Source:

Extends

  • AbstractBlock

Methods

(static) fromBlock(block, filter) → {MerkleBlock}

Create a merkleblock from a Block object, passing it through a filter first. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
filter Bloom
Source:
Returns:
Type
MerkleBlock

(static) fromExtendedRaw(data, encnullable) → {MerkleBlock}

Instantiate a merkleblock with transactions from a serialized data.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
MerkleBlock

(static) fromExtendedReader(br) → {MerkleBlock}

Instantiate a merkleblock with transactions from a buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
MerkleBlock

(static) fromHashes(block, hashes) → {MerkleBlock}

Create a merkleblock from an array of txids. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
hashes Array.<Hash>
Source:
Returns:
Type
MerkleBlock

(static) fromJSON(json) → {MerkleBlock}

Instantiate a merkle block from a jsonified block object.

Parameters:
Name Type Description
json Object

The jsonified block object.

Source:
Returns:
Type
MerkleBlock

(static) fromMatches(block, matches) → {MerkleBlock}

Create a merkleblock from an array of matches. This will build the partial merkle tree.

Parameters:
Name Type Description
block Block
matches Array.<Number>
Source:
Returns:
Type
MerkleBlock

(static) fromOptions(options) → {MerkleBlock}

Instantiate merkle block from options object.

Parameters:
Name Type Description
options Object
Source:
Returns:
Type
MerkleBlock

(static) fromRaw(data, encnullable) → {MerkleBlock}

Instantiate a merkleblock from a serialized data.

Parameters:
Name Type Attributes Description
data Buffer
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
MerkleBlock

(static) fromReader(br) → {MerkleBlock}

Instantiate a merkleblock from a buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:
Returns:
Type
MerkleBlock

(static) isMerkleBlock(obj) → {Boolean}

Test whether an object is a MerkleBlock.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(private) checkBody() → {Array}

Verify the partial merkletree.

Source:
Returns:

[valid, reason, score]

Type
Array

(private) extractTree() → {Object}

Extract the matches from partial merkle tree and calculate merkle root.

Source:
Returns:
Type
Object

format(view, height) → {Object}

Inspect the block and return a more user-friendly representation of the data.

Parameters:
Name Type Description
view CoinView
height Number
Source:
Returns:
Type
Object

(private) fromExtendedRaw(data)

Inject properties with transactions from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(private) fromExtendedReader(br)

Inject properties with transactions from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options Object
Source:

(private) fromRaw(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(private) fromReader(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br BufferReader
Source:

getCoinbaseHeight() → {Number}

Extract the coinbase height (always -1).

Source:
Returns:
Type
Number

getExtendedSize() → {Number}

Get merkleblock size with transactions.

Source:
Returns:

Size.

Type
Number

getJSON(network, view, height) → {Object}

Convert the block to an object suitable for JSON serialization. Note that the hashes will be reversed to abide by bitcoind's legacy of little-endian uint256s.

Parameters:
Name Type Description
network Network
view CoinView
height Number
Source:
Returns:
Type
Object

getSize() → {Number}

Get merkleblock size.

Source:
Returns:

Size.

Type
Number

getTree() → {Object}

Extract the matches from partial merkle tree and calculate merkle root.

Source:
Returns:
Type
Object

hasTX(hash) → {Boolean}

Test the block's matched transaction vector against a hash.

Parameters:
Name Type Description
hash Hash
Source:
Returns:
Type
Boolean

indexOf(hash) → {Number}

Test the block's matched transaction vector against a hash.

Parameters:
Name Type Description
hash Hash
Source:
Returns:

Index.

Type
Number

inspectSymbol() → {Object}

Inspect the block and return a more user-friendly representation of the data.

Source:
Returns:
Type
Object

refresh(allnullable)

Clear any cached values.

Parameters:
Name Type Attributes Description
all Boolean <nullable>

Clear transactions.

Source:

toExtendedRaw() → {Buffer}

Serialize the merkleblock with transactions.

Source:
Returns:
Type
Buffer

toExtendedWriter(bw)

Write the merkleblock to a buffer writer with transactions.

Parameters:
Name Type Description
bw BufferWriter
Source:

toHeaders() → {Headers}

Convert the block to a headers object.

Source:
Returns:
Type
Headers

toJSON() → {Object}

Convert the block to an object suitable for JSON serialization.

Source:
Returns:
Type
Object

toRaw(encnullable) → {Buffer|String}

Serialize the merkleblock.

Parameters:
Name Type Attributes Description
enc String <nullable>

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Buffer | String

toWriter(bw)

Write the merkleblock to a buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source:

(private) verifyBody() → {Boolean}

Verify the partial merkletree.

Source:
Returns:
Type
Boolean