UNPKG

@btc-vision/bitcoin-rpc

Version:

The one and only fully typed Bitcoin RPC client for Node.js

125 lines (124 loc) 9.25 kB
import { Logger } from '@btc-vision/bsi-common'; import { CreateWalletParams, GetBlockTemplateParams, GetChainTxStatsParams, ImportDescriptorsParams, PsbtBumpFeeParams, RPCIniOptions, SendAllParams, SendParams, SendRawTransactionParams } from './external/rpc.js'; import { AddressByLabel } from './types/AddressByLabel.js'; import { RPCConfig } from './interfaces/RPCConfig.js'; import { BasicBlockInfo } from './types/BasicBlockInfo.js'; import { BitcoinRawTransactionParams, IRawTransaction, RawTransaction } from './types/BitcoinRawTransaction.js'; import { BitcoinVerbosity } from './types/BitcoinVerbosity.js'; import { BlockchainInfo } from './types/BlockchainInfo.js'; import { BlockData, BlockDataWithTransactionData } from './types/BlockData.js'; import { BlockFilterInfo } from './types/BlockFilterInfo.js'; import { BlockHeaderInfo } from './types/BlockHeaderInfo.js'; import { BlockStats } from './types/BlockStats.js'; import { ChainTipInfo } from './types/ChainTipInfo.js'; import { ChainTxStats } from './types/ChainTxStats.js'; import { CreateWalletResponse } from './types/CreateWalletResponse.js'; import { FeeEstimation, SmartFeeEstimation } from './types/FeeEstimation.js'; import { MempoolInfo } from './types/MempoolInfo.js'; import { MemPoolTransactionInfo, RawMemPoolTransactionInfo } from './types/MemPoolTransactionInfo.js'; import { TransactionOutputInfo } from './types/TransactionOutputInfo.js'; import { TransactionOutputSetInfo } from './types/TransactionOutputSetInfo.js'; import { WalletInfo } from './types/WalletInfo.js'; import { RawMempool } from './types/RawMempool.js'; import { BestBlockHeader, ChainLockVerification, DeploymentInfo, GenerateBlockResult, HDKeyInfo, ImportDescriptorsResult, IndexInfo, ListDescriptorsResult, MempoolEntryById, MigrateWalletResult, NodeAddress, PackageResult, PeerAddressResult, PsbtBumpFeeResult, SendAllResult, SendResult, SimulateTransactionResult, TestMempoolAcceptResult, UpgradeWalletResult, WalletDescriptor } from './types/NewMethods.js'; import { BlockTemplate } from './types/BlockTemplate.js'; export declare class BitcoinRPC extends Logger { private readonly cacheClearInterval; private readonly enableDebug; readonly logColor: string; private rpc; private blockchainInfo; private currentBlockInfo; private purgeInterval; constructor(cacheClearInterval?: number, enableDebug?: boolean); destroy(): void; getRpcConfigFromBlockchainConfig(rpcInfo: RPCConfig): RPCIniOptions; getBestBlockHash(): Promise<string | null>; getBlockBatch(blockHashes: string[]): Promise<BlockData[] | null>; getBestBlockHeader(verbose?: boolean): Promise<BestBlockHeader | string | null>; getDeploymentInfo(blockHash?: string): Promise<DeploymentInfo | null>; getMempoolEntryById(wtxid: string): Promise<MempoolEntryById | null>; generate(nBlocks: number, maxTries?: number, wallet?: string): Promise<string[] | null>; generateBlock(output: string, transactions?: string[], submit?: boolean): Promise<GenerateBlockResult | null>; addPeerAddress(address: string, port: number, tried?: boolean): Promise<PeerAddressResult | null>; getNodeAddresses(count?: number): Promise<NodeAddress[] | null>; sendMsgToPeer(peerId: number, msgType: string, data: string): Promise<void>; submitPackage(packageTxs: string[], maxFeeRate?: number | string, maxBurnAmount?: number | string): Promise<PackageResult | null>; getIndexInfo(indexName?: string): Promise<IndexInfo | null>; verifyChainLock(blockHash: string, signature: string, height: number): Promise<ChainLockVerification | null>; createWalletDescriptor(type: 'wpkh' | 'pkh' | 'sh' | 'tr', internal?: boolean, hdkey?: string, wallet?: string): Promise<WalletDescriptor | null>; getHDKeys(activeOnly?: boolean, privateKeys?: boolean, wallet?: string): Promise<HDKeyInfo[] | null>; importDescriptors(requests: ImportDescriptorsParams['requests'], wallet?: string): Promise<ImportDescriptorsResult | null>; listDescriptors(includePrivate?: boolean, wallet?: string): Promise<ListDescriptorsResult | null>; migrateWallet(walletName?: string, passphrase?: string): Promise<MigrateWalletResult | null>; newKeypool(wallet?: string): Promise<void>; getBlockTemplate(params: GetBlockTemplateParams): Promise<BlockTemplate | null>; submitBlock(blockHex: string): Promise<string | null>; psbtBumpFee(txid: string, options?: PsbtBumpFeeParams['options'], wallet?: string): Promise<PsbtBumpFeeResult | null>; send(outputs: SendParams['outputs'], options?: { confTarget?: number; estimateMode?: 'UNSET' | 'ECONOMICAL' | 'CONSERVATIVE'; feeRate?: number | string; advancedOptions?: SendParams['options']; }, wallet?: string): Promise<SendResult | null>; sendAll(recipients: SendAllParams['recipients'], options?: { confTarget?: number; estimateMode?: 'UNSET' | 'ECONOMICAL' | 'CONSERVATIVE'; feeRate?: number | string; advancedOptions?: SendAllParams['options']; }, wallet?: string): Promise<SendAllResult | null>; simulateRawTransaction(rawTxs?: string[], includeWatchOnly?: boolean, wallet?: string): Promise<SimulateTransactionResult | null>; upgradeWallet(version?: number, wallet?: string): Promise<UpgradeWalletResult | null>; getBlockAsHexString(blockHash: string): Promise<string | null>; estimateSmartFee(confTarget: number, estimateMode?: FeeEstimation): Promise<SmartFeeEstimation>; joinPSBTs(psbts: string[]): Promise<string | null>; getBlockInfoOnly(blockHash: string): Promise<BlockData | null>; getBlockInfoWithTransactionData(blockHash: string): Promise<BlockDataWithTransactionData | null>; getBlockHashes(height: number, count: number): Promise<(string | null)[] | null>; getBlocksInfoWithTransactionData(blockHashes: string[]): Promise<(BlockDataWithTransactionData | null)[] | null>; getBlockCount(): Promise<number | null>; getBlockFilter(blockHash: string, filterType?: string): Promise<BlockFilterInfo | null>; getBlockHash(height: number): Promise<string | null>; getChainInfo(): Promise<BlockchainInfo | null>; getWalletInfo(walletName: string): Promise<WalletInfo | null>; createWallet(params: CreateWalletParams): Promise<CreateWalletResponse | null>; loadWallet(filename: string): Promise<CreateWalletResponse | null>; listWallets(): Promise<string[] | null>; getNewAddress(label: string, wallet?: string): Promise<string | null>; generateToAddress(nBlock: number, address: string, wallet?: string): Promise<string[] | null>; importPrivateKey(privateKey: string, label: string, rescan?: boolean, wallet?: string): Promise<void>; invalidateBlock(blockHash: string): Promise<void>; reconsiderBlock(blockHash: string): Promise<void>; getAddressByLabel(label: string, wallet?: string): Promise<AddressByLabel | null>; sendRawTransaction(params: SendRawTransactionParams): Promise<string | null>; testMempoolAccept(rawtxs: string[], maxfeerate?: number | string): Promise<TestMempoolAcceptResult[]>; decodeRawTransaction(hexString: string, isWitness?: boolean): Promise<IRawTransaction | null>; dumpPrivateKey(address: string, wallet?: string): Promise<string | null>; getRawTransaction<V extends BitcoinVerbosity>(parameters: BitcoinRawTransactionParams): Promise<RawTransaction<V> | null>; getRawTransactions<V extends BitcoinVerbosity>(txs: string[], verbose?: V): Promise<(RawTransaction<V> | null)[] | null>; getBlockHeight(): Promise<BasicBlockInfo | null>; getBlockHeader(blockHash: string, verbose?: boolean): Promise<BlockHeaderInfo | null>; getBlockStatsByHeight(height: number, stats?: string[]): Promise<BlockStats | null>; getBlockStatsByHash(blockHash: string, stats?: string[]): Promise<BlockStats | null>; getChainTips(): Promise<ChainTipInfo[] | null>; getChainTxStats(param: GetChainTxStatsParams): Promise<ChainTxStats | null>; getDifficulty(): Promise<number | null>; getMempoolAncestors<V extends BitcoinVerbosity>(txId: string, verbose?: V): Promise<MemPoolTransactionInfo<V> | null>; getMempoolDescendants<V extends BitcoinVerbosity>(txid: string, verbose?: V): Promise<MemPoolTransactionInfo<V> | null>; getMempoolEntry(txid: string): Promise<RawMemPoolTransactionInfo | null>; getMempoolInfo(): Promise<MempoolInfo<BitcoinVerbosity.NONE> | null>; getRawMempool<V extends BitcoinVerbosity>(verbose?: V): Promise<RawMempool<V> | null>; getTxOut(txid: string, voutNumber: number, includeMempool?: boolean): Promise<TransactionOutputInfo | null>; getTxOutProof(txids: string[], blockHash?: string): Promise<string | null>; getTxOutSetInfo(): Promise<TransactionOutputSetInfo | null>; preciousBlock(blockHash: string): Promise<void>; pruneBlockChain(height: number): Promise<number | null>; saveMempool(): Promise<void>; verifyChain(checkLevel?: number, nblocks?: number): Promise<boolean | null>; verifyTxOutProof(proof: string): Promise<string[] | null>; init(rpcInfo: RPCConfig): Promise<void>; error(...args: string[]): void; private debugMessage; private purgeCachedData; private testRPC; }