Class: Headers

primitives~Headers(options)

Headers Represents block headers obtained from the network via headers.

Constructor

new Headers(options)

Create headers.

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

Extends

  • AbstractBlock

Methods

(static) fromBlock(block) → {Headers}

Convert the block to a headers object.

Parameters:
Name Type Description
block Block | MerkleBlock
Source:
Returns:
Type
Headers

(static) fromEntry(entry) → {Headers}

Instantiate headers from a chain entry.

Parameters:
Name Type Description
entry ChainEntry
Source:
Returns:
Type
Headers

(static) fromHead(data, encnullable) → {Headers}

Instantiate headers from serialized data.

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

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Headers

(static) fromJSON(json) → {Headers}

Instantiate a merkle block from a jsonified block object.

Parameters:
Name Type Description
json Object

The jsonified block object.

Source:
Returns:
Type
Headers

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

Instantiate headers from serialized data.

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

Encoding, can be 'hex' or null.

Source:
Returns:
Type
Headers

(static) fromReader(br) → {Headers}

Instantiate headers from buffer reader.

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

(static) isHeaders(obj) → {Boolean}

Test an object to see if it is a Headers object.

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

format(view, height) → {Object}

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

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

(private) fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Object
Source:

(private) fromRaw(data)

Inject properties from serialized data.

Parameters:
Name Type Description
data Buffer
Source:

(private) fromReader(data)

Inject properties from buffer reader.

Parameters:
Name Type Description
data Buffer
Source:

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 size of the headers.

Source:
Returns:
Type
Number

inspectSymbol() → {Object}

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

Source:
Returns:
Type
Object

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() → {Buffer|String}

Serialize the headers.

Source:
Returns:
Type
Buffer | String

toWriter(bw)

Serialize the headers to a buffer writer.

Parameters:
Name Type Description
bw BufferWriter
Source:

verifyBody() → {Boolean}

Perform non-contextual verification on the headers.

Source:
Returns:
Type
Boolean