Class: AbstractBlock

primitives.AbstractBlock

(abstract) new AbstractBlock()

The class which all block-like objects inherit from.

Properties:
Name Type Description
version Number

Block version. Note that Bcoin reads versions as unsigned despite them being signed on the protocol level. This number will never be negative.

prevBlock Hash

Previous block hash.

merkleRoot Hash

Merkle root hash.

ts Number

Timestamp.

bits Number
nonce Number
totalTX Number

Transaction count.

txs Array:.<TX:>

Transaction vector.

rhash ReversedHash

Reversed block hash (uint256le).

Source:

Methods

_refresh(allnullable)

Clear any cached values (abstract).

Parameters:
Name Type Attributes Description
all Boolean <nullable>

Clear transactions.

Source:

(private) _verify(retnullable) → {Boolean}

Verify the block.

Parameters:
Name Type Attributes Description
ret Object <nullable>

Return object, may be set with properties reason and score.

Source:
Returns:
Type
Boolean

(private) _verifyHeaders(retnullable) → {Boolean}

Verify the block headers (called by verify() in all objects which inherit from AbstractBlock).

Parameters:
Name Type Attributes Description
ret Object <nullable>

Return object, may be set with properties reason and score.

Source:
Returns:
Type
Boolean

abbr() → {Buffer}

Serialize the block headers.

Source:
Returns:
Type
Buffer

hash(encnullable) → {Hash|Buffer}

Hash the block headers.

Parameters:
Name Type Attributes Description
enc String <nullable>

Can be 'hex' or null.

Source:
Returns:

hash

Type
Hash | Buffer

parseAbbr(br)

Parse the block headers.

Parameters:
Name Type Description
br BufferReader
Source:

(private) parseJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) parseOptions(options)

Inject properties from options object.

Parameters:
Name Type Description
options NakedBlock
Source:

refresh(allnullable)

Clear any cached values.

Parameters:
Name Type Attributes Description
all Boolean <nullable>

Clear transactions.

Source:

rhash() → {Hash}

Get little-endian block hash.

Source:
Returns:
Type
Hash

toInv() → {InvItem}

Convert the block to an inv item.

Source:
Returns:
Type
InvItem

verify(retnullable) → {Boolean}

Verify the block.

Parameters:
Name Type Attributes Description
ret Object <nullable>

Return object, may be set with properties reason and score.

Source:
Returns:
Type
Boolean

verifyHeaders(retnullable) → {Boolean}

Verify the block headers (called by verify() in all objects which inherit from AbstractBlock).

Parameters:
Name Type Attributes Description
ret Object <nullable>

Return object, may be set with properties reason and score.

Source:
Returns:
Type
Boolean

verifyPOW() → {Boolean}

Verify proof-of-work.

Source:
Returns:
Type
Boolean

writeAbbr(bw)

Serialize the block headers.

Parameters:
Name Type Description
bw BufferWriter
Source: