/// import { EventEmitter } from "events"; import * as zmq from "zeromq"; import { IBitcoindOptions } from "./BitcoindOptions"; import { BlockChainInfo } from "./types/BlockChainInfo"; import { Block } from "./types/Block"; import { BlockHeader } from "./types/BlockHeader"; import { BlockSummary } from "./types/BlockSummary"; import { Transaction } from "./types/Transaction"; import { Utxo } from "./types/Transaction"; import { JsonRpcOptions } from "./JsonRpcOptions"; export declare interface IBitcoindClient { on(event: "rawtx", listener: (rawtx: Buffer) => void): this; on(event: "rawblock", listener: (rawblock: Buffer) => void): this; } /** * Bitcoind RPC and Zeromq client */ export declare class BitcoindClient extends EventEmitter { opts: IBitcoindOptions; jsonRpcOptions: JsonRpcOptions; id: number; rawTxSock: zmq.socket; rawBlockSock: zmq.socket; constructor(opts: IBitcoindOptions); /** * Subscribes to the raw transaction ZeroMQ stream and emits * rawtx events with a Buffer payload * @emits rawtx */ subscribeRawTx(): void; /** * Subscribes to the raw block ZeroMQ stream and emits * rawblock events with a Buffer payload. * @emits rawblock */ subscribeRawBlock(): void; /** * Gets the BlockChaininfo using the `getblockchaininfo` RPC method */ getBlockchainInfo(): Promise; /** * Returns the hash of the best block. */ getBestBlockHash(): Promise; /** * Gets the block hash for a given block height. Hash is returned in RPC byte * order using the `getblockhash` RPC method * @param height */ getBlockHash(height: number): Promise; /** * Gets a BlockSummary object, which only includes the transaction identifiers * using the `getblock` RPC method * @param hash */ getBlockSummary(hash: string): Promise; getBlock(hash: string): Promise; /** * Gets a raw block as a Buffer use the `getblock` RPC method * @param hash */ getRawBlock(hash: string): Promise; /** * Gets a transaction header from the by calling the * `getblockheader` RPC * @param hash */ getHeader(hash: string): Promise; /** * Gets a parsed transaction using the `getrawtransaction` method * @param txid */ getTransaction(txid: string): Promise; /** * Gets a raw transaction as a buffer using the `getrawtransaction` RPC method * @param txid */ getRawTransaction(txid: string): Promise; /** * Retrieves the UTXO value using the gettxout rpc method * @param txid * @param n */ getUtxo(txid: string, n: number): Promise; /** * Generates the supplied number of blocks to the specified address. * @param blocks * @param address */ generateToAddress(blocks: number, address: string): Promise; /** * Returns the estimated network hashes per second based on the last n blocks. * @param blocks * @param height * @returns */ getNetworkHashPs(blocks: number, height: number): Promise; /** * Submit a raw transaction (serialized, hex-encoded) to local node and network. * @param hexstring hex-encoded transaction * @returns */ sendRawTransaction(hexString: string): Promise; /** * Send an amount to a given address. * @param address the bitcoin address to send to * @param amountInBtc the amount in BC to send. eg. 0.1 * @returns the hex encoded transaction id */ sendToAddress(address: string, amountInBtc: string | number): Promise; /** * Returns a new address for receiving payments. * @param label optional label * @param type legacy, p2sh-segwit, or bech32. Defaults to beceh32 */ getNewAddress(label?: string, type?: "legacy" | "p2sh-segwit" | "bech32"): Promise; /** * This API will block until the bitcoind has been synced. If the bitcoind * has already been synced then it will immediately return. * * This method works by using the `getblockchaininfo` RPC call and analyzing * the mediantime, blocks, and headers values. The mediantime must be within * several hours of the current system time and then we verify that the * blocks and headers counts match. If either of this conditions fail we use a * backoff strategy and try again. */ waitForSync(): Promise; /** * Performs a json-rpc requets using the configured options for the client. * @param method * @param args */ private _jsonrpc; }