@bitcoinerlab/explorer - v0.4.2
    Preparing search index...

    Interface Explorer

    interface Explorer {
        connect(): Promise<void>;
        isConnected(): Promise<boolean>;
        isClosed(): boolean;
        close(): void;
        fetchAddress(
            address: string,
        ): Promise<
            {
                balance: number;
                txCount: number;
                unconfirmedBalance: number;
                unconfirmedTxCount: number;
            },
        >;
        fetchScriptHash(
            scriptHash: string,
        ): Promise<
            {
                balance: number;
                txCount: number;
                unconfirmedBalance: number;
                unconfirmedTxCount: number;
            },
        >;
        fetchTxHistory(
            params: { address?: string; scriptHash?: string },
        ): Promise<{ txId: string; blockHeight: number; irreversible: boolean }[]>;
        fetchTx(txId: string): Promise<string>;
        fetchFeeEstimates(): Promise<Record<string, number>>;
        fetchBlockStatus(blockHeight: number): Promise<BlockStatus | undefined>;
        fetchBlockHeight(): Promise<number>;
        push(txHex: string): Promise<string>;
    }

    Implemented by

    Index

    Methods

    • Connect to the server.

      Returns Promise<void>

    • Checks if the connection to the server is alive.

      For the Electrum client, this method directly checks the server's availability by sending a ping. It returns true if the ping is successful, otherwise false.

      For the Esplora client, this method checks the server's availability by attempting to fetch the current block height. Note that the Esplora client returns true even after closing the connection, because an HTTP connection is stateless and not persistent. Thus, for Esplora, isConnected effectively checks if the server can respond to requests.

      Returns Promise<boolean>

      Promise resolving to true if the server is reachable and responding; otherwise, false.

    • Returns true if connect has never been called or if close() was called after a connect().

      Returns boolean

    • Get the balance of an address and find out whether the address ever received some coins.

      Parameters

      • address: string

        A Bitcoin address

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

      An object with 'balance' & confirmedTxCount properties.

    • Get the balance of a scriptHash and find out whether the scriptHash ever received some coins.

      Parameters

      • scriptHash: string

        A Bitcoin scriptHash

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

      An object with 'balance' & txCount properties.

    • Fetches the transaction history for a given address or script hash.

      Parameters

      • params: { address?: string; scriptHash?: string }

        The parameters for the method.

        • Optionaladdress?: string

          The address to fetch transaction history for.

        • OptionalscriptHash?: string

          The script hash to fetch transaction history for.

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

      A promise that resolves to an array containing transaction history, each item is an object containing txId, blockHeight and irreversible. txId is the transaction ID, blockHeight is the height of the block that includes the transaction, and irreversible is a boolean indicating whether the transaction has reached the irreversible confirmation threshold (set to IRREV_CONF_THRESH confirmations). They are returned in blockchain order. However, esplora might not respect order when txs belong to the same block. See https://github.com/Blockstream/esplora/issues/165

      If both address and scriptHash are provided or if neither are provided.

    • Parameters

      • txId: string

      Returns Promise<string>

    • Get an object where the key is the confirmation target (in number of blocks) and the value is the estimated feerate (in sat/vB).

      The available confirmation targets are 1-25, 144, 504 and 1008 blocks.

      Returns Promise<Record<string, number>>

      An object where the key is the confirmation target (in number of blocks).

    • Get's the BlockStatus: { blockHeight: number; blockHash: string; blockTime: number; }) of a certain blockHeight.

      Returns undefined if this block height has not been mined yet.

      Parameters

      • blockHeight: number

      Returns Promise<BlockStatus | undefined>

      BlockStatus | undefined;

    • Get's current block height (blockchain tip).

      Returns Promise<number>

      A number representing the current height.

    • 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.

      If the transaction is invalid or fails to be broadcasted.