UNPKG

bitcoincore-node

Version:

A comprehensive Node.js package for interacting with Bitcoin Core via RPC. Create, sign, and broadcast Bitcoin transactions, manage wallets, and access blockchain data through an easy-to-use API interface. Perfect for developers building cryptocurrency ap

200 lines (199 loc) 6.96 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockchainRPC = void 0; class BlockchainRPC { constructor(bitcoinCore) { this.bitcoinCore = bitcoinCore; } // getbestblockhash getBestBlockhash() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getbestblockhash'); }); } // getblock getBlock(blockHash_1) { return __awaiter(this, arguments, void 0, function* (blockHash, verbosity = 1) { return this.bitcoinCore.callMethod('getblock', [blockHash, verbosity]); }); } // getblockchaininfo getBlockchainInfo() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getblockchaininfo'); }); } // getblockcount getBlockCount() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getblockcount'); }); } // getblockfilter getBlockFilter(blockHash_1) { return __awaiter(this, arguments, void 0, function* (blockHash, filterType = 'basic') { return this.bitcoinCore.callMethod('getblockfilter', [ blockHash, filterType, ]); }); } // getblockhash getBlockHash(height) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getblockhash', [height]); }); } // getblockheader getBlockHeader(blockHash_1) { return __awaiter(this, arguments, void 0, function* (blockHash, verbose = true) { return this.bitcoinCore.callMethod('getblockheader', [ blockHash, verbose, ]); }); } // getblockstats getBlockStats(hashOrHeight_1) { return __awaiter(this, arguments, void 0, function* (hashOrHeight, stats = []) { return this.bitcoinCore.callMethod('getblockstats', [ hashOrHeight, stats, ]); }); } // getchaintips getChainTips() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getchaintips'); }); } // getchaintxstats getChainTxStats(nblocks, blockHash) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getchaintxstats', [ nblocks, blockHash, ]); }); } // getdifficulty getDifficulty() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getdifficulty'); }); } // getmempoolancestors getMempoolAncestors(txid_1) { return __awaiter(this, arguments, void 0, function* (txid, verbose = false) { return this.bitcoinCore.callMethod('getmempoolancestors', [ txid, verbose, ]); }); } // getmempooldescendants getMempoolDescendants(txid_1) { return __awaiter(this, arguments, void 0, function* (txid, verbose = false) { return this.bitcoinCore.callMethod('getmempooldescendants', [ txid, verbose, ]); }); } // getmempoolentry getMempoolEntry(txid) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getmempoolentry', [txid]); }); } // getmempoolinfo getMempoolInfo() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('getmempoolinfo'); }); } // getrawmempool getRawMempool() { return __awaiter(this, arguments, void 0, function* (verbose = false, mempoolSequence = false) { return this.bitcoinCore.callMethod('getrawmempool', [ verbose, mempoolSequence, ]); }); } // gettxout getTxOut(txid_1, n_1) { return __awaiter(this, arguments, void 0, function* (txid, n, includeMemPool = true) { return this.bitcoinCore.callMethod('gettxout', [ txid, n, includeMemPool, ]); }); } // gettxoutproof getTxOutProof(txids, blockHash) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('gettxoutproof', [txids, blockHash]); }); } // gettxoutsetinfo getTxOutSetInfo() { return __awaiter(this, arguments, void 0, function* (hashType = 'hash_serialized_2') { return this.bitcoinCore.callMethod('gettxoutsetinfo', [hashType]); }); } // preciousblock preciousBlock(blockHash) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('preciousblock', [blockHash]); }); } // pruneblockchain pruneBlockChain(height) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('pruneblockchain', [height]); }); } // savemempool saveMempool() { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('savemempool'); }); } // scantxoutset scanTxOutSet(action, scanObjects) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('scantxoutset', [ action, scanObjects, ]); }); } // verifychain verifyChain() { return __awaiter(this, arguments, void 0, function* (checklevel = 3, nblocks = 6) { return this.bitcoinCore.callMethod('verifychain', [ checklevel, nblocks, ]); }); } // verifytxoutproof verifyTxOutProof(proof) { return __awaiter(this, void 0, void 0, function* () { return this.bitcoinCore.callMethod('verifytxoutproof', [proof]); }); } } exports.BlockchainRPC = BlockchainRPC;