import { Chain } from '../../../../sdk/types'; import { BlockHeader } from '../../../../sdk/WalletServices.interfaces'; import { WhatsOnChain, WocChainInfo } from '../../../providers/WhatsOnChain'; import { ChaintracksFetchApi } from '../Api/ChaintracksFetchApi'; import { HeightRange } from '../util/HeightRange'; /** * return true to ignore error, false to close service connection */ export type ErrorHandler = (code: number, message: string) => boolean; export type EnqueueHandler = (header: BlockHeader) => void; export declare function parseFileLink(file: string): { range: { fromHeight: number; toHeight: number; } | 'latest'; sourceUrl: string; fileName: string; } | undefined; export interface WhatsOnChainServicesOptions { /** * Which chain is being tracked. The public WhatsOnChain fallback is only * configured automatically for mainnet and testnet. */ chain: Chain; /** * Optional WhatsOnChain API key. ChainTracks works without one and limits * anonymous traffic to the documented public rate. * https://docs.whatsonchain.com/ */ apiKey?: string; /** * Request timeout for GETs to https://api.whatsonchain.com/v1/bsv */ timeout: number; /** * User-Agent header value for requests to https://api.whatsonchain.com/v1/bsv */ userAgent: string; /** * Enable WhatsOnChain client cache option. */ enableCache: boolean; /** * How long chainInfo is considered still valid before updating (msecs). */ chainInfoMsecs: number; /** Minimum interval between keyless API request starts. Defaults below 3 requests/second. */ minRequestIntervalMsecs?: number; } export declare class WhatsOnChainServices { static createWhatsOnChainServicesOptions(chain: Chain): WhatsOnChainServicesOptions; static readonly chainInfo: Array; static readonly chainInfoTime: Array; static readonly chainInfoMsecs: number[]; static readonly chainInfoPromise: Partial>>; private static requestTail; private static nextRequestMsecs; chain: Chain; woc: WhatsOnChain; readonly options: WhatsOnChainServicesOptions; constructor(options: WhatsOnChainServicesOptions); getHeaderByHash(hash: string): Promise; getChainInfo(): Promise; getChainTipHeight(): Promise; getChainTipHash(): Promise; /** * @param fetch * @returns returns the last 10 block headers including height, size, chainwork... */ getHeaders(fetch?: ChaintracksFetchApi): Promise; getHeaderByteFileLinks(neededRange: HeightRange, fetch?: ChaintracksFetchApi): Promise; private waitForRateLimit; } export interface WocGetHeaderByteFileLinks { files: string[]; } export interface WocGetHeadersHeader { hash: string; confirmations: number; size: number; height: number; version: number; versionHex: string; merkleroot: string; time: number; mediantime: number; nonce: number; bits: string; difficulty: number; chainwork: string; previousblockhash: string; nextblockhash: string; nTx: number; num_tx: number; } export declare function wocGetHeadersHeaderToBlockHeader(h: WocGetHeadersHeader): BlockHeader; export interface GetHeaderByteFileLinksResult { sourceUrl: string; fileName: string; range: HeightRange; data: Uint8Array | undefined; /** The URL came from a remote resource manifest and must remain public HTTPS. */ publicNetworkOnly: true; } //# sourceMappingURL=WhatsOnChainServices.d.ts.map