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
64 lines (63 loc) • 2.42 kB
JavaScript
;
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.MiningRPC = void 0;
class MiningRPC {
constructor(bitcoinCore) {
this.bitcoinCore = bitcoinCore;
}
// getblocktemplate
getBlockTemplate() {
return __awaiter(this, arguments, void 0, function* (templateRequest = {}) {
return this.bitcoinCore.callMethod('getblocktemplate', [
templateRequest,
]);
});
}
// getmininginfo
getMiningInfo() {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('getmininginfo');
});
}
// getnetworkhashps
getNetworkHashPs() {
return __awaiter(this, arguments, void 0, function* (nblocks = 120, height = -1) {
return this.bitcoinCore.callMethod('getnetworkhashps', [
nblocks,
height,
]);
});
}
// prioritisetransaction
prioritizeTransaction(txid_1) {
return __awaiter(this, arguments, void 0, function* (txid, dummy = '', fee_delta) {
return this.bitcoinCore.callMethod('prioritisetransaction', [
txid,
dummy,
fee_delta,
]);
});
}
// submitblock
submitBlock(hexdata, dummy) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('submitblock', [hexdata, dummy]);
});
}
// submitheader
submitHeader(hexdata) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('submitheader', [hexdata]);
});
}
}
exports.MiningRPC = MiningRPC;