@mr-zwets/bchn-api-wrapper
Version:
a Typescript wrapper for interacting with the Bitcoin Cash Node (BCHN) API
30 lines (29 loc) • 2.3 kB
TypeScript
import type { RestClientConfig, formatOptions, ResponseType } from "./interfaces/interfaces.js";
import type { BlockInfoNoTxDetails, BlockInfoTxDetails, BlockInfoWithPatterns, ChainInfo, HeaderInfo, MempoolContent, MempoolInfo, TxDetails, TxDetailsWithPatterns, UtxosInfo } from "./interfaces/restInterfaces/interfaces.js";
/** REST client for read-only BCHN blockchain access via the REST interface. */
export declare class BchnRestClient {
private baseUrl;
private timeoutMs;
private logger;
constructor(config: RestClientConfig);
private fetchFromNode;
/** Returns transaction details by txid. */
getTransaction<TFormat extends formatOptions = 'json'>(txid: string, format?: TFormat): Promise<ResponseType<TFormat, TxDetails>>;
/** Returns block data. Use includeTxDetails=true for full transaction objects. */
getBlock<TFormat extends formatOptions = 'json'>(blockhash: string, includeTxDetails: true, format?: TFormat): Promise<TFormat extends 'json' ? BlockInfoTxDetails : string>;
getBlock<TFormat extends formatOptions = 'json'>(blockhash: string, includeTxDetails: false, format?: TFormat): Promise<TFormat extends 'json' ? BlockInfoNoTxDetails : string>;
/** Returns block headers starting from a specific block hash. */
getBlockHeaders<TFormat extends formatOptions = 'json'>(count: number, blockhash: string, format?: TFormat): Promise<ResponseType<TFormat, HeaderInfo>>;
/** Returns current chain state (network, sync progress, best block). */
getChainInfo(): Promise<ChainInfo>;
/** Queries UTXO set for specific outpoints. Outpoints format: "txid-vout". */
getUTXOs<TFormat extends formatOptions = 'json'>(checkmempool: boolean, outpoints: string[], format?: TFormat): Promise<ResponseType<TFormat, UtxosInfo>>;
/** Returns mempool statistics (size, bytes, fee rates). */
getMempoolInfo(): Promise<MempoolInfo>;
/** Returns all transactions currently in the mempool. */
getMempoolContents(): Promise<MempoolContent>;
/** Returns block with bytecode pattern data (v29.0.0+). */
getBlockWithPatterns(blockhash: string): Promise<BlockInfoWithPatterns>;
/** Returns transaction with bytecode pattern data (v29.0.0+). */
getTransactionWithPatterns(txid: string): Promise<TxDetailsWithPatterns>;
}