@mr-zwets/bchn-api-wrapper
Version:
a Typescript wrapper for interacting with the Bitcoin Cash Node (BCHN) API
71 lines (70 loc) • 1.86 kB
TypeScript
export interface BaseRpcClientConfig {
rpcUser: string;
rpcPassword: string;
maxRetries?: number;
retryDelayMs?: number;
logger?: typeof console;
timeoutMs?: number;
}
export interface RpcClientUrlConfig extends BaseRpcClientConfig {
url: string;
}
export interface RpcClientHostConfig extends BaseRpcClientConfig {
protocol: 'http' | 'https';
host: string;
port: number;
}
export type RpcClientConfig = RpcClientUrlConfig | RpcClientHostConfig;
export type RPCParameter = string | number | boolean | undefined | object;
declare type RequestResponse = object | string | number | boolean | null | RequestResponse[];
export interface RpcRequest {
method: string;
params: Array<RPCParameter>;
response: RequestResponse;
}
export interface RestClientConfig {
url: string;
logger?: typeof console;
timeoutMs?: number;
}
export type formatOptions = 'bin' | 'hex' | 'json';
export type ResponseType<TFormat extends formatOptions, TJson> = TFormat extends 'json' ? TJson : TFormat extends 'hex' | 'bin' ? string : never;
export interface Transaction {
txid: string;
hash: string;
size: number;
version: number;
locktime: number;
vin: TransactionInput[];
vout: TransactionOutput[];
}
export interface TransactionInput {
txid: string;
vout: number;
scriptSig: {
asm: string;
hex: string;
};
sequence: number;
}
export interface TransactionOutput {
value: number;
n: number;
scriptPubKey: {
asm: string;
hex: string;
reqSigs: number;
type: string;
addresses: string[];
tokenData: TokenData;
};
}
export interface TokenData {
category: string;
amount: string;
nft?: {
capability: 'none' | 'mutable' | 'minting';
commitment: string;
};
}
export {};