From f46617dbab793b1dc7029055d104d33d4748d788 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Thu, 14 May 2020 20:10:58 +0000 Subject: [PATCH] add litemode information to help texts regarding CL/IS and change getbestchainlock to throw an error if running in litemode (#3478) Signed-off-by: Pasta --- src/rpc/blockchain.cpp | 12 +++++++++--- src/rpc/rawtransaction.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 18 +++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9efc35841d..ab67ab1545 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -225,7 +225,8 @@ UniValue getbestchainlock(const JSONRPCRequest& request) if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getbestchainlock\n" - "\nReturns the block hash of the best chainlock. Throws an error if there is no known chainlock yet.\n" + "\nReturns the block hash of the best chainlock. Throws an error if there is no known chainlock yet. " + "Will throw an error if running in litemode.\n" "\nResult:\n" "{\n" " \"blockhash\" : \"hash\", (string) The block hash hex encoded\n" @@ -237,6 +238,11 @@ UniValue getbestchainlock(const JSONRPCRequest& request) + HelpExampleRpc("getbestchainlock", "") ); UniValue result(UniValue::VOBJ); + + if (fLiteMode) { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Chainlock information not available in litemode."); + } + llmq::CChainLockSig clsig = llmq::chainLocksHandler->GetBestChainLock(); if (clsig.IsNull()) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to find any chainlock"); @@ -413,7 +419,7 @@ std::string EntryDescriptionString() " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n" " \"transactionid\", (string) parent transaction id\n" " ... ],\n" - " \"instantlock\" : true|false (boolean) True if this transaction was locked via InstantSend\n"; + " \"instantlock\" : true|false (boolean) True if this transaction was locked via InstantSend. Always false if litemode is enabled\n"; } void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) @@ -1675,7 +1681,7 @@ UniValue getmempoolinfo(const JSONRPCRequest& request) " \"maxmempool\": xxxxx, (numeric) Maximum memory usage for the mempool\n" " \"mempoolminfee\": xxxxx (numeric) Minimum fee rate in " + CURRENCY_UNIT + "/kB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee\n" " \"minrelaytxfee\": xxxxx (numeric) Current minimum relay fee for transactions\n" - " \"instantsendlocks\": xxxxx, (numeric) Number of unconfirmed instant send locks\n" + " \"instantsendlocks\": xxxxx, (numeric) Number of unconfirmed instant send locks. Always 0 if litemode is enabled\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmempoolinfo", "") diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 6b9c554ca0..71d5b0e86f 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -171,9 +171,9 @@ UniValue getrawtransaction(const JSONRPCRequest& request) " \"confirmations\" : n, (numeric) The confirmations\n" " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n" " \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"instantlock\" : true|false, (bool) Current transaction lock state\n" - " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state\n" - " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" + " \"instantlock\" : true|false, (bool) Current transaction lock state. Always false if litemode is enabled\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Always false if litemode is enabled\n" + " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock. Always false if litemode is enabled\n" "}\n" "\nExamples:\n" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7fa668959c..ed76222c65 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1651,9 +1651,9 @@ UniValue listtransactions(const JSONRPCRequest& request) " \"confirmations\": n, (numeric) The number of blockchain confirmations for the transaction. Available for 'send' and \n" " 'receive' category of transactions. Negative confirmations indicate the\n" " transation conflicts with the block chain\n" - " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" - " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions.\n" - " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" + " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions. Always false if litemode is enabled\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions. Always false if litemode is enabled\n" + " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock. Always false if litemode is enabled\n" " \"trusted\": xxx, (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n" " category of transactions.\n" @@ -1874,9 +1874,9 @@ UniValue listsinceblock(const JSONRPCRequest& request) " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n" " \"confirmations\" : n, (numeric) The number of blockchain confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" " When it's < 0, it means the transaction conflicted that many blocks ago.\n" - " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" - " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions.\n" - " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" + " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions. Always false if litemode is enabled\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Available for 'send' and 'receive' category of transactions. Always false if litemode is enabled\n" + " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock. Always false if litemode is enabled\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" @@ -2005,9 +2005,9 @@ UniValue gettransaction(const JSONRPCRequest& request) " \"amount\" : x.xxx, (numeric) The transaction amount in " + CURRENCY_UNIT + "\n" " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" " 'send' category of transactions.\n" - " \"instantlock\" : true|false, (bool) Current transaction lock state\n" - " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state\n" - " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n" + " \"instantlock\" : true|false, (bool) Current transaction lock state. Always false if litemode is enabled\n" + " \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state. Always false if litemode is enabled\n" + " \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock. Always false if litemode is enabled\n" " \"confirmations\" : n, (numeric) The number of blockchain confirmations\n" " \"blockhash\" : \"hash\", (string) The block hash\n" " \"blockindex\" : xx, (numeric) The index of the transaction in the block that includes it\n"