Class

Blockchain

Blockchain()

Constructor

# new Blockchain()

View Source methods/blockchain/blockchain.ts, line 2

Methods

# clearMempool() → {Promise.<string>}

Removes all transaction from the mempool

View Source methods/blockchain/blockchain.ts, line 315

Mempool cleared

Promise.<string>

# decodeBlock(params) → {Promisee.<DecodeBlockResponse>}

Decode block by the blockhex

Parameters:
Name Type Description
params
blockhex string

The block hex

View Source methods/blockchain/blockchain.ts, line 365

Promisee.<DecodeBlockResponse>

# getBestBlockHash() → {Promise.<string>}

Returns the hash of the best (tip) block in the longest blockchain.

View Source methods/blockchain/blockchain.ts, line 338

The block hash hex encoded

Promise.<string>

# getBlock(params) → {Promise.<(GetBlockVerbosity0|GetBlockVerbosity1|GetBlockVerbosity2)>}

If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.

If verbosity is 1, returns an Object with information about block .

If verbosity is 2, returns an Object with information about block and information about each transaction.

Parameters:
Name Type Attributes Default Description
params
blockhash string

The block hash

verbosity number | boolean <optional>
1

Default = 1. 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data

View Source methods/blockchain/blockchain.ts, line 357

# getBlockchainInfo() → {Promise.<GetBlockchainInfoResponse>}

Returns an object containing various state info regarding blockchain processing.

View Source methods/blockchain/blockchain.ts, line 323

Promise.<GetBlockchainInfoResponse>
Example
client.blockchain.getBlockchainInfo()

# getBlockCount() → {Promise.<number>}

Returns the number of blocks in the longest blockchain.

View Source methods/blockchain/blockchain.ts, line 344

The current block count

Promise.<number>

# getBlockDeltas(params) → {Promise.<GetBlockDeltasResponse>}

Get Block Deltas

Parameters:
Name Type Description
params
blockhash string

The block hash

View Source methods/blockchain/blockchain.ts, line 373

Promise.<GetBlockDeltasResponse>

# getBlockHash(params) → {Promise.<string>}

Returns hash of block in best-block-chain at height provided.

Parameters:
Name Type Description
params
height number

The height index

View Source methods/blockchain/blockchain.ts, line 391

The block hash

Promise.<string>

# getBlockHashes(params) → {Promise.<(GetBlockHashesResponse|GetBlockHashesResponseLogicalTimes)>}

Returns array of hashes of blocks within the timestamp range provided.

Parameters:
Name Type Description
params
high number

The newer block timestamp

low number

The older block timestamp

options OptionsRequest

View Source methods/blockchain/blockchain.ts, line 99

# getBlockHeader(params) → {Promise.<(GetBlockHeaderResponseFalse|GetBlockHeaderResponseTrue)>}

If verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.

If verbose is true, returns an Object with information about blockheader .

Parameters:
Name Type Attributes Default Description
params
hash string

The block hash

verbose boolean <optional>
true

Default = true. True for a json object, false for the hex encoded data

View Source methods/blockchain/blockchain.ts, line 402

# getChainTips() → {Promise.<Array.<GetChainTipsResponse>>}

Return information about all known tips in the block tree, including the main chain as well as orphaned branches. * @param params

View Source methods/blockchain/blockchain.ts, line 408

Promise.<Array.<GetChainTipsResponse>>

# getChainTxStats(params) → {Promise.<GetChainTxStatsResponse>}

Compute statistics about the total number and rate of transactions in the chain.

Parameters:
Name Type Attributes Description
params
nblocks number <optional>

Size of the window in number of blocks (default: one month).

blockhash string <optional>

The hash of the block that ends the window.

View Source methods/blockchain/blockchain.ts, line 332

Promise.<GetChainTxStatsResponse>

# getDifficulty() → {Promise.<number>}

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

View Source methods/blockchain/blockchain.ts, line 414

The proof-of-work difficulty as a multiple of the minimum difficulty.

Promise.<number>

# getMempoolAncestors(params) → {Promise.<(Array.<GetMempoolAncestorsResponseVerboseFalse>|GetMempoolAncestorsResponseVerboseTrue)>}

If txid is in the mempool, returns all in-mempool ancestors.

Parameters:
Name Type Attributes Default Description
params
txid string

The transaction id (must be in mempool)

verbose boolean <optional>
false

Default = false. True for a json object, false for array of transaction ids

View Source methods/blockchain/blockchain.ts, line 423

Array of transactions or ids of an in-mempool ancestor transactions

# getMempoolDescendants(params) → {Promise.<(Array.<GetMempoolDescendantsResponseVerboseFalse>|GetMempoolDescendantsResponseVerboseTrue)>}

If txid is in the mempool, returns all in-mempool descendants.

Parameters:
Name Type Attributes Default Description
params
txid string

The transaction id (must be in mempool)

verbose boolean <optional>
false

Default = false. True for a json object, false for array of transaction ids

View Source methods/blockchain/blockchain.ts, line 432

# getMempoolEntry(params) → {Promise.<Array.<string>>}

Returns mempool data for given transaction

Parameters:
Name Type Description
params
txid string

The transaction id (must be in mempool)

View Source methods/blockchain/blockchain.ts, line 440

Promise.<Array.<string>>

# getMempoolInfo() → {Promise.<GetMempoolInfoResponse>}

Returns details on the active state of the TX memory pool.

View Source methods/blockchain/blockchain.ts, line 446

Promise.<GetMempoolInfoResponse>

# getRawMempool(params) → {Promise.<(GetRawMempoolResponseVerboseFalse|GetRawMempoolResponseVerboseTrue)>}

Returns all transaction ids in memory pool as a json array of string transaction ids.

Hint: use getmempoolentry to fetch a specific transaction from the mempool.

Parameters:
Name Type Attributes Description
params
verbose boolean <optional>

Default = false. True for a json object, false for array of transaction ids

View Source methods/blockchain/blockchain.ts, line 456

# GetTxOut(params) → {Promise}

Returns details about an unspent transaction output.

Parameters:
Name Type Attributes Description
params
txid string

The transaction id

n number

vout number

include_mempool boolean <optional>

Whether to include the mempool. Default: true. Note that an unspent output that is spent in the mempool won't appear.

View Source methods/blockchain/blockchain.ts, line 466

Promise

# getTxOutSetInfo() → {Promise.<GetTxOutResponse>}

Returns statistics about the unspent transaction output set.

Note this call may take some time.

View Source methods/blockchain/blockchain.ts, line 474

Promise.<GetTxOutResponse>

# invalidateBlock(params) → {Promise.<null>}

Permanently marks a block as invalid, as if it violated a consensus rule.

Parameters:
Name Type Description
params
blockhash string

The hash of the block to mark as invalid

View Source methods/blockchain/blockchain.ts, line 517

Promise.<null>

# preciousBlock(params) → {Promise.<null>}

Treats a block as if it were received before others with the same work.

A later preciousblock call can override the effect of an earlier one.

The effects of preciousblock are not retained across restarts

Parameters:
Name Type Description
params
blockhash string

The hash of the block to mark as precious

View Source methods/blockchain/blockchain.ts, line 509

Promise.<null>

# pruneBlockchain(params) → {Promise.<number>}

Prune the blockchain

Parameters:
Name Type Description
params
height number

The block height to prune up to. May be set to a discrete height, or a unix timestamp to prune blocks whose block time is at least 2 hours older than the provided timestamp.

View Source methods/blockchain/blockchain.ts, line 482

Height of the last block pruned.

Promise.<number>

# reconsiderBlock(params) → {Promise.<null>}

Removes invalidity status of a block and its descendants, reconsider them for activation.

This can be used to undo the effects of invalidateblock.

Parameters:
Name Type Description
params
blockhash string

The hash of the block to reconsider

View Source methods/blockchain/blockchain.ts, line 527

Promise.<null>

# saveMempool() → {Promise.<null>}

Dumps the mempool to disk.

View Source methods/blockchain/blockchain.ts, line 488

Promise.<null>

# verifyChain(params) → {Promise.<boolean>}

Verifies blockchain database.

Parameters:
Name Type Attributes Description
params
checklevel number <optional>

0-4, default=" + strprintf("%d", nCheckLevel) + ") How thorough the block verification is.

nblocks number <optional>

Default = " + strprintf("%d", nCheckDepth) + ", 0=all) The number of blocks to check.

View Source methods/blockchain/blockchain.ts, line 497

Verified or not

Promise.<boolean>

# waitForBlock(params) → {Promise.<WaitForBlockResponse>}

Waits for a specific new block and returns useful info about it.

Returns the current block on timeout or exit.

Parameters:
Name Type Attributes Default Description
params
blockhash string

Block hash to wait for.

timeout number <optional>
0

Default = 0. Time in milliseconds to wait for a response. 0 indicates no timeout.

View Source methods/blockchain/blockchain.ts, line 548

Promise.<WaitForBlockResponse>

# waitForBlockHeight(params) → {Promise.<WaitForBlockHeightResponse>}

Waits for (at least) block height and returns the height and hash of the current tip.

Returns the current block on timeout or exit.

Parameters:
Name Type Attributes Default Description
params
height number

Block height to wait for (int)

timeout number <optional>
0

Default = 0. Time in milliseconds to wait for a response. 0 indicates no timeout.

View Source methods/blockchain/blockchain.ts, line 559

Promise.<WaitForBlockHeightResponse>

# waitForNewBlock(params) → {Promise.<WaitForNewBlockResponse>}

Waits for a specific new block and returns useful info about it.

Returns the current block on timeout or exit.

Parameters:
Name Type Attributes Default Description
params
timeout number <optional>
0

Default = 0. Time in milliseconds to wait for a response. 0 indicates no timeout.

View Source methods/blockchain/blockchain.ts, line 537

Promise.<WaitForNewBlockResponse>