Implements an Explorer Interface for an Esplora server.

Hierarchy

  • EsploraExplorer

Implements

Constructors

  • Parameters

    • params: {
          url?: string;
          irrevConfThresh?: number;
          maxTxPerScriptPubKey?: number;
      } = {}
      • Optional url?: string

        Esplora's API url. Defaults to blockstream.info if service = ESPLORA.

      • Optional irrevConfThresh?: number
      • Optional maxTxPerScriptPubKey?: number

    Returns EsploraExplorer

Properties

#irrevConfThresh: number
#BLOCK_HEIGHT_CACHE_TIME: number = 3
#cachedTipBlockHeight: number = 0
#tipBlockHeightCacheTime: number = 0
#url: string
#maxTxPerScriptPubKey: number
#blockStatusMap: Map<number, BlockStatus> = ...

Methods

  • Parameters

    • __namedParameters: {
          address?: string;
          scriptHash?: string;
      }
      • Optional address?: string
      • Optional scriptHash?: string

    Returns Promise<{
        balance: number;
        txCount: number;
        unconfirmedBalance: number;
        unconfirmedTxCount: number;
    }>

  • Parameters

    • address: string

    Returns Promise<{
        balance: number;
        txCount: number;
        unconfirmedBalance: number;
        unconfirmedTxCount: number;
    }>

  • Parameters

    • scriptHash: string

    Returns Promise<{
        balance: number;
        txCount: number;
        unconfirmedBalance: number;
        unconfirmedTxCount: number;
    }>

  • Returns the height of the last block. It does not fetch it, unless either: fetched before more than #BLOCK_HEIGHT_CACHE_TIME ago the #cachedTipBlockHeight is behind the blockHeight passed as a param

    Parameters

    • Optional blockHeight: number

    Returns Promise<number>

  • Fetches the transaction history for a given address or script hash from an Esplora server. See interface.ts

    Parameters

    • __namedParameters: {
          address?: string;
          scriptHash?: string;
      }
      • Optional address?: string
      • Optional scriptHash?: string

    Returns Promise<{
        txId: string;
        blockHeight: number;
        irreversible: boolean;
    }[]>

  • Fetches raw transaction data for a given transaction ID from an Esplora server.

    Parameters

    • txId: string

      The transaction ID to fetch data for.

    Returns Promise<string>

    A promise that resolves to the raw transaction data as a string.

  • Push a raw Bitcoin transaction to the network.

    Parameters

    • txHex: string

      A raw Bitcoin transaction in hexadecimal string format.

    Returns Promise<string>

    The transaction ID (txId) if the transaction was broadcasted successfully.

    Async

    Throws

    If the transaction is invalid or fails to be broadcasted.