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
160 lines (159 loc) • 5.79 kB
JavaScript
"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.RawTransactionRPC = void 0;
class RawTransactionRPC {
constructor(bitcoinCore) {
this.bitcoinCore = bitcoinCore;
}
// analyzepsbt
analyzePsbt(psbt) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('analyzepsbt', [psbt]);
});
}
// combinepsbt
combinePsbt(txs) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('combinepsbt', [txs]);
});
}
// combinerawtransaction
combineRawTransaction(txs) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('combinerawtransaction', [txs]);
});
}
// converttopsbt
convertToPsbt(hexstring_1) {
return __awaiter(this, arguments, void 0, function* (hexstring, permitsigData = false, isWitness) {
return this.bitcoinCore.callMethod('converttopsbt', [
hexstring,
permitsigData,
isWitness,
]);
});
}
// createpsbt
createPsbt(inputs_1, outputs_1) {
return __awaiter(this, arguments, void 0, function* (inputs, outputs, locktime = 0, replaceable = false) {
return this.bitcoinCore.callMethod('createpsbt', [
inputs,
outputs,
locktime,
replaceable,
]);
});
}
// createrawtransaction
createRawTransaction(inputs_1, outputs_1) {
return __awaiter(this, arguments, void 0, function* (inputs, outputs, locktime = 0, replaceable = false) {
return this.bitcoinCore.callMethod('createrawtransaction', [
inputs,
outputs,
locktime,
replaceable,
]);
});
}
// decodepsbt
decodePsbt(psbt) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('decodepsbt', [psbt]);
});
}
// decoderawtransaction
decodeRawTransaction(hexString, iswitness) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('decoderawtransaction', [
hexString,
iswitness,
]);
});
}
// decodescript
decodeScript(hexString) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('decodescript', [hexString]);
});
}
// finalizepsbt
finalizePsbt(psbt_1) {
return __awaiter(this, arguments, void 0, function* (psbt, extract = true) {
return this.bitcoinCore.callMethod('finalizepsbt', [psbt, extract]);
});
}
// fundrawtransaction
fundRawTransaction(hexString_1) {
return __awaiter(this, arguments, void 0, function* (hexString, options = {}, isWitness) {
return this.bitcoinCore.callMethod('fundrawtransaction', [
hexString,
options,
isWitness,
]);
});
}
// getrawtransaction
getRawTransaction(txid_1) {
return __awaiter(this, arguments, void 0, function* (txid, verbose = false, blockHash) {
return this.bitcoinCore.callMethod('getrawtransaction', [
txid,
verbose,
blockHash,
]);
});
}
// joinpsbts
joinPsbts(txs) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('joinpsbts', [txs]);
});
}
// sendrawtransaction
sendRawTransaction(hexString_1) {
return __awaiter(this, arguments, void 0, function* (hexString, maxFeerate = 0.1) {
return this.bitcoinCore.callMethod('sendrawtransaction', [
hexString,
maxFeerate,
]);
});
}
// signrawtransactionwithkey
signRawTransactionWithKey(hexString_1, privKeys_1) {
return __awaiter(this, arguments, void 0, function* (hexString, privKeys, prevTxs = [], hashType = 'ALL') {
return this.bitcoinCore.callMethod('signrawtransactionwithkey', [
hexString,
privKeys,
prevTxs,
hashType,
]);
});
}
// testmempoolaccept
testMempoolAccept(rawTxs_1) {
return __awaiter(this, arguments, void 0, function* (rawTxs, maxFeerate = 0.1) {
return this.bitcoinCore.callMethod('testmempoolaccept', [
rawTxs,
maxFeerate,
]);
});
}
// utxoupdatepsbt
utxoUpdatePsbt(psbt, descriptors) {
return __awaiter(this, void 0, void 0, function* () {
return this.bitcoinCore.callMethod('utxoupdatepsbt', [
psbt,
descriptors,
]);
});
}
}
exports.RawTransactionRPC = RawTransactionRPC;