getchaintips

How to use it

// yarn add @tatumio/tatum

import { TatumSDK, BitcoinCash, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<BitcoinCash>({network: Network.BITCOIN_CASH})

const result = await tatum.rpc.getChainTips()

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

getchaintips is a method that returns information about all known tips in the block tree. This method is useful for identifying and analyzing potential forks or alternative chains in the network. It can be used to monitor the health and status of the network or to investigate discrepancies in blockchain data.

Parameters

This method does not require any parameters.

Return Object

The return object is an array of JSON objects, with each object representing a chain tip. The fields in each object are:

  • height: The height of the chain tip in the block chain.

  • hash: The hash of the block corresponding to the chain tip.

  • branchlen: The length of the branch connected to the main chain.

  • status: The status of the chain tip, which can be one of the following values:

    • active: The tip is part of the main chain.

    • valid-fork: The tip is part of a valid but inactive fork.

    • valid-headers: The tip is part of a valid fork but with incomplete block data.

    • headers-only: The tip is a fork with valid headers but incomplete block data and an invalid parent block.

    • invalid: The tip is part of an invalid fork.

    • unknown: The tip has an unknown validation state.

JSON Examples

Request example:

{
  "jsonrpc": "2.0",
  "method": "getchaintips",
  "id": 1
}

Response example:

{
    "result": [
        {
            "height": 787067,
            "hash": "0000000000000000000348522f4f24304bfcadece8b34c0696faa4f87ec4fdc4",
            "branchlen": 0,
            "status": "active"
        },
        {
            "height": 784121,
            "hash": "000000000000000000046a2698233ed93bb5e74ba7d2146a68ddb0c2504c980d",
            "branchlen": 1,
            "status": "invalid"
        },
        {
            "height": 783830,
            "hash": "0000000000000000000366d2c12772a350f507879a5325203424e58ec440249b",
            "branchlen": 1,
            "status": "valid-headers"
        },
        {
            "height": 783478,
            "hash": "0000000000000000000446f7d3093688ae697386fed3f52a63812678ea6b251d",