UNPKG

@indigonakamoto/rpc-omnilite

Version:

A TypeScript library to make RPC and HTTP REST requests to OmniLite Litecoin Omni Layer.

690 lines (689 loc) 21.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RPCClient = void 0; const rest_1 = require("./rest"); class RPCClient extends rest_1.RESTClient { constructor({ user = "", pass, wallet, fullResponse, ...options }) { super({ ...options, auth: { user, pass }, uri: "/" }); this.fullResponse = fullResponse ? true : false; this.wallet = typeof wallet === "string" ? wallet : undefined; } batch(body, uri = "/") { return super.post({ body, uri }); } async rpc(method, params = {}, wallet) { const uri = typeof wallet === "undefined" ? "/" : "wallet/" + wallet; const body = { method, params, jsonrpc: 1.0, id: "rpc-omnilite" }; try { const response = await this.batch(body, uri); return this.fullResponse ? response : response.result; } catch (error) { if (error.error && error.error.error && error.error.result === null) { throw this.fullResponse ? error.error : error.error.error; } throw error; } } getbestblockhash() { return this.rpc("getbestblockhash").catch((error) => error); } getblock({ blockhash, verbosity = 1 }) { return this.rpc("getblock", { blockhash, verbosity }); } getblockchaininfo() { return this.rpc("getblockchaininfo"); } getblockcount() { return this.rpc("getblockcount"); } getblockfilter(options) { return this.rpc("getblockfilter", options); } getblockhash({ height }) { return this.rpc("getblockhash", { height }); } getblockheader({ blockhash, verbose = true }) { return this.rpc("getblockheader", { blockhash, verbose }); } getblockstats({ hash_or_height, stats = [] }) { return this.rpc("getblockstats", { hash_or_height, stats }); } getchaintips() { return this.rpc("getchaintips"); } getchaintxstats({ nblocks, blockhash }) { return this.rpc("getchaintxstats", { nblocks, blockhash }); } getdifficulty() { return this.rpc("getdifficulty"); } getmempoolancestors({ txid, verbose = false }) { return this.rpc("getmempoolancestors", { txid, verbose }); } getmempooldescendants({ txid, verbose = false }) { return this.rpc("getmempooldescendants", { txid, verbose }); } getmempoolentry({ txid }) { return this.rpc("getmempoolentry", { txid }); } getmempoolinfo() { return this.rpc("getmempoolinfo"); } getrawmempool({ verbose = false } = {}) { return this.rpc("getrawmempool", { verbose }); } gettxout({ txid, n, include_mempool = true }) { return this.rpc("gettxout", { txid, n, include_mempool }); } gettxoutproof({ txids, blockhash }) { return this.rpc("gettxoutproof", { txids, blockhash }); } gettxoutsetinfo() { return this.rpc("gettxoutsetinfo"); } preciousblock({ blockhash }) { return this.rpc("preciousblock", { blockhash }); } pruneblockchain({ height }) { return this.rpc("pruneblockchain", { height }); } savemempool() { return this.rpc("savemempool"); } scantxoutset({ action, scanobjects }) { return this.rpc("scantxoutset", { action, scanobjects }); } verifychain({ checklevel = 3, nblocks = 6 } = {}) { return this.rpc("verifychain", { checklevel, nblocks }); } verifytxoutproof({ proof }) { return this.rpc("verifytxoutproof", { proof }); } getmemoryinfo({ mode = "stats" } = {}) { return this.rpc("getmemoryinfo", { mode }); } getrpcinfo() { return this.rpc("getrpcinfo"); } help({ command } = {}) { return this.rpc("help", { command }); } logging({ include, exclude } = {}) { return this.rpc("logging", { include, exclude }); } stop() { return this.rpc("stop"); } uptime() { return this.rpc("uptime"); } generatetoaddress(options, wallet) { return this.rpc("generatetoaddress", options, wallet || this.wallet); } getblocktemplate(options) { return this.rpc("getblocktemplate", options); } getmininginfo() { return this.rpc("getmininginfo"); } getnetworkhashps(options = {}) { return this.rpc("getnetworkhashps", options); } prioritisetransaction(options) { return this.rpc("prioritisetransaction", options); } submitblock(options) { return this.rpc("submitblock", options); } submitheader(options) { return this.rpc("submitheader", options); } addnode(options) { return this.rpc("addnode", options); } clearbanned() { return this.rpc("clearbanned"); } disconnectnode(params) { if ("address" in params) { return this.rpc("disconnectnode", { address: params.address }); } return this.rpc("disconnectnode", { nodeid: params.nodeid }); } getaddednodeinfo(options = {}) { return this.rpc("getaddednodeinfo", options); } getconnectioncount() { return this.rpc("getconnectioncount"); } getnettotals() { return this.rpc("getnettotals"); } getnetworkinfo() { return this.rpc("getnetworkinfo"); } getnodeaddresses(options = {}) { return this.rpc("getnodeaddresses", options); } getpeerinfo() { return this.rpc("getpeerinfo"); } listbanned() { return this.rpc("listbanned"); } ping() { return this.rpc("ping"); } setban(options) { return this.rpc("setban", options); } setnetworkactive(options) { return this.rpc("setnetworkactive", options); } analyzepsbt(options) { return this.rpc("analyzepsbt", options); } combinepsbt(options) { return this.rpc("combinepsbt", options); } combinerawtransaction(options) { return this.rpc("combinerawtransaction", options); } converttopsbt(options) { return this.rpc("converttopsbt", options); } createpsbt(options) { return this.rpc("createpsbt", options); } createrawtransaction(options) { return this.rpc("createrawtransaction", options); } decodepsbt(options) { return this.rpc("decodepsbt", options); } decoderawtransaction(options) { return this.rpc("decoderawtransaction", options); } decodescript(options) { return this.rpc("decodescript", options); } finalizepsbt(options) { return this.rpc("finalizepsbt", options); } fundrawtransaction(options, wallet) { return this.rpc("fundrawtransaction", options, wallet || this.wallet); } getrawtransaction(options) { return this.rpc("getrawtransaction", options); } joinpsbts(options) { return this.rpc("joinpsbts", options); } sendrawtransaction(options) { return this.rpc("sendrawtransaction", options); } signrawtransactionwithkey(options) { return this.rpc("signrawtransactionwithkey", options); } testmempoolaccept(options) { return this.rpc("testmempoolaccept", options); } utxoupdatepsbt(options) { return this.rpc("utxoupdatepsbt", options); } createmultisig(options) { return this.rpc("createmultisig", options); } deriveaddresses({ descriptor, range }) { return this.rpc("deriveaddresses", { descriptor, range }); } estimatesmartfee(options) { return this.rpc("estimatesmartfee", options); } getdescriptorinfo(options) { return this.rpc("getdescriptorinfo", options); } signmessagewithprivkey(options) { return this.rpc("signmessagewithprivkey", options); } validateaddress(options) { return this.rpc("validateaddress", options); } verifymessage(options) { return this.rpc("verifymessage", options); } abandontransaction(options, wallet) { return this.rpc("abandontransaction", options, wallet || this.wallet); } abortrescan(wallet) { return this.rpc("abortrescan", undefined, wallet || this.wallet); } addmultisigaddress(options, wallet) { return this.rpc("addmultisigaddress", options, wallet || this.wallet); } backupwallet(options, wallet) { return this.rpc("backupwallet", options, wallet || this.wallet); } bumpfee(options, wallet) { return this.rpc("bumpfee", options, wallet || this.wallet); } createwallet(options) { return this.rpc("createwallet", options); } dumpprivkey(options, wallet) { return this.rpc("dumpprivkey", options, wallet || this.wallet); } dumpwallet(options, wallet) { return this.rpc("dumpwallet", options, wallet || this.wallet); } encryptwallet(options, wallet) { return this.rpc("encryptwallet", options, wallet || this.wallet); } getaddressesbylabel(options, wallet) { return this.rpc("getaddressesbylabel", options, wallet || this.wallet); } getaddressinfo(options, wallet) { return this.rpc("getaddressinfo", options, wallet || this.wallet); } getbalance(options, wallet) { return this.rpc("getbalance", options, wallet || this.wallet); } getbalances(wallet) { return this.rpc("getbalances", undefined, wallet || this.wallet); } getnewaddress(options, wallet) { return this.rpc("getnewaddress", options, wallet || this.wallet); } getrawchangeaddress(options, wallet) { return this.rpc("getrawchangeaddress", options, wallet || this.wallet); } getreceivedbyaddress(options, wallet) { return this.rpc("getreceivedbyaddress", options, wallet || this.wallet); } getreceivedbylabel(options, wallet) { return this.rpc("getreceivedbylabel", options, wallet || this.wallet); } gettransaction(options, wallet) { return this.rpc("gettransaction", options, wallet || this.wallet); } getunconfirmedbalance(wallet) { return this.rpc("getunconfirmedbalance", undefined, wallet || this.wallet); } getwalletinfo(wallet) { return this.rpc("getwalletinfo", undefined, wallet || this.wallet); } importaddress(options, wallet) { return this.rpc("importaddress", options, wallet || this.wallet); } importmulti(options, wallet) { return this.rpc("importmulti", options, wallet || this.wallet); } importprivkey(options, wallet) { return this.rpc("importprivkey", options, wallet || this.wallet); } importprunedfunds(options, wallet) { return this.rpc("importprunedfunds", options, wallet || this.wallet); } importpubkey(options, wallet) { return this.rpc("importpubkey", options, wallet || this.wallet); } importwallet(options, wallet) { return this.rpc("importwallet", options, wallet || this.wallet); } keypoolrefill(options, wallet) { return this.rpc("keypoolrefill", options, wallet || this.wallet); } listaddressgroupings(wallet) { return this.rpc("listaddressgroupings", undefined, wallet || this.wallet); } listlabels(options, wallet) { return this.rpc("listlabels", options, wallet || this.wallet); } listlockunspent(wallet) { return this.rpc("listlockunspent", undefined, wallet || this.wallet); } listreceivedbyaddress(options, wallet) { return this.rpc("listreceivedbyaddress", options, wallet || this.wallet); } listreceivedbylabel(options, wallet) { return this.rpc("listreceivedbylabel", options, wallet || this.wallet); } listsinceblock(options, wallet) { return this.rpc("listsinceblock", options, wallet || this.wallet); } listtransactions(options, wallet) { return this.rpc("listtransactions", options, wallet || this.wallet); } listunspent(options, wallet) { return this.rpc("listunspent", options, wallet || this.wallet); } listwalletdir() { return this.rpc("listwalletdir"); } listwallets() { return this.rpc("listwallets"); } loadwallet({ filename }) { return this.rpc("loadwallet", { filename }); } lockunspent(options, wallet) { return this.rpc("lockunspent", options, wallet || this.wallet); } removeprunedfunds(options, wallet) { return this.rpc("removeprunedfunds", options, wallet || this.wallet); } rescanblockchain(options, wallet) { return this.rpc("rescanblockchain", options, wallet || this.wallet); } sendmany(options, wallet) { return this.rpc("sendmany", options, wallet || this.wallet); } sendtoaddress(options, wallet) { return this.rpc("sendtoaddress", options, wallet || this.wallet); } sethdseed(options, wallet) { return this.rpc("sethdseed", options, wallet || this.wallet); } setlabel(options, wallet) { return this.rpc("setlabel", options, wallet || this.wallet); } settxfee(options, wallet) { return this.rpc("settxfee", options, wallet || this.wallet); } setwalletflag(options, wallet) { return this.rpc("setwalletflag", options, wallet || this.wallet); } signmessage(options, wallet) { return this.rpc("signmessage", options, wallet || this.wallet); } signrawtransactionwithwallet(options, wallet) { return this.rpc( "signrawtransactionwithwallet", options, wallet || this.wallet ); } unloadwallet({ wallet_name } = {}) { if (typeof wallet_name !== "undefined") { return this.rpc("unloadwallet", { wallet_name }); } return this.rpc("unloadwallet", undefined, this.wallet); } walletcreatefundedpsbt(options, wallet) { return this.rpc("walletcreatefundedpsbt", options, wallet || this.wallet); } walletlock(wallet) { return this.rpc("walletlock", undefined, wallet || this.wallet); } walletpassphrase(options, wallet) { return this.rpc("walletpassphrase", options, wallet || this.wallet); } walletpassphrasechange(options, wallet) { return this.rpc("walletpassphrasechange", options, wallet || this.wallet); } walletprocesspsbt(options, wallet) { return this.rpc("walletprocesspsbt", options, wallet || this.wallet); } getzmqnotifications() { return this.rpc("getzmqnotifications"); } omni_send(params) { return this.rpc("omni_send", params); } omni_sendnewdexorder(params) { return this.rpc("omni_sendnewdexorder", params); } omni_sendupdatedexorder(params) { return this.rpc("omni_sendupdatedexorder", params); } omni_sendcanceldexorder(params) { return this.rpc("omni_sendcanceldexorder", params); } omni_senddexaccept(params) { return this.rpc("omni_senddexaccept", params); } omni_senddexpay(params) { return this.rpc("omni_senddexpay", params); } omni_sendissuancecrowdsale(params) { return this.rpc("omni_sendissuancecrowdsale", params); } omni_sendissuancefixed(params) { return this.rpc("omni_sendissuancefixed", params); } omni_sendissuancemanaged(params) { return this.rpc("omni_sendissuancemanaged", params); } omni_sendsto(params) { return this.rpc("omni_sendsto", params); } omni_sendgrant(params) { return this.rpc("omni_sendgrant", params); } omni_sendrevoke(params) { return this.rpc("omni_sendrevoke", params); } omni_sendclosecrowdsale(params) { return this.rpc("omni_sendclosecrowdsale", params); } omni_sendchangeissuer(params) { return this.rpc("omni_sendchangeissuer", params); } omni_sendall(params) { return this.rpc("omni_sendall", params); } omni_sendenablefreezing(params) { return this.rpc("omni_sendenablefreezing", params); } omni_senddisablefreezing(params) { return this.rpc("omni_senddisablefreezing", params); } omni_sendfreeze(params) { return this.rpc("omni_sendfreeze", params); } omni_sendunfreeze(params) { return this.rpc("omni_sendunfreeze", params); } omni_sendanydata(params) { return this.rpc("omni_sendanydata", params); } omni_sendrawtx(params) { return this.rpc("omni_sendrawtx", params); } omni_funded_send(params) { return this.rpc("omni_funded_send", params); } omni_funded_sendall(params) { return this.rpc("omni_funded_sendall", params); } omni_sendnonfungible(params) { return this.rpc("omni_sendanydata", params); } omni_setnonfungibledata(params) { return this.rpc("omni_sendanydata", params); } omni_getinfo() { return this.rpc("omni_getinfo"); } omni_getbalance(params) { return this.rpc("omni_getbalance", params); } omni_getallbalancesforid(params) { return this.rpc("omni_getallbalancesforid", params); } omni_getallbalancesforaddress(params) { return this.rpc("omni_getallbalancesforaddress", params); } omni_getwalletbalances(params) { return this.rpc("omni_getwalletbalances", params); } omni_getwalletaddressbalances() { return this.rpc("omni_getwalletaddressbalances"); } omni_gettransaction(params) { return this.rpc("omni_gettransaction", params); } omni_listtransactions(params) { return this.rpc("omni_listtransactions", params); } omni_listblocktransactions(params) { return this.rpc("omni_listblocktransactions", params); } omni_listblockstransactions(params) { return this.rpc("omni_listblockstransactions", params); } omni_listpendingtransactions(params) { return this.rpc("omni_listpendingtransactions", params); } omni_getactivedexsell() { return this.rpc("omni_getactivedexsells"); } omni_listproperties() { return this.rpc("omni_listproperties"); } omni_getproperty(params) { return this.rpc("omni_getproperty", params); } omni_getactivecrowdsales() { return this.rpc("omni_getactivecrowdsales"); } omni_getcrowdsale(params) { return this.rpc("omni_getcrowdsale", params); } omni_getgrants(params) { return this.rpc("omni_getgrants", params); } omni_getsto(params) { return this.rpc("omni_getsto", params); } omni_getactivations() { return this.rpc("omni_getactivations"); } omni_getpayload(params) { return this.rpc("omni_getpayload", params); } omni_getcurrentconsensushash() { return this.rpc("omni_getcurrentconsensushash"); } omni_getnonfungibletokens(params) { return this.rpc("omni_getnonfungibletokens", params); } omni_getnonfungibletokendata(params) { return this.rpc("omni_getnonfungibletokendata", params); } omni_getnonfungibletokenranges(params) { return this.rpc("omni_getnonfungibletokenranges", params); } getaddresstxids(params) { return this.rpc("getaddresstxids", params); } getaddressdeltas(params) { return this.rpc("getaddressdeltas", params); } getaddressbalance(params) { return this.rpc("getaddressbalance", params); } getaddressutxos(params) { return this.rpc("getaddressutxos", params); } getaddressmempool(params) { return this.rpc("getaddressmempool", params); } getblockhashes(params) { return this.rpc("getblockhashes", params); } getspentinfo(params) { return this.rpc("getspentinfo", params); } omni_decodetransaction(params) { return this.rpc("omni_decodetransaction", params); } omni_createrawtx_opreturn(params) { return this.rpc("omni_createrawtx_opreturn", params); } omni_createrawtx_input(params) { return this.rpc("omni_createrawtx_input", params); } omni_createrawtx_reference(params) { return this.rpc("omni_createrawtx_reference", params); } omni_createrawtx_change(params) { return this.rpc("omni_createrawtx_change", params); } omni_createpayload_simplesend(params) { return this.rpc("omni_createpayload_simplesend", params); } omni_createpayload_sendall(params) { return this.rpc("omni_createpayload_sendall", params); } omni_createpayload_dexsell(params) { return this.rpc("omni_createpayload_dexsell", params); } omni_createpayload_dexaccept(params) { return this.rpc("omni_createpayload_dexaccept", params); } omni_createpayload_sto(params) { return this.rpc("omni_createpayload_sto", params); } omni_createpayload_issuancefixed(params) { return this.rpc("omni_createpayload_issuancefixed", params); } omni_createpayload_issuancecrowdsale(params) { return this.rpc("omni_createpayload_issuancecrowdsale", params); } omni_createpayload_issuancemanaged(params) { return this.rpc("omni_createpayload_issuancemanaged", params); } omni_createpayload_closecrowdsale(params) { return this.rpc("omni_createpayload_closecrowdsale", params); } omni_createpayload_grant(params) { return this.rpc("omni_createpayload_grant", params); } omni_createpayload_revoke(params) { return this.rpc("omni_createpayload_revoke", params); } omni_createpayload_changeissuer(params) { return this.rpc("omni_createpayload_changeissuer", params); } omni_createpayload_enablefreezing(params) { return this.rpc("omni_createpayload_enablefreezing", params); } omni_createpayload_disablefreezing(params) { return this.rpc("omni_createpayload_disablefreezing", params); } omni_createpayload_freeze(params) { return this.rpc("omni_createpayload_freeze", params); } omni_createpayload_unfreeze(params) { return this.rpc("omni_createpayload_unfreeze", params); } omni_createpayload_anydata(params) { return this.rpc("omni_createpayload_anydata", params); } omni_createpayload_sendnonfungible(params) { return this.rpc("omni_createpayload_sendnonfungible", params); } omni_createpayload_setnonfungibledata(params) { return this.rpc("omni_createpayload_setnonfungibledata", params); } omni_getfeecache(params) { return this.rpc("omni_getfeecache", params); } omni_getfeetrigger(params) { return this.rpc("omni_getfeetrigger", params); } omni_getfeeshare(params) { return this.rpc("omni_getfeeshare", params); } omni_getfeedistribution(params) { return this.rpc("omni_getfeedistribution", params); } omni_getfeedistributions(params) { return this.rpc("omni_getfeedistributions", params); } omni_setautocommit(params) { return this.rpc("omni_setautocommit", params); } } exports.RPCClient = RPCClient;