diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -20,7 +20,7 @@ "getavalanchekey", "Returns the key used to sign avalanche messages.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::STR_HEX, "", ""}, RPCExamples{HelpExampleRpc("getavalanchekey", "")}, } .Check(request); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -432,7 +432,7 @@ "Waits for the validation interface queue to catch up on everything " "that was there when we entered this function.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("syncwithvalidationinterfacequeue", "") + HelpExampleRpc("syncwithvalidationinterfacequeue", "")}, } @@ -1778,7 +1778,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as precious"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("preciousblock", "\"blockhash\"") + HelpExampleRpc("preciousblock", "\"blockhash\"")}, } @@ -1816,7 +1816,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("finalizeblock", "\"blockhash\"") + HelpExampleRpc("finalizeblock", "\"blockhash\"")}, } @@ -1858,7 +1858,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + HelpExampleRpc("invalidateblock", "\"blockhash\"")}, } @@ -1896,7 +1896,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to park"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("parkblock", "\"blockhash\"") + HelpExampleRpc("parkblock", "\"blockhash\"")}, } @@ -1938,7 +1938,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to reconsider"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("reconsiderblock", "\"blockhash\"") + HelpExampleRpc("reconsiderblock", "\"blockhash\"")}, } @@ -1976,7 +1976,7 @@ {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to unpark"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("unparkblock", "\"blockhash\"") + HelpExampleRpc("unparkblock", "\"blockhash\"")}, } @@ -2425,7 +2425,7 @@ "Dumps the mempool to disk. It will fail until the previous dump is " "fully loaded.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("savemempool", "") + HelpExampleRpc("savemempool", "")}, } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1034,7 +1034,9 @@ "dummy value, for compatibility with BIP22. This value is " "ignored."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", + "Returns JSON Null when valid, a string according to BIP22 " + "otherwise"}, RPCExamples{HelpExampleCli("submitblock", "\"mydata\"") + HelpExampleRpc("submitblock", "\"mydata\"")}, } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -440,7 +440,7 @@ "\n" " Pass 0 to go back to using the system time."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, } .Check(request); @@ -483,7 +483,7 @@ {"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, "Number of seconds to forward the scheduler into the future."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, } .Check(request); @@ -731,7 +731,8 @@ "argument conversion enabled in the client-side table in " "bitcoin-cli and the GUI. There is no server-side difference.", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", + "Returns whatever was passed in"}, RPCExamples{""}, } .ToString()); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -61,7 +61,7 @@ "Ping command is handled in queue with all other commands, so it " "measures processing backlog, not just network ping.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("ping", "") + HelpExampleRpc("ping", "")}, } .Check(request); @@ -311,7 +311,7 @@ "node from the list, 'onetry' to try a connection to the " "node once"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")}, @@ -364,7 +364,7 @@ /* default */ "fallback to address", "The node ID (see getpeerinfo for node IDs)"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"") + HelpExampleCli("disconnectnode", "\"\" 1") + HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"") + @@ -720,7 +720,7 @@ "If set, the bantime must be an absolute timestamp expressed in " + UNIX_EPOCH_TIME}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400") + HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"") + @@ -810,7 +810,20 @@ "listbanned", "List all manually banned IPs/Subnets.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::ARR, + "", + "", + { + {RPCResult::Type::OBJ, + "", + "", + { + {RPCResult::Type::STR, "address", ""}, + {RPCResult::Type::NUM_TIME, "banned_until", ""}, + {RPCResult::Type::NUM_TIME, "ban_created", ""}, + {RPCResult::Type::STR, "ban_reason", ""}, + }}, + }}, RPCExamples{HelpExampleCli("listbanned", "") + HelpExampleRpc("listbanned", "")}, } @@ -845,7 +858,7 @@ "clearbanned", "Clear all banned IPs.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("clearbanned", "") + HelpExampleRpc("clearbanned", "")}, } @@ -872,7 +885,7 @@ {"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, "true to enable networking, false to disable"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::BOOL, "", "The value that was passed in"}, RPCExamples{""}, } .Check(request); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -196,6 +196,7 @@ } static UniValue stop(const Config &config, const JSONRPCRequest &jsonRequest) { + static const std::string RESULT{PACKAGE_NAME " stopping"}; // Accept the deprecated and ignored 'detach' boolean argument // Also accept the hidden 'wait' integer argument (milliseconds) // For instance, 'stop 1000' makes the call wait 1 second before returning @@ -205,7 +206,8 @@ "stop", "\nRequest a graceful shutdown of " PACKAGE_NAME ".", {}, - RPCResults{}, + RPCResult{RPCResult::Type::STR, "", + "A string with the content '" + RESULT + "'"}, RPCExamples{""}, } .ToString()); @@ -218,7 +220,7 @@ UninterruptibleSleep( std::chrono::milliseconds{jsonRequest.params[0].get_int()}); } - return PACKAGE_NAME " stopping"; + return RESULT; } static UniValue uptime(const Config &config, const JSONRPCRequest &request) { diff --git a/src/rpc/util.h b/src/rpc/util.h --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -307,8 +307,6 @@ struct RPCResults { const std::vector m_results; - RPCResults() : m_results{} {} - RPCResults(RPCResult result) : m_results{{result}} {} RPCResults(std::initializer_list results) : m_results{results} {} diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -124,7 +124,7 @@ {"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ "\nDump a private key\n" + HelpExampleCli("dumpprivkey", "\"myaddress\"") + @@ -228,7 +228,8 @@ "importprivkey call.\n" "Note: Use \"getwalletinfo\" to query the scanning progress.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::BOOL, "", + "Whether the abort was successful"}, RPCExamples{"\nImport a private key\n" + HelpExampleCli("importprivkey", "\"mykey\"") + "\nAbort the running wallet rescan\n" + @@ -279,7 +280,7 @@ {"p2sh", RPCArg::Type::BOOL, /* default */ "false", "Add the P2SH version of the script as well"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ "\nImport an address with rescan\n" + HelpExampleCli("importaddress", "\"myaddress\"") + @@ -396,7 +397,7 @@ {"txoutproof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex output from gettxoutproof that contains the transaction"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{""}, } .Check(request); @@ -471,7 +472,7 @@ {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded id of the transaction you are deleting"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf4644" "6a512166eae7628734ea0a5\"") + @@ -529,7 +530,7 @@ {"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ "\nImport a public key with rescan\n" + HelpExampleCli("importpubkey", "\"mypubkey\"") + @@ -624,7 +625,7 @@ {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet file"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{"\nDump the wallet\n" + HelpExampleCli("dumpwallet", "\"test\"") + "\nImport the wallet\n" + diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -338,7 +338,7 @@ {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label to assign to the address."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ HelpExampleCli("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + @@ -886,7 +886,7 @@ "getunconfirmedbalance", "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NUM, "", "The balance"}, RPCExamples{""}, } .Check(request); @@ -2173,7 +2173,7 @@ {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c" "5cf302fc80e9d5fbf5d48d\"") + @@ -2221,7 +2221,7 @@ {"destination", RPCArg::Type::STR, RPCArg::Optional::NO, "The destination directory or file"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("backupwallet", "\"backup.dat\"") + HelpExampleRpc("backupwallet", "\"backup.dat\"")}, } @@ -2257,7 +2257,7 @@ {"newsize", RPCArg::Type::NUM, /* default */ "100", "The new keypool size"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "")}, } @@ -2317,7 +2317,7 @@ "The time to keep the decryption key in seconds; capped at " "100000000 (~3 years)."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ "\nUnlock the wallet for 60 seconds\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") + @@ -2427,7 +2427,7 @@ {"newpassphrase", RPCArg::Type::STR, RPCArg::Optional::NO, "The new passphrase"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"") + HelpExampleRpc("walletpassphrasechange", @@ -2486,7 +2486,7 @@ "before being able to call any methods which require the wallet to be " "unlocked.\n", {}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ "\nSet the passphrase for 2 minutes to perform a transaction\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + @@ -2538,7 +2538,8 @@ "The pass phrase to encrypt the wallet with. It must be at least " "1 character, but should be long."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::STR, "", + "A string with further instructions"}, RPCExamples{ "\nEncrypt your wallet\n" + HelpExampleCli("encryptwallet", "\"my pass phrase\"") + @@ -3409,7 +3410,7 @@ /* default */ "the wallet name from the RPC request", "The name of the wallet to unload."}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("unloadwallet", "wallet_name") + HelpExampleRpc("unloadwallet", "wallet_name")}, } @@ -3530,9 +3531,8 @@ {RPCResult::Type::BOOL, "safe", "Whether this output is considered safe to spend. " "Unconfirmed transactions\n" - " from outside keys and " - "unconfirmed replacement transactions are considered " - "unsafe\n" + "from outside keys and unconfirmed replacement " + "transactions are considered unsafe\n" "and are not eligible for spending by fundrawtransaction " "and sendtoaddress."}, }}, @@ -4654,7 +4654,7 @@ "using the dumpwallet command. It is the private key marked " "hdseed=1"}, }, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("sethdseed", "") + HelpExampleCli("sethdseed", "false") + HelpExampleCli("sethdseed", "true \"wifkey\"") + @@ -5014,7 +5014,7 @@ /* default */ strprintf("%d", FEATURE_LATEST), "The version number to upgrade to. Default is the latest " "wallet version"}}, - RPCResults{}, + RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{HelpExampleCli("upgradewallet", "200300") + HelpExampleRpc("upgradewallet", "200300")}} .Check(request);