Class: BlockTemplate

mining.BlockTemplate(options)

Block Template

Constructor

new BlockTemplate(options)

Create a block template.

Parameters:
Name Type Description
options Object
Source:

Methods

(static) fromOptions(options) → {BlockTemplate}

Instantiate block template from options.

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

addAirdrop(proof)

Add a claim to the template.

Parameters:
Name Type Description
proof AirdropProof
Source:

addClaim(claim, data)

Add a claim to the template.

Parameters:
Name Type Description
claim Claim
data Object
Source:

addTX(tx, view)

Add a transaction to the template.

Parameters:
Name Type Description
tx TX
view CoinView
Source:

commit(proof) → {Block}

Create block from calculated proof.

Parameters:
Name Type Description
proof BlockProof
Source:
Returns:
Type
Block

createCoinbase() → {TX}

Initialize the default coinbase.

Source:
Returns:
Type
TX

(private) fromOptions(options) → {BlockTemplate}

Inject properties from options.

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

getDifficulty() → {Number}

Calculate the target difficulty.

Source:
Returns:
Type
Number

getHeader(extraNonce, time, nonce) → {Buffer}

Create raw block header with given parameters.

Parameters:
Name Type Description
extraNonce Buffer
time Number
nonce Number
Source:
Returns:
Type
Buffer

getProof(nonce1, nonce2, time, nonce) → {BlockProof}

Calculate proof with given parameters.

Parameters:
Name Type Description
nonce1 Number
nonce2 Number
time Number
nonce Buffer
Source:
Returns:
Type
BlockProof

getReward() → {Amount}

Calculate the block reward.

Source:
Returns:
Type
Amount

pushTX(tx, viewnullable)

Add a transaction to the template (less verification than addTX).

Parameters:
Name Type Attributes Description
tx TX
view CoinView <nullable>
Source:

refresh()

Refresh the coinbase and merkle tree.

Source:

setAddress(address)

Set the reward output address and refresh.

Parameters:
Name Type Description
address Address
Source:

setBits(bits)

Set the target (bits).

Parameters:
Name Type Description
bits Number
Source:

setTarget(target)

Set the target (uint256le).

Parameters:
Name Type Description
target Buffer
Source:

toBlock() → {Block}

Quick and dirty way to get a block object (most likely to be an invalid one).

Source:
Returns:
Type
Block

toCoinbase() → {TX}

Quick and dirty way to get a coinbase tx object.

Source:
Returns:
Type
TX