Class: BlockTemplate

mining.BlockTemplate(optionsopt)

Block Template

Constructor

new BlockTemplate(optionsopt)

Create a block template.

Parameters:
Name Type Attributes Description
options Object <optional>
Source:

Methods

(static) fromOptions(options) → {BlockTemplate}

Instantiate block template from options.

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

addAirdrop(proof) → {Boolean}

Add a claim to the template.

Parameters:
Name Type Description
proof AirdropProof
Source:
Returns:
Type
Boolean

addClaim(claim, data) → {Boolean}

Add a claim to the template.

Parameters:
Name Type Description
claim Claim
data Object
Source:
Returns:
Type
Boolean

addTX(tx, view) → {Boolean}

Add a transaction to the template.

Parameters:
Name Type Description
tx TX
view CoinView
Source:
Returns:
Type
Boolean

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

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(nonce, time, extraNonce, mask) → {Buffer}

Create raw block header with given parameters.

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

getProof(nonce, time, extraNonce, mask) → {BlockProof}

Calculate proof with given parameters.

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

getReward() → {AmountValue}

Calculate the block reward.

Source:
Returns:
Type
AmountValue

pushTX(tx, viewopt, nullable) → {Boolean}

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

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

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