@bsv/wallet-toolbox
Version:
BRC100 conforming wallet, wallet storage and wallet signer components
89 lines • 3.05 kB
TypeScript
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 interface WhatsOnChainServicesOptions {
/**
* Which chain is being tracked: main, test, or stn.
*/
chain: Chain;
/**
* WhatsOnChain.com API Key
* https://docs.taal.com/introduction/get-an-api-key
* If unknown or empty, maximum request rate is limited.
* https://developers.whatsonchain.com/#rate-limits
*/
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;
}
export declare class WhatsOnChainServices {
options: WhatsOnChainServicesOptions;
static createWhatsOnChainServicesOptions(chain: Chain): WhatsOnChainServicesOptions;
static chainInfo: (WocChainInfo | undefined)[];
static chainInfoTime: (Date | undefined)[];
static chainInfoMsecs: number[];
chain: Chain;
woc: WhatsOnChain;
constructor(options: WhatsOnChainServicesOptions);
getHeaderByHash(hash: string): Promise<BlockHeader | undefined>;
getChainInfo(): Promise<WocChainInfo>;
getChainTipHeight(): Promise<number>;
getChainTipHash(): Promise<string>;
/**
* @param fetch
* @returns returns the last 10 block headers including height, size, chainwork...
*/
getHeaders(fetch?: ChaintracksFetchApi): Promise<WocGetHeadersHeader[]>;
getHeaderByteFileLinks(neededRange: HeightRange, fetch?: ChaintracksFetchApi): Promise<GetHeaderByteFileLinksResult[]>;
}
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;
}
//# sourceMappingURL=WhatsOnChainServices.d.ts.map