@btc-vision/bitcoin-rpc
Version:
The one and only fully typed Bitcoin RPC client for Node.js
49 lines (48 loc) • 1.43 kB
TypeScript
import { Fetch, IFetchOptions } from 'rpc-request';
export type formatParam = {
format?: 'json' | 'hex' | 'bin';
};
export type BlockParams = formatParam & {
hash: string;
};
export type BlockHeightParams = formatParam & {
height: number;
};
export type Outpoint = {
txid: string;
n: number;
};
export type UtxosParams = formatParam & {
checkmempool?: boolean;
outpoints: Outpoint[] | Outpoint;
};
export type HeaderParams = BlockParams & {
count?: number;
};
export type TxParams = formatParam & {
txid: string;
};
export type Auth = {
user: string;
pass: string;
};
export type RESTIniOptions = IFetchOptions & {
auth?: Auth;
port?: number;
url: string;
};
export type AuthHeaders = HeadersInit & {
Authorization: string;
};
export declare class RESTClient extends Fetch {
constructor(opts: RESTIniOptions);
getBlock({ hash, format }: BlockParams): Promise<unknown>;
getBlockNoTxDetails({ hash, format }: BlockParams): Promise<unknown>;
getBlockHashByHeight({ height, format }: BlockHeightParams): Promise<unknown>;
getChainInfo(): Promise<unknown>;
getUtxos({ checkmempool, outpoints, format }: UtxosParams): Promise<unknown>;
getHeaders({ count, hash, format }: HeaderParams): Promise<unknown>;
getMemPoolContents(): Promise<unknown>;
getMemPoolInfo(): Promise<unknown>;
getTx({ txid, format }: TxParams): Promise<unknown>;
}