UNPKG

@nawab_kibria/bitcoin-lib

Version:

A comprehensive Bitcoin HD wallet library with BIP84, BIP44, BIP49 support, mnemonic generation and restoration

123 lines (122 loc) 3.38 kB
import { ElectrumConfig, ElectrumBalance, ElectrumUTXO, ElectrumHistoryItem, FeeEstimate, BroadcastResult } from '../types/wallet'; export declare class ElectrumClient { private config; private socket; private requestId; private pendingRequests; private connected; private buffer; constructor(config: ElectrumConfig); /** * Connect to the Electrum server */ connect(): Promise<void>; /** * Disconnect from the Electrum server */ disconnect(): void; /** * Check if connected to the server */ isConnected(): boolean; /** * Handle incoming data from the server */ private handleData; /** * Handle server response */ private handleResponse; /** * Send a request to the Electrum server */ private sendRequest; /** * Get server version and protocol version */ getServerVersion(): Promise<{ server: string; protocol: string; }>; /** * Get address balance */ getBalance(address: string): Promise<ElectrumBalance>; /** * Get UTXOs for an address */ getUTXOs(address: string): Promise<ElectrumUTXO[]>; /** * Get transaction history for an address */ getHistory(address: string): Promise<ElectrumHistoryItem[]>; /** * Get raw transaction by hash */ getTransaction(txHash: string): Promise<string>; /** * Get transaction details with verbose output */ getTransactionVerbose(txHash: string): Promise<any>; /** * Broadcast a raw transaction */ broadcastTransaction(rawTx: string): Promise<BroadcastResult>; /** * Estimate transaction fees for different confirmation targets */ estimateFees(): Promise<FeeEstimate>; /** * Get estimated fee for transaction confirmation in specified blocks (legacy method) */ getEstimateFee(blocks?: number): Promise<number>; /** * Get relay fee from the server */ getRelayFee(): Promise<number>; /** * Get mempool fee histogram */ getMempoolFeeHistogram(): Promise<Array<[number, number]>>; /** * Check if transaction is in mempool */ isTransactionInMempool(txid: string): Promise<boolean>; /** * Get transaction confirmation status */ getTransactionStatus(txid: string): Promise<{ confirmed: boolean; confirmations: number; blockHeight?: number; }>; /** * Get multiple address balances at once */ getMultipleBalances(addresses: string[]): Promise<{ [address: string]: ElectrumBalance; }>; /** * Get multiple address UTXOs at once */ getMultipleUTXOs(addresses: string[]): Promise<{ [address: string]: ElectrumUTXO[]; }>; /** * Convert Bitcoin address to script hash for Electrum protocol */ private addressToScriptHash; /** * Subscribe to address changes (for real-time updates) */ subscribeToAddress(address: string, callback: (status: string) => void): Promise<void>; /** * Ping the server to keep connection alive */ ping(): Promise<void>; /** * Get server features */ getServerFeatures(): Promise<any>; } export declare function createElectrumClient(host?: string, port?: number, ssl?: boolean): ElectrumClient;