Merge pull request #4567 from dzutte-cpp/merge_14987_14918

Merge bitcoin#14987 and bitcoin#14918
This commit is contained in:
PastaPastaPasta 2021-11-13 15:15:11 -05:00 committed by GitHub
commit 4bf6dc07d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 2127 additions and 1717 deletions

View File

@ -190,14 +190,16 @@ static UniValue getblockcount(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getblockcount",
"\nReturns the number of blocks in the longest blockchain.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the number of blocks in the longest blockchain.\n",
{},
RPCResult{
"n (numeric) The current block count\n"
"\nExamples:\n"
+ HelpExampleCli("getblockcount", "")
},
RPCExamples{
HelpExampleCli("getblockcount", "")
+ HelpExampleRpc("getblockcount", "")
);
},
}.ToString());
LOCK(cs_main);
return ::ChainActive().Height();
@ -208,14 +210,16 @@ static UniValue getbestblockhash(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getbestblockhash",
"\nReturns the hash of the best (tip) block in the longest blockchain.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the hash of the best (tip) block in the longest blockchain.\n",
{},
RPCResult{
"\"hex\" (string) the block hash, hex-encoded\n"
"\nExamples:\n"
+ HelpExampleCli("getbestblockhash", "")
},
RPCExamples{
HelpExampleCli("getbestblockhash", "")
+ HelpExampleRpc("getbestblockhash", "")
);
},
}.ToString());
LOCK(cs_main);
return ::ChainActive().Tip()->GetBlockHash().GetHex();
@ -227,19 +231,20 @@ static UniValue getbestchainlock(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"getbestchainlock",
"\nReturns information about the best chainlock. Throws an error if there is no known chainlock yet.",
{}
}.ToString() +
"\nResult:\n"
"{\n"
" \"blockhash\" : \"hash\", (string) The block hash hex-encoded\n"
" \"height\" : n, (numeric) The block height or index\n"
" \"signature\" : \"hash\", (string) The chainlock's BLS signature.\n"
" \"known_block\" : true|false (boolean) True if the block is known by our node\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getbestchainlock", "")
+ HelpExampleRpc("getbestchainlock", "")
);
{},
RPCResult{
"{\n"
" \"blockhash\" : \"hash\", (string) The block hash hex-encoded\n"
" \"height\" : n, (numeric) The block height or index\n"
" \"signature\" : \"hash\", (string) The chainlock's BLS signature.\n"
" \"known_block\" : true|false (boolean) True if the block is known by our node\n"
"}\n"
},
RPCExamples{
HelpExampleCli("getbestchainlock", "")
+ HelpExampleRpc("getbestchainlock", "")
},
}.ToString());
UniValue result(UniValue::VOBJ);
llmq::CChainLockSig clsig = llmq::chainLocksHandler->GetBestChainLock();
@ -273,20 +278,19 @@ static UniValue waitfornewblock(const JSONRPCRequest& request)
"\nWaits for a specific new block and returns useful info about it.\n"
"\nReturns the current block on timeout or exit.\n",
{
{"timeout", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", ""},
}}
.ToString() +
"\nArguments:\n"
"1. timeout (int, optional, default=0) Time in milliseconds to wait for a response. 0 indicates no timeout.\n"
"\nResult:\n"
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
},
RPCResult{
"{ (json object)\n"
" \"hash\" : { (string) The blockhash\n"
" \"height\" : { (int) Block height\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("waitfornewblock", "1000")
},
RPCExamples{
HelpExampleCli("waitfornewblock", "1000")
+ HelpExampleRpc("waitfornewblock", "1000")
);
},
}.ToString());
int timeout = 0;
if (!request.params[0].isNull())
timeout = request.params[0].get_int();
@ -315,19 +319,20 @@ static UniValue waitforblock(const JSONRPCRequest& request)
"\nWaits for a specific new block and returns useful info about it.\n"
"\nReturns the current block on timeout or exit.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Block hash to wait for."},
{"timeout", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
}}
.ToString() +
"\nResult:\n"
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash to wait for."},
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
},
RPCResult{
"{ (json object)\n"
" \"hash\" : { (string) The blockhash\n"
" \"height\" : { (int) Block height\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
},
RPCExamples{
HelpExampleCli("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
+ HelpExampleRpc("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
);
},
}.ToString());
int timeout = 0;
uint256 hash = uint256S(request.params[0].get_str());
@ -360,19 +365,20 @@ static UniValue waitforblockheight(const JSONRPCRequest& request)
"of the current tip.\n"
"\nReturns the current block on timeout or exit.\n",
{
{"height", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Block height to wait for."},
{"timeout", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
}}
.ToString() +
"\nResult:\n"
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "Block height to wait for."},
{"timeout", RPCArg::Type::NUM, /* default */ "0", "Time in milliseconds to wait for a response. 0 indicates no timeout."},
},
RPCResult{
"{ (json object)\n"
" \"hash\" : { (string) The blockhash\n"
" \"height\" : { (int) Block height\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("waitforblockheight", "\"100\", 1000")
},
RPCExamples{
HelpExampleCli("waitforblockheight", "\"100\", 1000")
+ HelpExampleRpc("waitforblockheight", "\"100\", 1000")
);
},
}.ToString());
int timeout = 0;
int height = request.params[0].get_int();
@ -401,12 +407,14 @@ static UniValue syncwithvalidationinterfacequeue(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() > 0) {
throw std::runtime_error(
RPCHelpMan{"syncwithvalidationinterfacequeue",
"\nWaits for the validation interface queue to catch up on everything that was there when we entered this function.\n", {}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("syncwithvalidationinterfacequeue","")
"\nWaits for the validation interface queue to catch up on everything that was there when we entered this function.\n",
{},
RPCResults{},
RPCExamples{
HelpExampleCli("syncwithvalidationinterfacequeue","")
+ HelpExampleRpc("syncwithvalidationinterfacequeue","")
);
},
}.ToString());
}
SyncWithValidationInterfaceQueue();
return NullUniValue;
@ -417,14 +425,16 @@ static UniValue getdifficulty(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getdifficulty",
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n",
{},
RPCResult{
"n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n"
"\nExamples:\n"
+ HelpExampleCli("getdifficulty", "")
},
RPCExamples{
HelpExampleCli("getdifficulty", "")
+ HelpExampleRpc("getdifficulty", "")
);
},
}.ToString());
LOCK(cs_main);
return GetDifficulty(::ChainActive().Tip());
@ -542,10 +552,9 @@ static UniValue getrawmempool(const JSONRPCRequest& request)
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
"\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
{
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "True for a json object, false for array of transaction ids"},
}}
.ToString() +
"\nResult: (for verbose = false):\n"
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
},
RPCResult{"for verbose = false",
"[ (json array of string)\n"
" \"transactionid\" (string) The transaction id\n"
" ,...\n"
@ -556,10 +565,12 @@ static UniValue getrawmempool(const JSONRPCRequest& request)
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getrawmempool", "true")
},
RPCExamples{
HelpExampleCli("getrawmempool", "true")
+ HelpExampleRpc("getrawmempool", "true")
);
},
}.ToString());
bool fVerbose = false;
if (!request.params[0].isNull())
@ -575,25 +586,29 @@ static UniValue getmempoolancestors(const JSONRPCRequest& request)
RPCHelpMan{"getmempoolancestors",
"\nIf txid is in the mempool, returns all in-mempool ancestors.\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id (must be in mempool)"},
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "True for a json object, false for array of transaction ids"},
}}
.ToString() +
"\nResult (for verbose = false):\n"
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
},
{
RPCResult{"for verbose = false",
"[ (json array of strings)\n"
" \"transactionid\" (string) The transaction id of an in-mempool ancestor transaction\n"
" ,...\n"
"]\n"
"\nResult (for verbose = true):\n"
},
RPCResult{"for verbose = true",
"{ (json object)\n"
" \"transactionid\" : { (json object)\n"
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmempoolancestors", "\"mytxid\"")
},
},
RPCExamples{
HelpExampleCli("getmempoolancestors", "\"mytxid\"")
+ HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
);
},
}.ToString());
}
bool fVerbose = false;
@ -641,25 +656,29 @@ static UniValue getmempooldescendants(const JSONRPCRequest& request)
RPCHelpMan{"getmempooldescendants",
"\nIf txid is in the mempool, returns all in-mempool descendants.\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id (must be in mempool)"},
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "True for a json object, false for array of transaction ids"},
}}
.ToString() +
"\nResult (for verbose = false):\n"
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "True for a json object, false for array of transaction ids"},
},
{
RPCResult{"for verbose = false",
"[ (json array of strings)\n"
" \"transactionid\" (string) The transaction id of an in-mempool descendant transaction\n"
" ,...\n"
"]\n"
"\nResult (for verbose = true):\n"
},
RPCResult{"for verbose = true",
"{ (json object)\n"
" \"transactionid\" : { (json object)\n"
+ EntryDescriptionString()
+ " }, ...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmempooldescendants", "\"mytxid\"")
},
},
RPCExamples{
HelpExampleCli("getmempooldescendants", "\"mytxid\"")
+ HelpExampleRpc("getmempooldescendants", "\"mytxid\"")
);
},
}.ToString());
}
bool fVerbose = false;
@ -707,17 +726,18 @@ static UniValue getmempoolentry(const JSONRPCRequest& request)
RPCHelpMan{"getmempoolentry",
"\nReturns mempool data for given transaction\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id (must be in mempool)"},
}}
.ToString() +
"\nResult:\n"
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (must be in mempool)"},
},
RPCResult{
"{ (json object)\n"
+ EntryDescriptionString()
+ "}\n"
"\nExamples:\n"
+ HelpExampleCli("getmempoolentry", "\"mytxid\"")
},
RPCExamples{
HelpExampleCli("getmempoolentry", "\"mytxid\"")
+ HelpExampleRpc("getmempoolentry", "\"mytxid\"")
);
},
}.ToString());
}
uint256 hash = ParseHashV(request.params[0], "parameter 1");
@ -742,18 +762,19 @@ static UniValue getblockhashes(const JSONRPCRequest& request)
RPCHelpMan{"getblockhashes",
"\nReturns array of hashes of blocks within the timestamp range provided.\n",
{
{"high", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The newer block timestamp"},
{"low", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The older block timestamp"},
}}
.ToString() +
"\nResult:\n"
"[\n"
" \"hash\" (string) The block hash\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getblockhashes", "1231614698 1231024505")
+ HelpExampleRpc("getblockhashes", "1231614698, 1231024505")
);
{"high", RPCArg::Type::NUM, RPCArg::Optional::NO, "The newer block timestamp"},
{"low", RPCArg::Type::NUM, RPCArg::Optional::NO, "The older block timestamp"},
},
RPCResult{
"[\n"
" \"hash\" (string) The block hash\n"
"]\n"
},
RPCExamples{
HelpExampleCli("getblockhashes", "1231614698 1231024505")
+ HelpExampleRpc("getblockhashes", "1231614698, 1231024505")
},
}.ToString());
unsigned int high = request.params[0].get_int();
unsigned int low = request.params[1].get_int();
@ -778,15 +799,16 @@ static UniValue getblockhash(const JSONRPCRequest& request)
RPCHelpMan{"getblockhash",
"\nReturns hash of block in best-block-chain at height provided.\n",
{
{"height", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The height index"},
}}
.ToString() +
"\nResult:\n"
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The height index"},
},
RPCResult{
"\"hash\" (string) The block hash\n"
"\nExamples:\n"
+ HelpExampleCli("getblockhash", "1000")
},
RPCExamples{
HelpExampleCli("getblockhash", "1000")
+ HelpExampleRpc("getblockhash", "1000")
);
},
}.ToString());
LOCK(cs_main);
@ -806,11 +828,11 @@ static UniValue getblockheader(const JSONRPCRequest& request)
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
"If verbose is true, returns an Object with information about blockheader <hash>.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"},
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "true for a json object, false for the hex-encoded data"},
}}
.ToString() +
"\nResult (for verbose = true):\n"
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"},
},
{
RPCResult{"for verbose = true",
"{\n"
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
@ -828,12 +850,16 @@ static UniValue getblockheader(const JSONRPCRequest& request)
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\", (string) The hash of the next block\n"
"}\n"
"\nResult (for verbose=false):\n"
},
RPCResult{"for verbose=false",
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
"\nExamples:\n"
+ HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
},
},
RPCExamples{
HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
+ HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
);
},
}.ToString());
std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash));
@ -874,12 +900,12 @@ static UniValue getblockheaders(const JSONRPCRequest& request)
"\nIf verbose is false, each item is a string that is serialized, hex-encoded data for a single blockheader.\n"
"If verbose is true, each item is an Object with information about a single blockheader.\n",
{
{"hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"},
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%s", MAX_HEADERS_RESULTS), ""},
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "true for a json object, false for the hex-encoded data"},
}}
.ToString() +
"\nResult (for verbose = true):\n"
{"hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""},
{"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"},
},
RPCResults{
{"for verbose = true",
"[ {\n"
" \"hash\" : \"hash\", (string) The block hash\n"
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
@ -899,15 +925,17 @@ static UniValue getblockheaders(const JSONRPCRequest& request)
" },\n"
"...\n"
"]\n"
"\nResult (for verbose=false):\n"
},{"for verbose=false",
"[\n"
" \"data\", (string) A string that is serialized, hex-encoded data for block header.\n"
" ...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000")
}},
RPCExamples{
HelpExampleCli("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000")
+ HelpExampleRpc("getblockheaders", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" 2000")
);
},
}.ToString());
LOCK(cs_main);
@ -983,20 +1011,21 @@ static UniValue getmerkleblocks(const JSONRPCRequest& request)
RPCHelpMan{"getmerkleblocks",
"\nReturns an array of hex-encoded merkleblocks for <count> blocks starting from <hash> which match <filter>.\n",
{
{"filter", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex-encoded bloom filter"},
{"hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"},
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%s", MAX_HEADERS_RESULTS), ""},
}}
.ToString() +
"\nResult:\n"
{"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"},
{"hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_RESULTS), ""},
},
RPCResult{
"[\n"
" \"data\", (string) A string that is serialized, hex-encoded data for a merkleblock.\n"
" ...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000")
},
RPCExamples{
HelpExampleCli("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000")
+ HelpExampleRpc("getmerkleblocks", "\"2303028005802040100040000008008400048141010000f8400420800080025004000004130000000000000001\" \"00000000007e1432d2af52e8463278bf556b55cf5049262f25634557e2e91202\" 2000")
);
},
}.ToString());
LOCK(cs_main);
@ -1063,13 +1092,14 @@ static UniValue getblock(const JSONRPCRequest& request)
"If verbosity is 1, returns an Object with information about block <hash>.\n"
"If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"},
{"verbosity", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1", "0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"},
}}
.ToString() +
"\nResult (for verbosity = 0):\n"
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"verbosity", RPCArg::Type::NUM, /* default */ "1", "0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"},
},
{
RPCResult{"for verbosity = 0",
"\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n"
"\nResult (for verbose = 1):\n"
},
RPCResult{"for verbosity = 1",
"{\n"
" \"hash\" : \"hash\", (string) the block hash (same as provided)\n"
" \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n"
@ -1098,7 +1128,8 @@ static UniValue getblock(const JSONRPCRequest& request)
" \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n"
" \"nextblockhash\" : \"hash\" (string) The hash of the next block\n"
"}\n"
"\nResult (for verbosity = 2):\n"
},
RPCResult{"for verbosity = 2",
"{\n"
" ..., Same output as verbosity = 1.\n"
" \"tx\" : [ (array of Objects) The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result.\n"
@ -1106,10 +1137,13 @@ static UniValue getblock(const JSONRPCRequest& request)
" ],\n"
" ,... Same output as verbosity = 1.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblock", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
},
},
RPCExamples{
HelpExampleCli("getblock", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
+ HelpExampleRpc("getblock", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
);
},
}.ToString());
LOCK(cs_main);
@ -1148,15 +1182,17 @@ static UniValue pruneblockchain(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"pruneblockchain", "",
{
{"height", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
{"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block height to prune up to. May be set to a discrete height, or a unix timestamp\n"
" to prune blocks whose block time is at least 2 hours older than the provided timestamp."},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"n (numeric) Height of the last block pruned.\n"
"\nExamples:\n"
+ HelpExampleCli("pruneblockchain", "1000")
+ HelpExampleRpc("pruneblockchain", "1000"));
},
RPCExamples{
HelpExampleCli("pruneblockchain", "1000")
+ HelpExampleRpc("pruneblockchain", "1000")
},
}.ToString());
if (!fPruneMode)
throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
@ -1200,9 +1236,8 @@ static UniValue gettxoutsetinfo(const JSONRPCRequest& request)
RPCHelpMan{"gettxoutsetinfo",
"\nReturns statistics about the unspent transaction output set.\n"
"Note this call may take some time.\n",
{}}
.ToString() +
"\nResult:\n"
{},
RPCResult{
"{\n"
" \"height\":n, (numeric) The current block height (index)\n"
" \"bestblock\": \"hex\", (string) The hash of the block at the tip of the chain\n"
@ -1213,10 +1248,12 @@ static UniValue gettxoutsetinfo(const JSONRPCRequest& request)
" \"disk_size\": n, (numeric) The estimated size of the chainstate on disk\n"
" \"total_amount\": x.xxx (numeric) The total amount\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("gettxoutsetinfo", "")
},
RPCExamples{
HelpExampleCli("gettxoutsetinfo", "")
+ HelpExampleRpc("gettxoutsetinfo", "")
);
},
}.ToString());
UniValue ret(UniValue::VOBJ);
@ -1246,12 +1283,11 @@ static UniValue gettxout(const JSONRPCRequest& request)
RPCHelpMan{"gettxout",
"\nReturns details about an unspent transaction output.\n",
{
{"txid", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The transaction id"},
{"n", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "vout number"},
{"include_mempool", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."},
}}
.ToString() +
"\nResult:\n"
{"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
{"n", RPCArg::Type::NUM, RPCArg::Optional::NO, "vout number"},
{"include_mempool", RPCArg::Type::BOOL, /* default */ "true", "Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."},
},
RPCResult{
"{\n"
" \"bestblock\": \"hash\", (string) The hash of the block at the tip of the chain\n"
" \"confirmations\" : n, (numeric) The number of confirmations\n"
@ -1268,15 +1304,16 @@ static UniValue gettxout(const JSONRPCRequest& request)
" },\n"
" \"coinbase\" : true|false (boolean) Coinbase or not\n"
"}\n"
"\nExamples:\n"
},
RPCExamples{
"\nGet unspent transactions\n"
+ HelpExampleCli("listunspent", "") +
"\nView the details\n"
+ HelpExampleCli("gettxout", "\"txid\" 1") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("gettxout", "\"txid\", 1")
);
},
}.ToString());
LOCK(cs_main);
@ -1330,16 +1367,17 @@ static UniValue verifychain(const JSONRPCRequest& request)
RPCHelpMan{"verifychain",
"\nVerifies blockchain database.\n",
{
{"checklevel", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%d, range=0-4", nCheckLevel), "How thorough the block verification is."},
{"nblocks", RPCArg::Type::NUM, /* opt */ true, /* default_val */ strprintf("%d, 0=all", nCheckDepth), "The number of blocks to check."},
}}
.ToString() +
"\nResult:\n"
{"checklevel", RPCArg::Type::NUM, /* default */ strprintf("%d, range=0-4", nCheckLevel), "How thorough the block verification is."},
{"nblocks", RPCArg::Type::NUM, /* default */ strprintf("%d, 0=all", nCheckDepth), "The number of blocks to check."},
},
RPCResult{
"true|false (boolean) Verified or not\n"
"\nExamples:\n"
+ HelpExampleCli("verifychain", "")
},
RPCExamples{
HelpExampleCli("verifychain", "")
+ HelpExampleRpc("verifychain", "")
);
},
}.ToString());
LOCK(cs_main);
@ -1428,9 +1466,9 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getblockchaininfo",
"Returns an object containing various state info regarding blockchain processing.\n", {}}
.ToString() +
"\nResult:\n"
"Returns an object containing various state info regarding blockchain processing.\n",
{},
RPCResult{
"{\n"
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest) and\n"
" devnet or devnet-<name> for \"-devnet\" and \"-devnet=<name>\" respectively\n"
@ -1474,10 +1512,12 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
" }\n"
" \"warnings\" : \"...\", (string) any network and blockchain warnings.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblockchaininfo", "")
},
RPCExamples{
HelpExampleCli("getblockchaininfo", "")
+ HelpExampleRpc("getblockchaininfo", "")
);
},
}.ToString());
LOCK(cs_main);
@ -1553,11 +1593,10 @@ static UniValue getchaintips(const JSONRPCRequest& request)
"Return information about all known tips in the block tree,"
" including the main chain as well as orphaned branches.\n",
{
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "only show this much of latest tips"},
{"branchlen", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "only show tips that have equal or greater length of branch"},
}}
.ToString() +
"\nResult:\n"
{"count", RPCArg::Type::NUM, /* default */ "", "only show this much of latest tips"},
{"branchlen", RPCArg::Type::NUM, /* default */ "", "only show tips that have equal or greater length of branch"},
},
RPCResult{
"[\n"
" {\n"
" \"height\": xxxx, (numeric) height of the chain tip\n"
@ -1584,10 +1623,12 @@ static UniValue getchaintips(const JSONRPCRequest& request)
"3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n"
"4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n"
"5. \"active\" This is the tip of the active main chain, which is certainly valid\n"
"\nExamples:\n"
+ HelpExampleCli("getchaintips", "")
},
RPCExamples{
HelpExampleCli("getchaintips", "")
+ HelpExampleRpc("getchaintips", "")
);
},
}.ToString());
LOCK(cs_main);
@ -1700,9 +1741,9 @@ static UniValue getmempoolinfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getmempoolinfo",
"\nReturns details on the active state of the TX memory pool.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns details on the active state of the TX memory pool.\n",
{},
RPCResult{
"{\n"
" \"size\": xxxxx, (numeric) Current tx count\n"
" \"bytes\": xxxxx, (numeric) Sum of all tx sizes\n"
@ -1712,10 +1753,12 @@ static UniValue getmempoolinfo(const JSONRPCRequest& request)
" \"minrelaytxfee\": xxxxx (numeric) Current minimum relay fee for transactions\n"
" \"instantsendlocks\": xxxxx, (numeric) Number of unconfirmed instant send locks\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmempoolinfo", "")
},
RPCExamples{
HelpExampleCli("getmempoolinfo", "")
+ HelpExampleRpc("getmempoolinfo", "")
);
},
}.ToString());
return MempoolInfoToJSON(::mempool);
}
@ -1729,14 +1772,14 @@ static UniValue preciousblock(const JSONRPCRequest& request)
"\nA later preciousblock call can override the effect of an earlier one.\n"
"\nThe effects of preciousblock are not retained across restarts.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hash of the block to mark as precious"},
}}
.ToString() +
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("preciousblock", "\"blockhash\"")
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as precious"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("preciousblock", "\"blockhash\"")
+ HelpExampleRpc("preciousblock", "\"blockhash\"")
);
},
}.ToString());
std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash));
@ -1767,14 +1810,14 @@ static UniValue invalidateblock(const JSONRPCRequest& request)
RPCHelpMan{"invalidateblock",
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hash of the block to mark as invalid"},
}}
.ToString() +
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("invalidateblock", "\"blockhash\"")
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to mark as invalid"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("invalidateblock", "\"blockhash\"")
+ HelpExampleRpc("invalidateblock", "\"blockhash\"")
);
},
}.ToString());
std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash));
@ -1809,14 +1852,14 @@ static UniValue reconsiderblock(const JSONRPCRequest& request)
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
"This can be used to undo the effects of invalidateblock.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hash of the block to reconsider"},
}}
.ToString() +
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("reconsiderblock", "\"blockhash\"")
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to reconsider"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("reconsiderblock", "\"blockhash\"")
+ HelpExampleRpc("reconsiderblock", "\"blockhash\"")
);
},
}.ToString());
std::string strHash = request.params[0].get_str();
uint256 hash(uint256S(strHash));
@ -1848,11 +1891,10 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
RPCHelpMan{"getchaintxstats",
"\nCompute statistics about the total number and rate of transactions in the chain.\n",
{
{"nblocks", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "one month", "Size of the window in number of blocks"},
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The hash of the block that ends the window."},
}}
.ToString() +
"\nResult:\n"
{"nblocks", RPCArg::Type::NUM, /* default */ "one month", "Size of the window in number of blocks"},
{"blockhash", RPCArg::Type::STR_HEX, /* default */ "chain tip", "The hash of the block that ends the window."},
},
RPCResult{
"{\n"
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
@ -1863,10 +1905,12 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
" \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getchaintxstats", "")
},
RPCExamples{
HelpExampleCli("getchaintxstats", "")
+ HelpExampleRpc("getchaintxstats", "2016")
);
},
}.ToString());
const CBlockIndex* pindex;
int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month
@ -1984,16 +2028,15 @@ static UniValue getblockstats(const JSONRPCRequest& request)
"It won't work for some heights with pruning.\n"
"It won't work without -txindex for utxo_size_inc, *fee or *feerate stats.\n",
{
{"hash_or_height", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The block hash or height of the target block", "", {"", "string or numeric"}},
{"stats", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "Values to plot, by default all values (see result below)",
{"hash_or_height", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block hash or height of the target block", "", {"", "string or numeric"}},
{"stats", RPCArg::Type::ARR, /* default */ "all values", "Values to plot (see result below)",
{
{"height", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Selected statistic"},
{"time", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Selected statistic"},
{"height", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"},
{"time", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Selected statistic"},
},
"stats"},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{ (json object)\n"
" \"avgfee\": xxxxx, (numeric) Average fee in the block\n"
" \"avgfeerate\": xxxxx, (numeric) Average feerate (in duffs per byte)\n"
@ -2027,10 +2070,12 @@ static UniValue getblockstats(const JSONRPCRequest& request)
" \"utxo_increase\": xxxxx, (numeric) The increase/decrease in the number of unspent outputs\n"
" \"utxo_size_inc\": xxxxx, (numeric) The increase/decrease in size for the utxo index (not discounting op_return and similar)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
},
RPCExamples{
HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
+ HelpExampleRpc("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'")
);
},
}.ToString());
}
if (g_txindex) {
@ -2231,29 +2276,31 @@ static UniValue getspecialtxes(const JSONRPCRequest& request)
"If verbosity is 1, returns hex-encoded data for each transaction.\n"
"If verbosity is 2, returns an Object with information for each transaction.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash"},
{"type", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "-1", "Filter special txes by type, -1 means all types"},
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "10", "The number of transactions to return"},
{"skip", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "The number of transactions to skip"},
{"verbosity", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "0 for hashes, 1 for hex-encoded data, and 2 for json object"},
}}
.ToString() +
"\nResult (for verbosity = 0):\n"
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"type", RPCArg::Type::NUM, /* default */ "-1", "Filter special txes by type, -1 means all types"},
{"count", RPCArg::Type::NUM, /* default */ "10", "The number of transactions to return"},
{"skip", RPCArg::Type::NUM, /* default */ "0", "The number of transactions to skip"},
{"verbosity", RPCArg::Type::NUM, /* default */ "0", "0 for hashes, 1 for hex-encoded data, and 2 for json object"},
},
RPCResults{
{"for verbosity = 0",
"[\n"
" \"txid\" : \"xxxx\", (string) The transaction id\n"
"]\n"
"\nResult (for verbosity = 1):\n"
}, {"for verbosity = 1",
"[\n"
" \"data\", (string) A string that is serialized, hex-encoded data for the transaction\n"
"]\n"
"\nResult (for verbosity = 2):\n"
}, {"for verbosity = 2",
"[ (array of Objects) The transactions in the format of the getrawtransaction RPC.\n"
" ...,\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
}},
RPCExamples{
HelpExampleCli("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
+ HelpExampleRpc("getspecialtxes", "\"00000000000fd08c2fb661d2fcb0d49abb3a91e5f27082ce64feed3b4dede2e2\"")
);
},
}.ToString());
LOCK(cs_main);
@ -2329,12 +2376,14 @@ static UniValue savemempool(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0) {
throw std::runtime_error(
RPCHelpMan{"savemempool",
"\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n", {}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("savemempool", "")
"\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
{},
RPCResults{},
RPCExamples{
HelpExampleCli("savemempool", "")
+ HelpExampleRpc("savemempool", "")
);
},
}.ToString());
}
if (!g_is_mempool_loaded) {
@ -2427,25 +2476,24 @@ UniValue scantxoutset(const JSONRPCRequest& request)
"In the latter case, a range needs to be specified by below if different from 1000.\n"
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
{
{"action", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The action to execute\n"
{"action", RPCArg::Type::STR, RPCArg::Optional::NO, "The action to execute\n"
" \"start\" for starting a scan\n"
" \"abort\" for aborting the current scan (returns true when abort was successful)\n"
" \"status\" for progress report (in %) of the current scan"},
{"scanobjects", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "Array of scan objects\n"
{"scanobjects", RPCArg::Type::ARR, RPCArg::Optional::NO, "Array of scan objects\n"
" Every scan object is either a string descriptor or an object:",
{
{"descriptor", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "An output descriptor"},
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "An object with output descriptor and metadata",
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "An output descriptor"},
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "An object with output descriptor and metadata",
{
{"desc", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "An output descriptor"},
{"range", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1000", "Up to what child index HD chains should be explored"},
{"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "An output descriptor"},
{"range", RPCArg::Type::NUM, /* default */ "1000", "Up to what child index HD chains should be explored"},
},
},
},
"[scanobjects,...]"},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"unspents\": [\n"
" {\n"
@ -2459,6 +2507,9 @@ UniValue scantxoutset(const JSONRPCRequest& request)
" ,...], \n"
" \"total_amount\" : x.xxx, (numeric) The total amount of all found unspent outputs in " + CURRENCY_UNIT + "\n"
"]\n"
},
RPCExamples{""},
}.ToString()
);
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR});
@ -2578,17 +2629,19 @@ static UniValue getblockfilter(const JSONRPCRequest& request)
RPCHelpMan{"getblockfilter",
"\nRetrieve a BIP 157 content filter for a particular block.\n",
{
{"blockhash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The hash of the block"},
{"filtertype", RPCArg::Type::STR, /* opt */ true, /* default_val */ "basic", "The type name of the filter"},
}}
.ToString() +
"\nResult:\n"
{"blockhash", RPCArg::Type::STR, RPCArg::Optional::NO, "The hash of the block"},
{"filtertype", RPCArg::Type::STR, /* default */ "basic", "The type name of the filter"},
},
RPCResult{
"{\n"
" \"filter\" : (string) the hex-encoded filter data\n"
" \"header\" : (string) the hex-encoded filter header\n"
"}\n"
+ HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"")
);
},
RPCExamples{
HelpExampleCli("getblockfilter", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"")
},
}.ToString());
}
uint256 block_hash = ParseHashV(request.params[0], "blockhash");

View File

@ -26,16 +26,16 @@ static UniValue coinjoin(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 1)
throw std::runtime_error(
RPCHelpMan{"coinjoin",
"",
"\nAvailable commands:\n"
" start - Start mixing\n"
" stop - Stop mixing\n"
" reset - Reset mixing",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"},
}}
.ToString() +
"\nAvailable commands:\n"
" start - Start mixing\n"
" stop - Stop mixing\n"
" reset - Reset mixing\n"
);
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
if (fMasternodeMode)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Client-side mixing is not supported on masternodes");
@ -87,9 +87,10 @@ static UniValue getpoolinfo(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"getpoolinfo",
"DEPRECATED. Please use getcoinjoininfo instead.\n",
{}}
.ToString()
);
{},
RPCResults{},
RPCExamples{""}}
.ToString());
}
static UniValue getcoinjoininfo(const JSONRPCRequest& request)
@ -98,9 +99,9 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"getcoinjoininfo",
"Returns an object containing an information about CoinJoin settings and state.\n",
{}}
.ToString() +
"\nResult (for regular nodes):\n"
{},
RPCResults{
{"for regular nodes",
"{\n"
" \"enabled\": true|false, (bool) Whether mixing functionality is enabled\n"
" \"multisession\": true|false, (bool) Whether CoinJoin Multisession option is enabled\n"
@ -126,17 +127,19 @@ static UniValue getcoinjoininfo(const JSONRPCRequest& request)
" \"keys_left\": xxx, (numeric) How many new keys are left since last automatic backup\n"
" \"warnings\": \"...\" (string) Warnings if any\n"
"}\n"
"\nResult (for masternodes):\n"
}, {"for masternodes",
"{\n"
" \"queue_size\": xxx, (numeric) How many queues there are currently on the network\n"
" \"denomination\": xxx, (numeric) The denomination of the mixing session in " + CURRENCY_UNIT + "\n"
" \"state\": \"...\", (string) Current state of the mixing session\n"
" \"entries_count\": xxx, (numeric) The number of entries in the mixing session\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getcoinjoininfo", "")
}},
RPCExamples{
HelpExampleCli("getcoinjoininfo", "")
+ HelpExampleRpc("getcoinjoininfo", "")
);
},
}.ToString());
}
UniValue obj(UniValue::VOBJ);

View File

@ -31,9 +31,11 @@ static void gobject_count_help()
RPCHelpMan{"gobject count",
"Count governance objects and votes\n",
{
{"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "json", "Output format: json (\"json\") or string in free form (\"all\")"},
}}
.ToString());
{"mode", RPCArg::Type::STR, /* default */ "json", "Output format: json (\"json\") or string in free form (\"all\")"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_count(const JSONRPCRequest& request)
@ -59,9 +61,11 @@ static void gobject_deserialize_help()
RPCHelpMan {"gobject deserialize",
"Deserialize governance object from hex string to JSON\n",
{
{"hex_data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"},
}}
.ToString());
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_deserialize(const JSONRPCRequest& request)
@ -86,9 +90,11 @@ static void gobject_check_help()
RPCHelpMan{"gobject check",
"Validate governance object data (proposal only)\n",
{
{"hex_data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string format"},
}}
.ToString());
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string format"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_check(const JSONRPCRequest& request)
@ -131,15 +137,17 @@ static void gobject_prepare_help(CWallet* const pwallet)
"Prepare governance object by signing and creating tx\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
{"parent-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the parent object, \"0\" is root"},
{"revision", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "object revision in the system"},
{"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */"", "time this object was created"},
{"data-hex", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"},
{"use-IS", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Deprecated and ignored"},
{"outputHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "the single output to submit the proposal fee from"},
{"outputIndex", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The output index."},
}}
.ToString());
{"parent-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the parent object, \"0\" is root"},
{"revision", RPCArg::Type::NUM, RPCArg::Optional::NO, "object revision in the system"},
{"time", RPCArg::Type::NUM, RPCArg::Optional::NO, "time this object was created"},
{"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
{"use-IS", RPCArg::Type::BOOL, /* default */ "false", "Deprecated and ignored"},
{"outputHash", RPCArg::Type::STR_HEX, /* default */ "", "the single output to submit the proposal fee from"},
{"outputIndex", RPCArg::Type::NUM, /* default */ "", "The output index."},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_prepare(const JSONRPCRequest& request)
@ -256,9 +264,11 @@ static void gobject_list_prepared_help(CWallet* const pwallet)
"Returns a list of governance objects prepared by this wallet with \"gobject prepare\" sorted by their creation time.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "10", "Maximum number of objects to return."},
}}
.ToString());
{"count", RPCArg::Type::NUM, /* default */ "10", "Maximum number of objects to return."},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_list_prepared(const JSONRPCRequest& request)
@ -305,13 +315,15 @@ static void gobject_submit_help()
RPCHelpMan{"gobject submit",
"Submit governance object to network\n",
{
{"parent-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the parent object, \"0\" is root"},
{"revision", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "object revision in the system"},
{"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "time this object was created"},
{"data-hex", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "data in hex string form"},
{"fee-txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "fee-tx id, required for all objects except triggers"},
}}
.ToString());
{"parent-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the parent object, \"0\" is root"},
{"revision", RPCArg::Type::NUM, RPCArg::Optional::NO, "object revision in the system"},
{"time", RPCArg::Type::NUM, RPCArg::Optional::NO, "time this object was created"},
{"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
{"fee-txid", RPCArg::Type::STR_HEX, /* default */ "", "fee-tx id, required for all objects except triggers"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_submit(const JSONRPCRequest& request)
@ -418,11 +430,13 @@ static void gobject_vote_conf_help()
RPCHelpMan{"gobject vote-conf",
"Vote on a governance object by masternode configured in dash.conf\n",
{
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"},
{"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"},
}}
.ToString());
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"},
{"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_vote_conf(const JSONRPCRequest& request)
@ -591,11 +605,13 @@ static void gobject_vote_many_help(CWallet* const pwallet)
"Vote on a governance object by all masternodes for which the voting key is present in the local wallet\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"},
{"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"},
}}
.ToString());
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"},
{"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_vote_many(const JSONRPCRequest& request)
@ -646,12 +662,14 @@ static void gobject_vote_alias_help(CWallet* const pwallet)
"Vote on a governance object by masternode's voting key (if present in local wallet)\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "hash of the governance object"},
{"vote", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "vote outcome, possible values: [yes|no|abstain]"},
{"protx-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "masternode's proTxHash"},
}}
.ToString());
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hash of the governance object"},
{"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
{"protx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "masternode's proTxHash"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_vote_alias(const JSONRPCRequest& request)
@ -764,10 +782,12 @@ static void gobject_list_help()
RPCHelpMan{"gobject list",
"List governance objects (can be filtered by signal and/or object type)\n",
{
{"signal", RPCArg::Type::STR, /* opt */ true, /* default_val */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
{"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "all", "object type, possible values: [proposals|triggers|all]"},
}}
.ToString());
{"signal", RPCArg::Type::STR, /* default */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
{"type", RPCArg::Type::STR, /* default */ "all", "object type, possible values: [proposals|triggers|all]"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_list(const JSONRPCRequest& request)
@ -798,10 +818,12 @@ static void gobject_diff_help()
RPCHelpMan{"gobject diff",
"List differences since last diff or list\n",
{
{"signal", RPCArg::Type::STR, /* opt */ true, /* default_val */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
{"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "all", "object type, possible values: [proposals|triggers|all]"},
}}
.ToString());
{"signal", RPCArg::Type::STR, /* default */ "valid", "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
{"type", RPCArg::Type::STR, /* default */ "all", "object type, possible values: [proposals|triggers|all]"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_diff(const JSONRPCRequest& request)
@ -832,9 +854,11 @@ static void gobject_get_help()
RPCHelpMan{"gobject get",
"Get governance object by hash\n",
{
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "object id"},
}}
.ToString());
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_get(const JSONRPCRequest& request)
@ -922,11 +946,13 @@ static void gobject_getcurrentvotes_help()
RPCHelpMan{"gobject getcurrentvotes",
"Get only current (tallying) votes for a governance object hash (does not include old votes)\n",
{
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "object id"},
{"txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "masternode collateral txid"},
{"vout", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "masternode collateral output index, required if <txid> presents"},
}}
.ToString());
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"},
{"txid", RPCArg::Type::STR_HEX, /* default */ "", "masternode collateral txid"},
{"vout", RPCArg::Type::STR, /* default */ "", "masternode collateral output index, required if <txid> presents"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue gobject_getcurrentvotes(const JSONRPCRequest& request)
@ -995,7 +1021,9 @@ static UniValue gobject_getcurrentvotes(const JSONRPCRequest& request)
" vote-many - Vote on a governance object by all masternodes for which the voting key is in the wallet\n"
#endif // ENABLE_WALLET
,
{}
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
@ -1063,15 +1091,17 @@ static UniValue voteraw(const JSONRPCRequest& request)
RPCHelpMan{"voteraw",
"Compile and relay a governance vote with provided external signature instead of signing vote internally\n",
{
{"mn-collateral-tx-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""},
{"mn-collateral-tx-index", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", ""},
{"governance-hash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""},
{"vote-signal", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", ""},
{"vote-outcome", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "yes|no|abstain"},
{"time", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", ""},
{"vote-sig", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""},
}}
.ToString());
{"mn-collateral-tx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""},
{"mn-collateral-tx-index", RPCArg::Type::NUM, RPCArg::Optional::NO, ""},
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""},
{"vote-signal", RPCArg::Type::STR, RPCArg::Optional::NO, ""},
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "yes|no|abstain"},
{"time", RPCArg::Type::NUM, RPCArg::Optional::NO, ""},
{"vote-sig", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""},
},
RPCResults{},
RPCExamples{""}
}.ToString());
uint256 hashMnCollateralTx = ParseHashV(request.params[0], "mn collateral tx hash");
int nMnCollateralTxIndex = request.params[1].get_int();
@ -1142,9 +1172,8 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"getgovernanceinfo",
"Returns an object containing governance parameters.\n",
{}}
.ToString() +
"\nResult:\n"
{},
RPCResult{
"{\n"
" \"governanceminquorum\": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action\n"
" \"proposalfee\": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in " + CURRENCY_UNIT + "\n"
@ -1152,10 +1181,12 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request)
" \"lastsuperblock\": xxxxx, (numeric) the block number of the last superblock\n"
" \"nextsuperblock\": xxxxx, (numeric) the block number of the next superblock\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getgovernanceinfo", "")
},
RPCExamples{
HelpExampleCli("getgovernanceinfo", "")
+ HelpExampleRpc("getgovernanceinfo", "")
);
},
}.ToString());
}
int nLastSuperblock = 0, nNextSuperblock = 0;
@ -1180,15 +1211,16 @@ static UniValue getsuperblockbudget(const JSONRPCRequest& request)
RPCHelpMan{"getsuperblockbudget",
"\nReturns the absolute maximum sum of superblock payments allowed.\n",
{
{"index", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The block index"},
}}
.ToString() +
"\nResult:\n"
{"index", RPCArg::Type::NUM, RPCArg::Optional::NO, "The block index"},
},
RPCResult{
"n (numeric) The absolute maximum sum of superblock payments allowed, in " + CURRENCY_UNIT + "\n"
"\nExamples:\n"
+ HelpExampleCli("getsuperblockbudget", "1000")
},
RPCExamples{
HelpExampleCli("getsuperblockbudget", "1000")
+ HelpExampleRpc("getsuperblockbudget", "1000")
);
},
}.ToString());
}
int nBlockHeight = request.params[0].get_int();

View File

@ -29,29 +29,30 @@ static void masternode_list_help()
{
throw std::runtime_error(
RPCHelpMan{"masternodelist",
"Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n",
"Get a list of masternodes in different modes. This call is identical to 'masternode list' call.\n"
"Available modes:\n"
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status payee IP'\n"
" (can be additionally filtered, partial match)\n"
" json - Print info in JSON format (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" owneraddress - Print the masternode owner Dash address\n"
" payee - Print the masternode payout Dash address (can be additionally filtered,\n"
" partial match)\n"
" pubKeyOperator - Print the masternode operator public key\n"
" status - Print masternode status: ENABLED / POSE_BANNED\n"
" (can be additionally filtered, partial match)\n"
" votingaddress - Print the masternode voting Dash address\n",
{
{"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "json", "The mode to run list in"},
{"filter", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"},
}}
.ToString() +
"\nAvailable modes:\n"
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status payee IP'\n"
" (can be additionally filtered, partial match)\n"
" json - Print info in JSON format (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" owneraddress - Print the masternode owner Dash address\n"
" payee - Print the masternode payout Dash address (can be additionally filtered,\n"
" partial match)\n"
" pubKeyOperator - Print the masternode operator public key\n"
" status - Print masternode status: ENABLED / POSE_BANNED\n"
" (can be additionally filtered, partial match)\n"
" votingaddress - Print the masternode voting Dash address\n"
);
{"mode", RPCArg::Type::STR, /* default */ "json", "The mode to run list in"},
{"filter", RPCArg::Type::STR, /* default */ "", "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue masternode_list(const JSONRPCRequest& request)
@ -73,9 +74,11 @@ static void masternode_connect_help()
RPCHelpMan{"masternode connect",
"Connect to given masternode\n",
{
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The address of the masternode to connect"},
}}
.ToString());
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the masternode to connect"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_connect(const JSONRPCRequest& request)
@ -102,7 +105,10 @@ static void masternode_count_help()
throw std::runtime_error(
RPCHelpMan{"masternode count",
"Get information about number of masternodes.\n",
{}}.ToString());
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_count(const JSONRPCRequest& request)
@ -151,7 +157,10 @@ static void masternode_winner_help()
throw std::runtime_error(
RPCHelpMan{"masternode winner",
"Print info on next masternode winner to vote for\n",
{}}.ToString());
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_winner(const JSONRPCRequest& request)
@ -171,7 +180,10 @@ static void masternode_current_help()
throw std::runtime_error(
RPCHelpMan{"masternode current",
"Print info on current masternode winner to be paid the next block (calculated locally)\n",
{}}.ToString());
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_current(const JSONRPCRequest& request)
@ -188,7 +200,10 @@ static void masternode_outputs_help()
throw std::runtime_error(
RPCHelpMan{"masternode outputs",
"Print masternode compatible outputs\n",
{}}.ToString());
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_outputs(const JSONRPCRequest& request)
@ -226,7 +241,10 @@ static void masternode_status_help()
throw std::runtime_error(
RPCHelpMan{"masternode status",
"Print masternode status information\n",
{}}.ToString());
{},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_status(const JSONRPCRequest& request)
@ -304,9 +322,12 @@ static void masternode_winners_help()
RPCHelpMan{"masternode winners",
"Print list of masternode winners\n",
{
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "number of last winners to return"},
{"filter", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "filter for returned winners"},
}}.ToString());
{"count", RPCArg::Type::NUM, /* default */ "", "number of last winners to return"},
{"filter", RPCArg::Type::STR, /* default */ "", "filter for returned winners"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_winners(const JSONRPCRequest& request)
@ -360,11 +381,10 @@ static void masternode_payments_help()
RPCHelpMan{"masternode payments",
"\nReturns an array of deterministic masternodes and their payments for the specified block\n",
{
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "tip", "The hash of the starting block"},
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1", "The number of blocks to return. Will return <count> previous blocks if <count> is negative. Both 1 and -1 correspond to the chain tip."},
}}
.ToString() +
"\nResult:\n"
{"blockhash", RPCArg::Type::STR_HEX, /* default */ "tip", "The hash of the starting block"},
{"count", RPCArg::Type::NUM, /* default */ "1", "The number of blocks to return. Will return <count> previous blocks if <count> is negative. Both 1 and -1 correspond to the chain tip."},
},
RPCResult {
" [ (array) Blocks\n"
" {\n"
" \"height\" : n, (numeric) The height of the block\n"
@ -384,7 +404,10 @@ static void masternode_payments_help()
" },...\n"
" ]\n"
" },...\n"
" ]\n");
" ]"
},
RPCExamples{""}
}.ToString());
}
static UniValue masternode_payments(const JSONRPCRequest& request)
@ -501,23 +524,24 @@ static UniValue masternode_payments(const JSONRPCRequest& request)
{
throw std::runtime_error(
RPCHelpMan{"masternode",
"Set of commands to execute masternode related actions\n",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"},
}}
.ToString() +
"\nAvailable commands:\n"
" count - Get information about number of masternodes\n"
" current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n"
"Set of commands to execute masternode related actions\n"
"\nAvailable commands:\n"
" count - Get information about number of masternodes\n"
" current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally)\n"
#ifdef ENABLE_WALLET
" outputs - Print masternode compatible outputs\n"
" outputs - Print masternode compatible outputs\n"
#endif // ENABLE_WALLET
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" payments - Return information about masternode payments in a mined block\n"
" winner - DEPRECATED Print info on next masternode winner to vote for\n"
" winners - Print list of masternode winners\n"
);
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" payments - Return information about masternode payments in a mined block\n"
" winner - DEPRECATED Print info on next masternode winner to vote for\n"
" winners - Print list of masternode winners\n",
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue masternode(const JSONRPCRequest& request)

View File

@ -91,16 +91,17 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
"Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
{
{"nblocks", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "120", "The number of blocks, or -1 for blocks since last difficulty change."},
{"height", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "-1", "To estimate at the time of the given height."},
}}
.ToString() +
"\nResult:\n"
{"nblocks", RPCArg::Type::NUM, /* default */ "120", "The number of blocks, or -1 for blocks since last difficulty change."},
{"height", RPCArg::Type::NUM, /* default */ "-1", "To estimate at the time of the given height."},
},
RPCResult{
"x (numeric) Hashes per second estimated\n"
"\nExamples:\n"
+ HelpExampleCli("getnetworkhashps", "")
},
RPCExamples{
HelpExampleCli("getnetworkhashps", "")
+ HelpExampleRpc("getnetworkhashps", "")
);
},
}.ToString());
LOCK(cs_main);
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
@ -162,17 +163,18 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
RPCHelpMan{"generatetoaddress",
"\nMine blocks immediately to a specified address (before the RPC call returns)\n",
{
{"nblocks", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "How many blocks are generated immediately."},
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The address to send the newly generated Dash to."},
{"maxtries", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1000000", "How many iterations to try."},
}}
.ToString() +
"\nResult:\n"
{"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, "How many blocks are generated immediately."},
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to send the newly generated Dash to."},
{"maxtries", RPCArg::Type::NUM, /* default */ "1000000", "How many iterations to try."},
},
RPCResult{
"[ blockhashes ] (array) hashes of blocks generated\n"
"\nExamples:\n"
},
RPCExamples{
"\nGenerate 11 blocks to myaddress\n"
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
);
},
}.ToString());
int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000;
@ -202,9 +204,9 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getmininginfo",
"\nReturns a json object containing mining-related information.", {}}
.ToString() +
"\nResult:\n"
"\nReturns a json object containing mining-related information.",
{},
RPCResult{
"{\n"
" \"blocks\": nnn, (numeric) The current block\n"
" \"currentblocksize\": nnn, (numeric) The last block size\n"
@ -215,10 +217,12 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getmininginfo", "")
},
RPCExamples{
HelpExampleCli("getmininginfo", "")
+ HelpExampleRpc("getmininginfo", "")
);
},
}.ToString());
LOCK(cs_main);
@ -244,19 +248,20 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request)
RPCHelpMan{"prioritisetransaction",
"Accepts the transaction into mined blocks at a higher (or lower) priority\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id."},
{"fee_delta", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The fee value (in duffs) to add (or subtract, if negative).\n"
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id."},
{"fee_delta", RPCArg::Type::NUM, RPCArg::Optional::NO, "The fee value (in duffs) to add (or subtract, if negative).\n"
" Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n"
" The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
" considers the transaction as it would have paid a higher (or lower) fee."},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"true (boolean) Returns true\n"
"\nExamples:\n"
+ HelpExampleCli("prioritisetransaction", "\"txid\" 10000")
},
RPCExamples{
HelpExampleCli("prioritisetransaction", "\"txid\" 10000")
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 10000")
);
},
}.ToString());
LOCK(cs_main);
@ -308,24 +313,23 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
" https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n",
{
{"template_request", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "A json object in the following spec",
{"template_request", RPCArg::Type::OBJ, /* default_val */ "", "A json object in the following spec",
{
{"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
{"capabilities", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "A list of strings",
{"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
{
{"support", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'"},
{"support", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'"},
},
},
{"rules", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "A list of strings",
{"rules", RPCArg::Type::ARR, /* default_val */ "", "A list of strings",
{
{"support", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "client side supported softfork deployment"},
{"support", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported softfork deployment"},
},
},
},
"\"template_request\""},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"capabilities\" : [ \"capability\", ... ], (array of strings) specific client side supported features\n"
" \"version\" : n, (numeric) The preferred block version\n"
@ -386,11 +390,12 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
" \"superblocks_enabled\" : true|false, (boolean) true, if superblock payments are enabled\n"
" \"coinbase_payload\" : \"xxxxxxxx\" (string) coinbase transaction payload data encoded in hexadecimal\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getblocktemplate", "")
},
RPCExamples{
HelpExampleCli("getblocktemplate", "")
+ HelpExampleRpc("getblocktemplate", "")
);
},
}.ToString());
LOCK(cs_main);
@ -735,15 +740,15 @@ static UniValue submitblock(const JSONRPCRequest& request)
"\nAttempts to submit new block to network.\n"
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
{
{"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded block data to submit"},
{"dummy", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "dummy value, for compatibility with BIP22. This value is ignored."},
}}
.ToString() +
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("submitblock", "\"mydata\"")
{"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded block data to submit"},
{"dummy", RPCArg::Type::STR, /* default */ "ignored", "dummy value, for compatibility with BIP22. This value is ignored."},
},
RPCResults{},
RPCExamples{
HelpExampleCli("submitblock", "\"mydata\"")
+ HelpExampleRpc("submitblock", "\"mydata\"")
);
},
}.ToString());
}
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
@ -792,14 +797,16 @@ static UniValue submitheader(const JSONRPCRequest& request)
"\nDecode the given hexdata as a header and submit it as a candidate chain tip if valid."
"\nThrows when the header is invalid.\n",
{
{"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded block header data"},
}}
.ToString() +
"\nResult:\n"
{"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded block header data"},
},
RPCResult{
"None"
"\nExamples:\n" +
HelpExampleCli("submitheader", "\"aabbcc\"") +
HelpExampleRpc("submitheader", "\"aabbcc\""));
},
RPCExamples{
HelpExampleCli("submitheader", "\"aabbcc\"") +
HelpExampleRpc("submitheader", "\"aabbcc\"")
},
}.ToString());
}
CBlockHeader h;
@ -831,8 +838,8 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
"confirmation within conf_target blocks if possible and return the number of blocks\n"
"for which the estimate is valid.\n",
{
{"conf_target", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Confirmation target in blocks (1 - 1008)"},
{"estimate_mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "CONSERVATIVE", "The fee estimate mode.\n"
{"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"},
{"estimate_mode", RPCArg::Type::STR, /* default */ "CONSERVATIVE", "The fee estimate mode.\n"
" Whether to return a more conservative estimate which also satisfies\n"
" a longer history. A conservative estimate potentially returns a\n"
" higher feerate and is more likely to be sufficient for the desired\n"
@ -841,9 +848,8 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
" \"UNSET\"\n"
" \"ECONOMICAL\"\n"
" \"CONSERVATIVE\""},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"feerate\" : x.x, (numeric, optional) estimate fee rate in " + CURRENCY_UNIT + "/kB\n"
" \"errors\": [ str... ] (json array of strings, optional) Errors encountered during processing\n"
@ -854,9 +860,11 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
"fee estimation is able to return based on how long it has been running.\n"
"An error is returned if not enough transactions and blocks\n"
"have been observed to make an estimate for any number of blocks.\n"
"\nExample:\n"
+ HelpExampleCli("estimatesmartfee", "6")
);
},
RPCExamples{
HelpExampleCli("estimatesmartfee", "6")
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
@ -896,13 +904,12 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
"\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
"confirmation within conf_target blocks if possible.\n",
{
{"conf_target", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Confirmation target in blocks (1 - 1008)"},
{"threshold", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The proportion of transactions in a given feerate range that must have been\n"
{"conf_target", RPCArg::Type::NUM, RPCArg::Optional::NO, "Confirmation target in blocks (1 - 1008)"},
{"threshold", RPCArg::Type::NUM, /* default */ "0.95", "The proportion of transactions in a given feerate range that must have been\n"
" confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
" lower buckets. Default: 0.95"},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"short\" : { (json object, optional) estimate for short time horizon\n"
" \"feerate\" : x.x, (numeric, optional) estimate fee rate in " + CURRENCY_UNIT + "/kB\n"
@ -924,9 +931,11 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
"}\n"
"\n"
"Results are returned for any horizon which tracks blocks up to the confirmation target.\n"
"\nExample:\n"
+ HelpExampleCli("estimaterawfee", "6 0.9")
);
},
RPCExamples{
HelpExampleCli("estimaterawfee", "6 0.9")
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);

View File

@ -52,15 +52,15 @@ static UniValue debug(const JSONRPCRequest& request)
" - \"none\" (or \"0\") deactivates all categories at once.\n"
"Note: If specified category doesn't match any of the above, no error is thrown.\n",
{
{"category", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The name of the debug category to turn on."},
}}
.ToString() +
"\nResult:\n"
{"category", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the debug category to turn on."},
},
RPCResult {
" result (string) \"Debug mode: \" followed by the specified category.\n"
"\nExamples:\n"
+ HelpExampleCli("debug", "dash")
},
RPCExamples {
HelpExampleCli("debug", "dash")
+ HelpExampleRpc("debug", "dash+net")
);
}}.ToString());
std::string strMode = request.params[0].get_str();
LogInstance().DisableCategory(BCLog::ALL);
@ -84,10 +84,11 @@ static UniValue mnsync(const JSONRPCRequest& request)
RPCHelpMan{"mnsync",
"Returns the sync status, updates to the next step or resets it entirely.\n",
{
{"mode", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "[status|next|reset]"},
}}
.ToString()
);
{"mode", RPCArg::Type::STR, RPCArg::Optional::NO, "[status|next|reset]"},
},
RPCResults{},
RPCExamples{""}
}.ToString());
std::string strMode = request.params[0].get_str();
@ -145,23 +146,24 @@ static UniValue spork(const JSONRPCRequest& request)
RPCHelpMan{"spork",
"\nShows information about current state of sporks\n",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "'show' to show all current spork values, 'active' to show which sporks are active"},
}}
.ToString() +
"\nResult:\n"
"For 'show':\n"
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'show' to show all current spork values, 'active' to show which sporks are active"},
},
RPCResults {
{"For 'show'",
"{\n"
" \"SPORK_NAME\" : spork_value, (number) The value of the specific spork with the name SPORK_NAME\n"
" ...\n"
"}\n"
"For 'active':\n"
}, {"For 'active'",
"{\n"
" \"SPORK_NAME\" : true|false, (boolean) 'true' for time-based sporks if spork is active and 'false' otherwise\n"
" ...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("spork", "show")
+ HelpExampleRpc("spork", "\"show\""));
}},
RPCExamples {
HelpExampleCli("spork", "show")
+ HelpExampleRpc("spork", "\"show\"")
}}.ToString());
} else {
// advanced mode, update spork values
SporkId nSporkID = CSporkManager::GetSporkIDByName(request.params[0].get_str());
@ -182,15 +184,17 @@ static UniValue spork(const JSONRPCRequest& request)
RPCHelpMan{"spork",
"\nUpdate the value of the specific spork. Requires \"-sporkkey\" to be set to sign the message.\n",
{
{"name", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The name of the spork to update"},
{"value", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The new desired value of the spork"},
}}
.ToString() +
"\nResult:\n"
{"name", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the spork to update"},
{"value", RPCArg::Type::NUM, RPCArg::Optional::NO, "The new desired value of the spork"},
},
RPCResult{
" result (string) \"success\" if spork value was updated or this help otherwise\n"
"\nExamples:\n"
+ HelpExampleCli("spork", "SPORK_2_INSTANTSEND_ENABLED 4070908800")
+ HelpExampleRpc("spork", "\"SPORK_2_INSTANTSEND_ENABLED\", 4070908800"));
},
RPCExamples{
HelpExampleCli("spork", "SPORK_2_INSTANTSEND_ENABLED 4070908800")
+ HelpExampleRpc("spork", "\"SPORK_2_INSTANTSEND_ENABLED\", 4070908800")
},
}.ToString());
}
}
@ -203,20 +207,21 @@ static UniValue validateaddress(const JSONRPCRequest& request)
RPCHelpMan{"validateaddress",
"\nReturn information about the given dash address.\n",
{
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The dash address to validate"},
}}
.ToString() +
"\nResult:\n"
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to validate"},
},
RPCResult{
"{\n"
" \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
" \"address\" : \"address\", (string) The dash address validated\n"
" \"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address\n"
" \"isscript\" : true|false, (boolean) If the key is a script\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("validateaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"")
},
RPCExamples{
HelpExampleCli("validateaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"")
+ HelpExampleRpc("validateaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"")
);
},
}.ToString());
CTxDestination dest = DecodeDestination(request.params[0].get_str());
bool isValid = IsValidDestination(dest);
@ -246,25 +251,25 @@ static UniValue createmultisig(const JSONRPCRequest& request)
"\nCreates a multi-signature address with n signature of m keys required.\n"
"It returns a json object with the address and redeemScript.\n",
{
{"nrequired", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The number of required signatures out of the n keys."},
{"keys", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of hex-encoded public keys.",
{"nrequired", RPCArg::Type::NUM, RPCArg::Optional::NO, "The number of required signatures out of the n keys."},
{"keys", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of hex-encoded public keys.",
{
{"key", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex-encoded public key"},
{"key", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The hex-encoded public key"},
}},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
" \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
"}\n"
"\nExamples:\n"
},
RPCExamples{
"\nCreate a multisig address from 2 public keys\n"
+ HelpExampleCli("createmultisig", "2 \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("createmultisig", "2, \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"")
;
},
}.ToString();
throw std::runtime_error(msg);
}
@ -299,9 +304,9 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request)
RPCHelpMan{"getdescriptorinfo",
{"\nAnalyses a descriptor.\n"},
{
{"descriptor", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The descriptor"},
}}.ToString() +
"\nResult:\n"
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor"},
},
RPCResult{
"{\n"
" \"descriptor\" : \"desc\", (string) The descriptor in canonical form, without private keys\n"
" \"checksum\" : \"chksum\", (string) The checksum for the input descriptor\n"
@ -309,10 +314,12 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request)
" \"issolvable\" : true|false, (boolean) Whether the descriptor is solvable\n"
" \"hasprivatekeys\" : true|false, (boolean) Whether the input descriptor contained at least one private key\n"
"}\n"
"\nExamples:\n"
},
RPCExamples{
"\nAnalyse a descriptor\n"
+ HelpExampleCli("getdescriptorinfo", "\"pkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)\"")
);
}
}.ToString());
}
RPCTypeCheck(request.params, {UniValue::VSTR});
@ -346,19 +353,21 @@ UniValue deriveaddresses(const JSONRPCRequest& request)
"or more path elements separated by \"/\", where \"h\" represents a hardened child key.\n"
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
{
{"descriptor", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The descriptor"},
{"begin", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "If a ranged descriptor is used, this specifies the beginning of the range to import"},
{"end", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "If a ranged descriptor is used, this specifies the end of the range to import"}}
}.ToString() +
"\nResult:\n"
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor"},
{"begin", RPCArg::Type::NUM, /* default */ "", "If a ranged descriptor is used, this specifies the beginning of the range to import"},
{"end", RPCArg::Type::NUM, /* default */ "", "If a ranged descriptor is used, this specifies the end of the range to import"}
},
RPCResult{
"\"address\" (array) A json array of the derived addresses\n"
" [\n"
" ...\n"
" ]\n"
"\nExamples:\n"
},
RPCExamples{
"\nFirst three receive addresses\n"
+ HelpExampleCli("deriveaddresses", "\"pkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#trd0mf0l\" 0 2")
);
}
}.ToString());
}
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VNUM, UniValue::VNUM});
@ -429,14 +438,14 @@ static UniValue verifymessage(const JSONRPCRequest& request)
RPCHelpMan{"verifymessage",
"\nVerify a signed message\n",
{
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The dash address to use for the signature."},
{"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The signature provided by the signer in base 64 encoding (see signmessage)."},
{"message", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The message that was signed."},
}}
.ToString() +
"\nResult:\n"
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to use for the signature."},
{"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature provided by the signer in base 64 encoding (see signmessage)."},
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message that was signed."},
},
RPCResult{
"true|false (boolean) If the signature is verified or not.\n"
"\nExamples:\n"
},
RPCExamples{
"\nUnlock the wallet for 30 seconds\n"
+ HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
"\nCreate the signature\n"
@ -445,7 +454,8 @@ static UniValue verifymessage(const JSONRPCRequest& request)
+ HelpExampleCli("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" \"signature\" \"my message\"") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", \"signature\", \"my message\"")
);
},
}.ToString());
LOCK(cs_main);
@ -487,20 +497,21 @@ static UniValue signmessagewithprivkey(const JSONRPCRequest& request)
RPCHelpMan{"signmessagewithprivkey",
"\nSign a message with the private key of an address\n",
{
{"privkey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The private key to sign the message with."},
{"message", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The message to create a signature of."},
}}
.ToString() +
"\nResult:\n"
{"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key to sign the message with."},
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
},
RPCResult{
"\"signature\" (string) The signature of the message encoded in base 64\n"
"\nExamples:\n"
},
RPCExamples{
"\nCreate the signature\n"
+ HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") +
"\nVerify the signature\n"
+ HelpExampleCli("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" \"signature\" \"my message\"") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
);
},
}.ToString());
std::string strPrivkey = request.params[0].get_str();
std::string strMessage = request.params[1].get_str();
@ -528,10 +539,12 @@ static UniValue setmocktime(const JSONRPCRequest& request)
RPCHelpMan{"setmocktime",
"\nSet the local time to given timestamp (-regtest only)\n",
{
{"timestamp", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Unix seconds-since-epoch timestamp\n"
{"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, "Unix seconds-since-epoch timestamp\n"
" Pass 0 to go back to using the system time."},
}}
.ToString()
},
RPCResults{},
RPCExamples{""},
}.ToString()
);
if (!Params().MineBlocksOnDemand())
@ -557,11 +570,13 @@ static UniValue mnauth(const JSONRPCRequest& request)
RPCHelpMan{"mnauth",
"\nOverride MNAUTH processing results for the specified node with a user provided data (-regtest only).\n",
{
{"nodeId", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Internal peer id of the node the mock data gets added to."},
{"proTxHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The authenticated proTxHash as hex string."},
{"publicKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The authenticated public key as hex string."},
}}
.ToString());
{"nodeId", RPCArg::Type::NUM, RPCArg::Optional::NO, "Internal peer id of the node the mock data gets added to."},
{"proTxHash", RPCArg::Type::STR, RPCArg::Optional::NO, "The authenticated proTxHash as hex string."},
{"publicKey", RPCArg::Type::STR, RPCArg::Optional::NO, "The authenticated public key as hex string."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
if (!Params().MineBlocksOnDemand())
throw std::runtime_error("mnauth for regression testing (-regtest mode) only");
@ -663,13 +678,13 @@ static UniValue getaddressmempool(const JSONRPCRequest& request)
RPCHelpMan{"getaddressmempool",
"\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n",
{
{"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "",
{"addresses", RPCArg::Type::ARR, /* default */ "", "",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"},
{"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"[\n"
" {\n"
" \"address\" (string) The base58check encoded address\n"
@ -681,10 +696,12 @@ static UniValue getaddressmempool(const JSONRPCRequest& request)
" \"prevout\" (string) The previous transaction output index (if spending)\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
},
RPCExamples{
HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
);
},
}.ToString());
std::vector<std::pair<uint160, int> > addresses;
@ -733,13 +750,13 @@ static UniValue getaddressutxos(const JSONRPCRequest& request)
RPCHelpMan{"getaddressutxos",
"\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n",
{
{"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "",
{"addresses", RPCArg::Type::ARR, /* default */ "", "",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"},
{"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"[\n"
" {\n"
" \"address\" (string) The address base58check encoded\n"
@ -750,10 +767,12 @@ static UniValue getaddressutxos(const JSONRPCRequest& request)
" \"height\" (number) The block height\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
},
RPCExamples{
HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
);
},
}.ToString());
std::vector<std::pair<uint160, int> > addresses;
@ -799,13 +818,13 @@ static UniValue getaddressdeltas(const JSONRPCRequest& request)
RPCHelpMan{"getaddressdeltas",
"\nReturns all changes for an address (requires addressindex to be enabled).\n",
{
{"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "",
{"addresses", RPCArg::Type::ARR, /* default */ "", "",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"},
{"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"[\n"
" {\n"
" \"satoshis\" (number) The difference of duffs\n"
@ -816,10 +835,12 @@ static UniValue getaddressdeltas(const JSONRPCRequest& request)
" \"address\" (string) The base58check encoded address\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
},
RPCExamples{
HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
);
},
}.ToString());
UniValue startValue = find_value(request.params[0].get_obj(), "start");
@ -884,23 +905,25 @@ static UniValue getaddressbalance(const JSONRPCRequest& request)
RPCHelpMan{"getaddressbalance",
"\nReturns the balance for an address(es) (requires addressindex to be enabled).\n",
{
{"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "",
{"addresses", RPCArg::Type::ARR, /* default */ "", "",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"},
{"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"balance\": xxxxx, (numeric) The current total balance in duffs\n"
" \"balance_immature\": xxxxx, (numeric) The current immature balance in duffs\n"
" \"balance_spendable\": xxxxx, (numeric) The current spendable balance in duffs\n"
" \"received\": xxxxx (numeric) The total number of duffs received (including change)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
},
RPCExamples{
HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
);
},
}.ToString());
std::vector<std::pair<uint160, int> > addresses;
@ -952,21 +975,23 @@ static UniValue getaddresstxids(const JSONRPCRequest& request)
RPCHelpMan{"getaddresstxids",
"\nReturns the txids for an address(es) (requires addressindex to be enabled).\n",
{
{"addresses", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "",
{"addresses", RPCArg::Type::ARR, /* default */ "", "",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The base58check encoded address"},
{"address", RPCArg::Type::STR, /* default */ "", "The base58check encoded address"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"[\n"
" \"transactionid\" (string) The transaction id\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
},
RPCExamples{
HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}'")
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\"]}")
);
},
}.ToString());
std::vector<std::pair<uint160, int> > addresses;
@ -1032,23 +1057,25 @@ static UniValue getspentinfo(const JSONRPCRequest& request)
RPCHelpMan{"getspentinfo",
"\nReturns the txid and index where an output is spent.\n",
{
{"request", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"request", RPCArg::Type::OBJ, /* default */ "", "",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The hex string of the txid"},
{"index", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The start block height"},
{"txid", RPCArg::Type::STR_HEX, /* default */ "", "The hex string of the txid"},
{"index", RPCArg::Type::NUM, /* default */ "", "The start block height"},
},
},
}}.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"txid\" (string) The transaction id\n"
" \"index\" (number) The spending input index\n"
" ,...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'")
},
RPCExamples{
HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'")
+ HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}")
);
},
}.ToString());
UniValue txidValue = find_value(request.params[0].get_obj(), "txid");
UniValue indexValue = find_value(request.params[0].get_obj(), "index");
@ -1117,12 +1144,12 @@ static UniValue getmemoryinfo(const JSONRPCRequest& request)
RPCHelpMan{"getmemoryinfo",
"Returns an object containing information about memory usage.\n",
{
{"mode", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "determines what kind of information is returned. This argument is optional, the default mode is \"stats\".\n"
{"mode", RPCArg::Type::STR, /* default */ "\"stats\"", "determines what kind of information is returned.\n"
" - \"stats\" returns general statistics about memory usage in the daemon.\n"
" - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+)."},
}}
.ToString() +
"\nResult (mode \"stats\"):\n"
},
{
RPCResult{"mode \"stats\"",
"{\n"
" \"locked\": { (json object) Information about locked memory manager\n"
" \"used\": xxxxx, (numeric) Number of bytes used\n"
@ -1133,12 +1160,16 @@ static UniValue getmemoryinfo(const JSONRPCRequest& request)
" \"chunks_free\": xxxxx, (numeric) Number unused chunks\n"
" }\n"
"}\n"
"\nResult (mode \"mallocinfo\"):\n"
},
RPCResult{"mode \"mallocinfo\"",
"\"<malloc version=\"1\">...\"\n"
"\nExamples:\n"
+ HelpExampleCli("getmemoryinfo", "")
},
},
RPCExamples{
HelpExampleCli("getmemoryinfo", "")
+ HelpExampleRpc("getmemoryinfo", "")
);
},
}.ToString());
std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str();
if (mode == "stats") {
@ -1192,25 +1223,26 @@ static UniValue logging(const JSONRPCRequest& request)
" - \"none\", \"0\" : even if other logging categories are specified, ignore all of them.\n"
,
{
{"include", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "A json array of categories to add debug logging",
{"include", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of categories to add debug logging",
{
{"include_category", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "the valid logging category"},
{"include_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
}},
{"exclude", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "A json array of categories to remove debug logging",
{"exclude", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of categories to remove debug logging",
{
{"exclude_category", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "the valid logging category"},
{"exclude_category", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "the valid logging category"},
}},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{ (json object where keys are the logging categories, and values indicates its status\n"
" \"category\": true|false, (bool) if being debug logged or not. false:inactive, true:active\n"
" ...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
+ HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]")
);
},
RPCExamples{
HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
+ HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"")
},
}.ToString());
}
uint64_t original_log_categories = LogInstance().GetCategoryMask();
@ -1254,9 +1286,11 @@ static UniValue echo(const JSONRPCRequest& request)
"\nSimply echo back the input arguments. This command is for testing.\n"
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
"dash-cli and the GUI. There is no server-side difference.",
{}}
.ToString() +
"");
{},
RPCResults{},
RPCExamples{""},
}.ToString()
);
return request.params;
}

View File

@ -32,14 +32,16 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getconnectioncount",
"\nReturns the number of connections to other nodes.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the number of connections to other nodes.\n",
{},
RPCResult{
"n (numeric) The connection count\n"
"\nExamples:\n"
+ HelpExampleCli("getconnectioncount", "")
},
RPCExamples{
HelpExampleCli("getconnectioncount", "")
+ HelpExampleRpc("getconnectioncount", "")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -55,12 +57,13 @@ static UniValue ping(const JSONRPCRequest& request)
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
"Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
"Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n",
{}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("ping", "")
{},
RPCResults{},
RPCExamples{
HelpExampleCli("ping", "")
+ HelpExampleRpc("ping", "")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -77,9 +80,9 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getpeerinfo",
"\nReturns data about each connected network node as a json array of objects.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns data about each connected network node as a json array of objects.\n",
{},
RPCResult{
"[\n"
" {\n"
" \"id\": n, (numeric) Peer index\n"
@ -137,10 +140,12 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getpeerinfo", "")
},
RPCExamples{
HelpExampleCli("getpeerinfo", "")
+ HelpExampleRpc("getpeerinfo", "")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -247,14 +252,15 @@ static UniValue addnode(const JSONRPCRequest& request)
"Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be\n"
"full nodes as other outbound peers are (though such peers will not be synced from).\n",
{
{"node", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The node (see getpeerinfo for nodes)"},
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("addnode", "\"192.168.0.6:9999\" \"onetry\"")
{"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The node (see getpeerinfo for nodes)"},
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("addnode", "\"192.168.0.6:9999\" \"onetry\"")
+ HelpExampleRpc("addnode", "\"192.168.0.6:9999\", \"onetry\"")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -291,16 +297,17 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
"\nStrictly one out of 'address' and 'nodeid' can be provided to identify the node.\n"
"\nTo disconnect by nodeid, either set 'address' to the empty string, or call using the named 'nodeid' argument only.\n",
{
{"address", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The IP address/port of the node"},
{"nodeid", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The node ID (see getpeerinfo for node IDs)"},
}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("disconnectnode", "\"192.168.0.6:9999\"")
{"address", RPCArg::Type::STR, /* default */ "fallback to nodeid", "The IP address/port of the node"},
{"nodeid", RPCArg::Type::NUM, /* default */ "fallback to address", "The node ID (see getpeerinfo for node IDs)"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("disconnectnode", "\"192.168.0.6:9999\"")
+ HelpExampleCli("disconnectnode", "\"\" 1")
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:9999\"")
+ HelpExampleRpc("disconnectnode", "\"\", 1")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -335,10 +342,9 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
"\nReturns information about the given added node, or all added nodes\n"
"(note that onetry addnodes are not listed here)\n",
{
{"node", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "If provided, return information about this specific node, otherwise all nodes are returned."},
}}
.ToString() +
"\nResult:\n"
{"node", RPCArg::Type::STR, /* default */ "all nodes", "If provided, return information about this specific node, otherwise all nodes are returned."},
},
RPCResult{
"[\n"
" {\n"
" \"addednode\" : \"192.168.0.201\", (string) The node IP address or name (as provided to addnode)\n"
@ -352,11 +358,13 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddednodeinfo", "")
+ HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"")
},
RPCExamples{
HelpExampleCli("getaddednodeinfo", "")
+ HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"")
+ HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -404,9 +412,8 @@ static UniValue getnettotals(const JSONRPCRequest& request)
RPCHelpMan{"getnettotals",
"\nReturns information about network traffic, including bytes in, bytes out,\n"
"and current time.\n",
{}}
.ToString() +
"\nResult:\n"
{},
RPCResult{
"{\n"
" \"totalbytesrecv\": n, (numeric) Total bytes received\n"
" \"totalbytessent\": n, (numeric) Total bytes sent\n"
@ -421,10 +428,12 @@ static UniValue getnettotals(const JSONRPCRequest& request)
" \"time_left_in_cycle\": t (numeric) Seconds left in current time cycle\n"
" }\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getnettotals", "")
},
RPCExamples{
HelpExampleCli("getnettotals", "")
+ HelpExampleRpc("getnettotals", "")
);
},
}.ToString());
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
@ -470,9 +479,9 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"getnetworkinfo",
"Returns an object containing various state info regarding P2P networking.\n", {}}
.ToString() +
"\nResult:\n"
"Returns an object containing various state info regarding P2P networking.\n",
{},
RPCResult{
"{\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"buildversion\": \"x.x.x.x-xxx\", (string) the server build version including RC info or commit as relevant\n"
@ -510,10 +519,12 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
" ]\n"
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getnetworkinfo", "")
},
RPCExamples{
HelpExampleCli("getnetworkinfo", "")
+ HelpExampleRpc("getnetworkinfo", "")
);
},
}.ToString());
LOCK(cs_main);
UniValue obj(UniValue::VOBJ);
@ -581,17 +592,18 @@ static UniValue setban(const JSONRPCRequest& request)
RPCHelpMan{"setban",
"\nAttempts to add or remove an IP/Subnet from the banned list.\n",
{
{"subnet", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)"},
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list"},
{"bantime", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)"},
{"absolute", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", "If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)"},
}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400")
{"subnet", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)"},
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list"},
{"bantime", RPCArg::Type::NUM, /* default */ "0", "time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)"},
{"absolute", RPCArg::Type::BOOL, /* default */ "false", "If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400")
+ HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"")
+ HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400")
);
},
}.ToString());
if (!g_banman) {
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
}
@ -654,12 +666,14 @@ static UniValue listbanned(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"listbanned",
"\nList all banned IPs/Subnets.\n", {}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("listbanned", "")
"\nList all banned IPs/Subnets.\n",
{},
RPCResults{},
RPCExamples{
HelpExampleCli("listbanned", "")
+ HelpExampleRpc("listbanned", "")
);
},
}.ToString());
if(!g_banman) {
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
@ -689,12 +703,14 @@ static UniValue clearbanned(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
RPCHelpMan{"clearbanned",
"\nClear all banned IPs.\n", {}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("clearbanned", "")
"\nClear all banned IPs.\n",
{},
RPCResults{},
RPCExamples{
HelpExampleCli("clearbanned", "")
+ HelpExampleRpc("clearbanned", "")
);
},
}.ToString());
if (!g_banman) {
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
}
@ -711,9 +727,11 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
RPCHelpMan{"setnetworkactive",
"\nDisable/enable all p2p network activity.\n",
{
{"state", RPCArg::Type::BOOL, /* opt */ false, /* default_val */ "", "true to enable networking, false to disable"},
}}
.ToString()
{"state", RPCArg::Type::BOOL, RPCArg::Optional::NO, "true to enable networking, false to disable"},
},
RPCResults{},
RPCExamples{""},
}.ToString()
);
}
@ -733,10 +751,9 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
RPCHelpMan{"getnodeaddresses",
"\nReturn known addresses which can potentially be used to find new nodes in the network\n",
{
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "1", "How many addresses to return. Limited to the smaller of " + std::to_string(ADDRMAN_GETADDR_MAX) + " or " + std::to_string(ADDRMAN_GETADDR_MAX_PCT) + "% of all known addresses."},
}}
.ToString() +
"\nResult:\n"
{"count", RPCArg::Type::NUM, /* default */ "1", "How many addresses to return. Limited to the smaller of " + std::to_string(ADDRMAN_GETADDR_MAX) + " or " + std::to_string(ADDRMAN_GETADDR_MAX_PCT) + "% of all known addresses."},
},
RPCResult{
"[\n"
" {\n"
" \"time\": ttt, (numeric) Timestamp in seconds since epoch (Jan 1 1970 GMT) keeping track of when the node was last seen\n"
@ -746,10 +763,12 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
" }\n"
" ,....\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getnodeaddresses", "8")
},
RPCExamples{
HelpExampleCli("getnodeaddresses", "8")
+ HelpExampleRpc("getnodeaddresses", "8")
);
},
}.ToString());
}
if (!g_connman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");

View File

@ -119,15 +119,15 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
"\nIf verbose is 'true', returns an Object with information about 'txid'.\n"
"If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id"},
{"verbose", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "If false, return a string, otherwise return a json object"},
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The block in which to look for the transaction"},
}}
.ToString() +
"\nResult (if verbose is not set or set to false):\n"
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
{"verbose", RPCArg::Type::BOOL, /* default */ "false", "If false, return a string, otherwise return a json object"},
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED_NAMED_ARG, "The block in which to look for the transaction"},
},
{
RPCResult{"if verbose is not set or set to false",
"\"data\" (string) The serialized, hex-encoded data for 'txid'\n"
"\nResult (if verbose is set to true):\n"
},
RPCResult{"if verbose is set to true",
"{\n"
" \"in_active_chain\": b, (bool) Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)\n"
" \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
@ -175,14 +175,16 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
" \"instantlock_internal\" : true|false, (bool) Current internal transaction lock state\n"
" \"chainlock\" : true|false, (bool) The state of the corresponding block chainlock\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getrawtransaction", "\"mytxid\"")
},
},
RPCExamples{
HelpExampleCli("getrawtransaction", "\"mytxid\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true")
+ HelpExampleRpc("getrawtransaction", "\"mytxid\", true")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" false \"myblockhash\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" true \"myblockhash\"")
);
},
}.ToString());
bool in_active_chain = true;
uint256 hash = ParseHashV(request.params[0], "parameter 1");
@ -255,21 +257,22 @@ static UniValue gettxoutproof(const JSONRPCRequest& request)
"you need to maintain a transaction index, using the -txindex command line option or\n"
"specify the block in which the transaction is included manually (by blockhash).\n",
{
{"txids", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of txids to filter",
{"txids", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of txids to filter",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "A transaction hash"},
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A transaction hash"},
},
},
{"blockhash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "If specified, looks for txid in the block with this hash"},
}}
.ToString() +
"\nResult:\n"
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED_NAMED_ARG, "If specified, looks for txid in the block with this hash"},
},
RPCResult{
"\"data\" (string) A string that is a serialized, hex-encoded data for the proof.\n"
"\nExamples:\n"
+ HelpExampleCli("gettxoutproof", "'[\"mytxid\",...]'")
},
RPCExamples{
HelpExampleCli("gettxoutproof", "'[\"mytxid\",...]'")
+ HelpExampleCli("gettxoutproof", "'[\"mytxid\",...]' \"blockhash\"")
+ HelpExampleRpc("gettxoutproof", "[\"mytxid\",...], \"blockhash\"")
},
}.ToString()
);
std::set<uint256> setTxids;
@ -353,15 +356,16 @@ static UniValue verifytxoutproof(const JSONRPCRequest& request)
"\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n"
"and throwing an RPC error if the block is not in our best chain\n",
{
{"proof", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex-encoded proof generated by gettxoutproof"},
}}
.ToString() +
"\nResult:\n"
{"proof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded proof generated by gettxoutproof"},
},
RPCResult{
"[\"txid\"] (array, strings) The txid(s) which the proof commits to, or empty array if the proof can not be validated.\n"
"\nExamples:\n"
+ HelpExampleCli("verifytxoutproof", "\"proof\"")
},
RPCExamples{
HelpExampleCli("verifytxoutproof", "\"proof\"")
+ HelpExampleRpc("gettxoutproof", "\"proof\"")
},
}.ToString()
);
CDataStream ssMB(ParseHexV(request.params[0], "proof"), SER_NETWORK, PROTOCOL_VERSION);
@ -493,45 +497,46 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
"Note that the transaction's inputs are not signed, and\n"
"it is not stored in the wallet or transmitted to the network.\n",
{
{"inputs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of json objects",
{"inputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of json objects",
{
{"", RPCArg::Type::OBJ, /* opt */ false, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id"},
{"vout", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The output number"},
{"sequence", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The sequence number"},
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
{"sequence", RPCArg::Type::NUM, /* default */ "", "The sequence number"},
},
},
},
},
{"outputs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "a json array with outputs (key-value pairs).\n"
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "a json array with outputs (key-value pairs).\n"
"That is, each address can only appear once and there can only be one 'data' object.\n"
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
" accepted as second parameter.",
{
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"address", RPCArg::Type::AMOUNT, /* opt */ false, /* default_val */ "", "A key-value pair. The key (string) is the dash address, the value (float or string) is the amount in " + CURRENCY_UNIT},
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the dash address, the value (float or string) is the amount in " + CURRENCY_UNIT},
},
},
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
},
},
},
},
{"locktime", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"},
}}
.ToString() +
"\nResult:\n"
{"locktime", RPCArg::Type::NUM, /* default */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"},
},
RPCResult{
"\"transaction\" (string) hex string of the transaction\n"
"\nExamples:\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
},
RPCExamples{
HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
);
},
}.ToString());
}
RPCTypeCheck(request.params, {
@ -553,10 +558,9 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
RPCHelpMan{"decoderawtransaction",
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n",
{
{"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction hex string"},
}}
.ToString() +
"\nResult:\n"
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction hex string"},
},
RPCResult{
"{\n"
" \"txid\" : \"id\", (string) The transaction id\n"
" \"size\" : n, (numeric) The transaction size\n"
@ -595,11 +599,12 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
" \"extraPayloadSize\" : n (numeric) Size of DIP2 extra payload. Only present if it's a special TX\n"
" \"extraPayload\" : \"hex\" (string) Hex-encoded DIP2 extra payload data. Only present if it's a special TX\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decoderawtransaction", "\"hexstring\"")
},
RPCExamples{
HelpExampleCli("decoderawtransaction", "\"hexstring\"")
+ HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
);
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR});
@ -621,10 +626,9 @@ static UniValue decodescript(const JSONRPCRequest& request)
RPCHelpMan{"decodescript",
"\nDecode a hex-encoded script.\n",
{
{"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded script"},
}}
.ToString() +
"\nResult:\n"
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hex-encoded script"},
},
RPCResult{
"{\n"
" \"asm\":\"asm\", (string) Script public key\n"
" \"hex\":\"hex\", (string) hex-encoded public key\n"
@ -636,10 +640,12 @@ static UniValue decodescript(const JSONRPCRequest& request)
" ],\n"
" \"p2sh\",\"address\" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decodescript", "\"hexstring\"")
},
RPCExamples{
HelpExampleCli("decodescript", "\"hexstring\"")
+ HelpExampleRpc("decodescript", "\"hexstring\"")
);
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR});
@ -687,19 +693,19 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
"The combined transaction may be another partially signed transaction or a \n"
"fully signed transaction.",
{
{"txs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of hex strings of partially signed transactions",
{"txs", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of hex strings of partially signed transactions",
{
{"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "A transaction hash"},
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "A transaction hash"},
},
},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"\"hex\" (string) The hex-encoded raw transaction with signature(s)\n"
"\nExamples:\n"
+ HelpExampleCli("combinerawtransaction", "'[\"myhex1\", \"myhex2\", \"myhex3\"]'")
);
},
RPCExamples{
HelpExampleCli("combinerawtransaction", "'[\"myhex1\", \"myhex2\", \"myhex3\"]'")
},
}.ToString());
UniValue txs = request.params[0].get_array();
@ -905,26 +911,26 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
"The third optional argument (may be null) is an array of previous transaction outputs that\n"
"this transaction depends on but may not yet be in the block chain.\n",
{
{"hexstring", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The transaction hex string"},
{"privkeys", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of base58-encoded private keys for signing",
{"hexstring", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction hex string"},
{"privkeys", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of base58-encoded private keys for signing",
{
{"privatekey", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "private key in base58-encoding"},
{"privatekey", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "private key in base58-encoding"},
},
},
{"prevtxs", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "A json array of previous dependent transaction outputs",
{"prevtxs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of previous dependent transaction outputs",
{
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id"},
{"vout", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The output number"},
{"scriptPubKey", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "script key"},
{"redeemScript", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "(required for P2SH or P2WSH) redeem script"},
{"amount", RPCArg::Type::AMOUNT, /* opt */ false, /* default_val */ "", "The amount spent"},
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
{"scriptPubKey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "script key"},
{"redeemScript", RPCArg::Type::STR_HEX, /* default_val */ "", "(required for P2SH or P2WSH) redeem script"},
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount spent"},
},
},
},
},
{"sighashtype", RPCArg::Type::STR, /* opt */ true, /* default_val */ "ALL", "The signature hash type. Must be one of:\n"
{"sighashtype", RPCArg::Type::STR, /* default */ "ALL", "The signature hash type. Must be one of:\n"
" \"ALL\"\n"
" \"NONE\"\n"
" \"SINGLE\"\n"
@ -932,9 +938,8 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
" \"NONE|ANYONECANPAY\"\n"
" \"SINGLE|ANYONECANPAY\"\n"
},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"hex\" : \"value\", (string) The hex-encoded raw transaction with signature(s)\n"
" \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n"
@ -949,11 +954,12 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
" ,...\n"
" ]\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("signrawtransactionwithkey", "\"myhex\"")
},
RPCExamples{
HelpExampleCli("signrawtransactionwithkey", "\"myhex\"")
+ HelpExampleRpc("signrawtransactionwithkey", "\"myhex\"")
);
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true);
@ -984,15 +990,15 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n"
"\nAlso see createrawtransaction and signrawtransactionwithkey calls.\n",
{
{"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex string of the raw transaction"},
{"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Allow high fees"},
{"instantsend", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Deprecated and ignored"},
{"bypasslimits", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Bypass transaction policy limits"},
}}
.ToString() +
"\nResult:\n"
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
{"allowhighfees", RPCArg::Type::BOOL, /* default */ "false", "Allow high fees"},
{"instantsend", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Deprecated and ignored"},
{"bypasslimits", RPCArg::Type::BOOL, /* default_val */ "false", "Bypass transaction policy limits"},
},
RPCResult{
"\"hex\" (string) The transaction hash in hex\n"
"\nExamples:\n"
},
RPCExamples{
"\nCreate a transaction\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
"Sign the transaction, and get back the hex\n"
@ -1001,7 +1007,8 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
+ HelpExampleCli("sendrawtransaction", "\"signedhex\"") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
);
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL});
@ -1034,16 +1041,15 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
"\nThis checks if the transaction violates the consensus or policy rules.\n"
"\nSee sendrawtransaction call.\n",
{
{"rawtxs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "An array of hex strings of raw transactions.\n"
{"rawtxs", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings of raw transactions.\n"
" Length must be one for now.",
{
{"rawtx", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", ""},
{"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
},
},
{"allowhighfees", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Allow high fees"},
}}
.ToString() +
"\nResult:\n"
{"allowhighfees", RPCArg::Type::BOOL, /* default */ "false", "Allow high fees"},
},
RPCResult{
"[ (array) The result of the mempool acceptance test for each raw transaction in the input array.\n"
" Length is exactly one for now.\n"
" {\n"
@ -1052,7 +1058,8 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
" \"reject-reason\" (string) Rejection string (only present when 'allowed' is false)\n"
" }\n"
"]\n"
"\nExamples:\n"
},
RPCExamples{
"\nCreate a transaction\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
"Sign the transaction, and get back the hex\n"
@ -1061,7 +1068,8 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
+ HelpExampleCli("testmempoolaccept", "[\"signedhex\"]") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
);
},
}.ToString());
}
RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VBOOL});
@ -1134,10 +1142,9 @@ UniValue decodepsbt(const JSONRPCRequest& request)
RPCHelpMan{"decodepsbt",
"\nReturn a JSON object representing the serialized, base64-encoded partially signed Dash transaction.\n",
{
{"psbt", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The PSBT base64 string"},
}}
.ToString() +
"\nResult:\n"
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The PSBT base64 string"},
},
RPCResult{
"{\n"
" \"tx\" : { (json object) The decoded network-serialized unsigned transaction.\n"
" ... The layout is the same as the output of decoderawtransaction.\n"
@ -1204,10 +1211,11 @@ UniValue decodepsbt(const JSONRPCRequest& request)
" ]\n"
" \"fee\" : fee (numeric, optional) The transaction fee paid if all UTXOs slots in the PSBT have been filled.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("decodepsbt", "\"psbt\"")
);
},
RPCExamples{
HelpExampleCli("decodepsbt", "\"psbt\"")
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR});
@ -1361,18 +1369,19 @@ UniValue combinepsbt(const JSONRPCRequest& request)
"\nCombine multiple partially signed Dash transactions into one transaction.\n"
"Implements the Combiner role.\n",
{
{"txs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of base64 strings of partially signed transactions",
{"txs", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of base64 strings of partially signed transactions",
{
{"psbt", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "A base64 string of a PSBT"},
{"psbt", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "A base64 string of a PSBT"},
},
},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
" \"psbt\" (string) The base64-encoded partially signed transaction\n"
"\nExamples:\n"
+ HelpExampleCli("combinepsbt", "[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")
);
},
RPCExamples{
HelpExampleCli("combinepsbt", "[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VARR}, true);
@ -1412,22 +1421,22 @@ UniValue finalizepsbt(const JSONRPCRequest& request)
"created which has the final_scriptSig field filled for inputs that are complete.\n"
"Implements the Finalizer and Extractor roles.\n",
{
{"psbt", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "A base64 string of a PSBT"},
{"extract", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "If true and the transaction is complete,\n"
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "A base64 string of a PSBT"},
{"extract", RPCArg::Type::BOOL, /* default */ "true", "If true and the transaction is complete,\n"
" extract and return the complete transaction in normal network serialization instead of the PSBT."},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
"{\n"
" \"psbt\" : \"value\", (string) The base64-encoded partially signed transaction if not extracted\n"
" \"hex\" : \"value\", (string) The hex-encoded network transaction if extracted\n"
" \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n"
" ]\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("finalizepsbt", "\"psbt\"")
);
},
RPCExamples{
HelpExampleCli("finalizepsbt", "\"psbt\"")
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}, true);
@ -1469,41 +1478,42 @@ UniValue createpsbt(const JSONRPCRequest& request)
"\nCreates a transaction in the Partially Signed Transaction format.\n"
"Implements the Creator role.\n",
{
{"inputs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "A json array of json objects",
{"inputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of json objects",
{
{"", RPCArg::Type::OBJ, /* opt */ false, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id"},
{"vout", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The output number"},
{"sequence", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The sequence number"},
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id"},
{"vout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The output number"},
{"sequence", RPCArg::Type::NUM, /* default */ "", "The sequence number"},
},
},
},
},
{"outputs", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "a json array with outputs (key-value pairs).\n"
{"outputs", RPCArg::Type::ARR, RPCArg::Optional::NO, "a json array with outputs (key-value pairs).\n"
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
" accepted as second parameter.",
{
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"address", RPCArg::Type::AMOUNT, /* opt */ false, /* default_val */ "", "A key-value pair. The key (string) is the Dash address, the value (float or string) is the amount in " + CURRENCY_UNIT},
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the Dash address, the value (float or string) is the amount in " + CURRENCY_UNIT},
},
},
{"", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"data", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A key-value pair. The key must be \"data\", the value is hex-encoded data"},
},
},
},
},
{"locktime", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"},
}}
.ToString() +
"\nResult:\n"
{"locktime", RPCArg::Type::NUM, /* default */ "0", "Raw locktime. Non-0 value also locktime-activates inputs"},
},
RPCResult{
" \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n"
"\nExamples:\n"
+ HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
);
},
RPCExamples{
HelpExampleCli("createpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
},
}.ToString());
RPCTypeCheck(request.params, {
@ -1540,19 +1550,20 @@ UniValue converttopsbt(const JSONRPCRequest& request)
"\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
"createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
{
{"hexstring", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex string of a raw transaction"},
{"permitsigdata", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "If true, any signatures in the input will be discarded and conversion.\n"
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of a raw transaction"},
{"permitsigdata", RPCArg::Type::BOOL, /* default */ "false", "If true, any signatures in the input will be discarded and conversion.\n"
" will continue. If false, RPC will fail if any signatures are present."},
}}
.ToString() +
"\nResult:\n"
},
RPCResult{
" \"psbt\" (string) The resulting raw transaction (base64-encoded string)\n"
"\nExamples:\n"
},
RPCExamples{
"\nCreate a transaction\n"
+ HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
"\nConvert the transaction to a PSBT\n"
+ HelpExampleCli("converttopsbt", "\"rawtransaction\"")
);
},
}.ToString());
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL}, true);

View File

@ -35,100 +35,100 @@ extern UniValue sendrawtransaction(const JSONRPCRequest& request);
class CWallet;
#endif//ENABLE_WALLET
static RPCArg GetHelpString(const std::string& strParamName)
static RPCArg GetRpcArg(const std::string& strParamName)
{
static const std::map<std::string, RPCArg> mapParamHelp = {
{"collateralAddress",
{"collateralAddress", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"collateralAddress", RPCArg::Type::STR, RPCArg::Optional::NO,
"The dash address to send the collateral to."}
},
{"collateralHash",
{"collateralHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"collateralHash", RPCArg::Type::STR, RPCArg::Optional::NO,
"The collateral transaction hash."}
},
{"collateralIndex",
{"collateralIndex", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "",
{"collateralIndex", RPCArg::Type::NUM, RPCArg::Optional::NO,
"The collateral transaction output index."}
},
{"feeSourceAddress",
{"feeSourceAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "",
{"feeSourceAddress", RPCArg::Type::STR, /* default */ "",
"If specified wallet will only use coins from this address to fund ProTx.\n"
"If not specified, payoutAddress is the one that is going to be used.\n"
"The private key belonging to this address must be known in your wallet."}
},
{"fundAddress",
{"fundAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "",
{"fundAddress", RPCArg::Type::STR, /* default */ "",
"If specified wallet will only use coins from this address to fund ProTx.\n"
"If not specified, payoutAddress is the one that is going to be used.\n"
"The private key belonging to this address must be known in your wallet."}
},
{"ipAndPort",
{"ipAndPort", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"ipAndPort", RPCArg::Type::STR, RPCArg::Optional::NO,
"IP and port in the form \"IP:PORT\".\n"
"Must be unique on the network. Can be set to 0, which will require a ProUpServTx afterwards."}
},
{"operatorKey",
{"operatorKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"operatorKey", RPCArg::Type::STR, RPCArg::Optional::NO,
"The operator BLS private key associated with the\n"
"registered operator public key."}
},
{"operatorPayoutAddress",
{"operatorPayoutAddress", RPCArg::Type::STR, /* opt */ true, /* default_val */ "",
{"operatorPayoutAddress", RPCArg::Type::STR, /* default */ "",
"The address used for operator reward payments.\n"
"Only allowed when the ProRegTx had a non-zero operatorReward value.\n"
"If set to an empty string, the currently active payout address is reused."}
},
{"operatorPubKey_register",
{"operatorPubKey_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"operatorPubKey_register", RPCArg::Type::STR, RPCArg::Optional::NO,
"The operator BLS public key. The BLS private key does not have to be known.\n"
"It has to match the BLS private key which is later used when operating the masternode."}
},
{"operatorPubKey_update",
{"operatorPubKey_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"operatorPubKey_update", RPCArg::Type::STR, RPCArg::Optional::NO,
"The operator BLS public key. The BLS private key does not have to be known.\n"
"It has to match the BLS private key which is later used when operating the masternode.\n"
"If set to an empty string, the currently active operator BLS public key is reused."}
},
{"operatorReward",
{"operatorReward", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"operatorReward", RPCArg::Type::STR, RPCArg::Optional::NO,
"The fraction in %% to share with the operator. The value must be\n"
"between 0.00 and 100.00."}
},
{"ownerAddress",
{"ownerAddress", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"ownerAddress", RPCArg::Type::STR, RPCArg::Optional::NO,
"The dash address to use for payee updates and proposal voting.\n"
"The corresponding private key does not have to be known by your wallet.\n"
"The address must be unused and must differ from the collateralAddress."}
},
{"payoutAddress_register",
{"payoutAddress_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"payoutAddress_register", RPCArg::Type::STR, RPCArg::Optional::NO,
"The dash address to use for masternode reward payments."}
},
{"payoutAddress_update",
{"payoutAddress_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"payoutAddress_update", RPCArg::Type::STR, RPCArg::Optional::NO,
"The dash address to use for masternode reward payments.\n"
"If set to an empty string, the currently active payout address is reused."}
},
{"proTxHash",
{"proTxHash", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"proTxHash", RPCArg::Type::STR, RPCArg::Optional::NO,
"The hash of the initial ProRegTx."}
},
{"reason",
{"reason", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "",
{"reason", RPCArg::Type::NUM, /* default */ "",
"The reason for masternode service revocation."}
},
{"submit",
{"submit", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true",
{"submit", RPCArg::Type::BOOL, /* default */ "true",
"If true, the resulting transaction is sent to the network."}
},
{"votingAddress_register",
{"votingAddress_register", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"votingAddress_register", RPCArg::Type::STR, RPCArg::Optional::NO,
"The voting key address. The private key does not have to be known by your wallet.\n"
"It has to match the private key which is later used when voting on proposals.\n"
"If set to an empty string, ownerAddress will be used."}
},
{"votingAddress_update",
{"votingAddress_update", RPCArg::Type::STR, /* opt */ false, /* default_val */ "",
{"votingAddress_update", RPCArg::Type::STR, RPCArg::Optional::NO,
"The voting key address. The private key does not have to be known by your wallet.\n"
"It has to match the private key which is later used when voting on proposals.\n"
"If set to an empty string, the currently active voting key address is reused."}
@ -327,24 +327,26 @@ static void protx_register_fund_help(CWallet* const pwallet)
"is fully deployed.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
GetHelpString("collateralAddress"),
GetHelpString("ipAndPort"),
GetHelpString("ownerAddress"),
GetHelpString("operatorPubKey_register"),
GetHelpString("votingAddress_register"),
GetHelpString("operatorReward"),
GetHelpString("payoutAddress_register"),
GetHelpString("fundAddress"),
GetHelpString("submit"),
}}
.ToString() +
"\nResult (if \"submit\" is not set or set to true):\n"
GetRpcArg("collateralAddress"),
GetRpcArg("ipAndPort"),
GetRpcArg("ownerAddress"),
GetRpcArg("operatorPubKey_register"),
GetRpcArg("votingAddress_register"),
GetRpcArg("operatorReward"),
GetRpcArg("payoutAddress_register"),
GetRpcArg("fundAddress"),
GetRpcArg("submit"),
},
RPCResults{
{"if \"submit\" is not set or set to true",
"\"txid\" (string) The transaction id.\n"
"\nResult (if \"submit\" is set to false):\n"
}, {"if \"submit\" is set to false",
"\"hex\" (string) The serialized signed ProTx in hex format.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "register_fund \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\" \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
);
}},
RPCExamples{
HelpExampleCli("protx", "register_fund \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\" \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
},
}.ToString());
}
static void protx_register_help(CWallet* const pwallet)
@ -356,25 +358,27 @@ static void protx_register_help(CWallet* const pwallet)
"transaction output spendable by this wallet. It must also not be used by any other masternode.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
GetHelpString("collateralHash"),
GetHelpString("collateralIndex"),
GetHelpString("ipAndPort"),
GetHelpString("ownerAddress"),
GetHelpString("operatorPubKey_register"),
GetHelpString("votingAddress_register"),
GetHelpString("operatorReward"),
GetHelpString("payoutAddress_register"),
GetHelpString("feeSourceAddress"),
GetHelpString("submit"),
}}
.ToString() +
"\nResult (if \"submit\" is not set or set to true):\n"
GetRpcArg("collateralHash"),
GetRpcArg("collateralIndex"),
GetRpcArg("ipAndPort"),
GetRpcArg("ownerAddress"),
GetRpcArg("operatorPubKey_register"),
GetRpcArg("votingAddress_register"),
GetRpcArg("operatorReward"),
GetRpcArg("payoutAddress_register"),
GetRpcArg("feeSourceAddress"),
GetRpcArg("submit"),
},
RPCResults{
{"if \"submit\" is not set or set to true",
"\"txid\" (string) The transaction id.\n"
"\nResult (if \"submit\" is set to false):\n"
}, {"if \"submit\" is set to false",
"\"hex\" (string) The serialized signed ProTx in hex format.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "register \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
);
}},
RPCExamples{
HelpExampleCli("protx", "register \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
},
}.ToString());
}
static void protx_register_prepare_help()
@ -385,27 +389,28 @@ static void protx_register_prepare_help()
"with the private key that corresponds to collateralAddress to prove collateral ownership.\n"
"The prepared transaction will also contain inputs and outputs to cover fees.\n",
{
GetHelpString("collateralHash"),
GetHelpString("collateralIndex"),
GetHelpString("ipAndPort"),
GetHelpString("ownerAddress"),
GetHelpString("operatorPubKey_register"),
GetHelpString("votingAddress_register"),
GetHelpString("operatorReward"),
GetHelpString("payoutAddress_register"),
GetHelpString("feeSourceAddress"),
}}
.ToString() +
"\nResult:\n"
GetRpcArg("collateralHash"),
GetRpcArg("collateralIndex"),
GetRpcArg("ipAndPort"),
GetRpcArg("ownerAddress"),
GetRpcArg("operatorPubKey_register"),
GetRpcArg("votingAddress_register"),
GetRpcArg("operatorReward"),
GetRpcArg("payoutAddress_register"),
GetRpcArg("feeSourceAddress"),
},
RPCResult{
"{ (json object)\n"
" \"tx\" : (string) The serialized unsigned ProTx in hex format.\n"
" \"collateralAddress\" : (string) The collateral address.\n"
" \"signMessage\" : (string) The string message that needs to be signed with\n"
" the collateral key.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "register_prepare \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
);
},
RPCExamples{
HelpExampleCli("protx", "register_prepare \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"")
},
}.ToString());
}
static void protx_register_submit_help(CWallet* const pwallet)
@ -417,15 +422,16 @@ static void protx_register_submit_help(CWallet* const pwallet)
"Note: See \"help protx register_prepare\" for more info about creating a ProTx and a message to sign.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
{"tx", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The serialized unsigned ProTx in hex format."},
{"sig", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The signature signed with the collateral key. Must be in base64 format."},
}}
.ToString() +
"\nResult:\n"
{"tx", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The serialized unsigned ProTx in hex format."},
{"sig", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature signed with the collateral key. Must be in base64 format."},
},
RPCResult{
"\"txid\" (string) The transaction id.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "register_submit \"tx\" \"sig\"")
);
},
RPCExamples{
HelpExampleCli("protx", "register_submit \"tx\" \"sig\"")
},
}.ToString());
}
// handles register, register_prepare and register_fund in one method
@ -634,18 +640,19 @@ static void protx_update_service_help(CWallet* const pwallet)
"If this is done for a masternode that got PoSe-banned, the ProUpServTx will also revive this masternode.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
GetHelpString("proTxHash"),
GetHelpString("ipAndPort"),
GetHelpString("operatorKey"),
GetHelpString("operatorPayoutAddress"),
GetHelpString("feeSourceAddress"),
}}
.ToString() +
"\nResult:\n"
GetRpcArg("proTxHash"),
GetRpcArg("ipAndPort"),
GetRpcArg("operatorKey"),
GetRpcArg("operatorPayoutAddress"),
GetRpcArg("feeSourceAddress"),
},
RPCResult{
"\"txid\" (string) The transaction id.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "update_service \"0123456701234567012345670123456701234567012345670123456701234567\" \"1.2.3.4:1234\" 5a2e15982e62f1e0b7cf9783c64cf7e3af3f90a52d6c40f6f95d624c0b1621cd")
);
},
RPCExamples{
HelpExampleCli("protx", "update_service \"0123456701234567012345670123456701234567012345670123456701234567\" \"1.2.3.4:1234\" 5a2e15982e62f1e0b7cf9783c64cf7e3af3f90a52d6c40f6f95d624c0b1621cd")
},
}.ToString());
}
static UniValue protx_update_service(const JSONRPCRequest& request)
@ -732,18 +739,19 @@ static void protx_update_registrar_help(CWallet* const pwallet)
"The owner key of the masternode must be known to your wallet.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
GetHelpString("proTxHash"),
GetHelpString("operatorPubKey_update"),
GetHelpString("votingAddress_update"),
GetHelpString("payoutAddress_update"),
GetHelpString("feeSourceAddress"),
}}
.ToString() +
"\nResult:\n"
GetRpcArg("proTxHash"),
GetRpcArg("operatorPubKey_update"),
GetRpcArg("votingAddress_update"),
GetRpcArg("payoutAddress_update"),
GetRpcArg("feeSourceAddress"),
},
RPCResult{
"\"txid\" (string) The transaction id.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "update_registrar \"0123456701234567012345670123456701234567012345670123456701234567\" \"982eb34b7c7f614f29e5c665bc3605f1beeef85e3395ca12d3be49d2868ecfea5566f11cedfad30c51b2403f2ad95b67\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"")
);
},
RPCExamples{
HelpExampleCli("protx", "update_registrar \"0123456701234567012345670123456701234567012345670123456701234567\" \"982eb34b7c7f614f29e5c665bc3605f1beeef85e3395ca12d3be49d2868ecfea5566f11cedfad30c51b2403f2ad95b67\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"")
},
}.ToString());
}
static UniValue protx_update_registrar(const JSONRPCRequest& request)
@ -824,17 +832,18 @@ static void protx_revoke_help(CWallet* const pwallet)
"to the masternode owner.\n"
+ HelpRequiringPassphrase(pwallet) + "\n",
{
GetHelpString("proTxHash"),
GetHelpString("operatorKey"),
GetHelpString("reason"),
GetHelpString("feeSourceAddress"),
}}
.ToString() +
"\nResult:\n"
GetRpcArg("proTxHash"),
GetRpcArg("operatorKey"),
GetRpcArg("reason"),
GetRpcArg("feeSourceAddress"),
},
RPCResult{
"\"txid\" (string) The transaction id.\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "revoke \"0123456701234567012345670123456701234567012345670123456701234567\" \"072f36a77261cdd5d64c32d97bac417540eddca1d5612f416feb07ff75a8e240\"")
);
},
RPCExamples{
HelpExampleCli("protx", "revoke \"0123456701234567012345670123456701234567012345670123456701234567\" \"072f36a77261cdd5d64c32d97bac417540eddca1d5612f416feb07ff75a8e240\"")
},
}.ToString());
}
static UniValue protx_revoke(const JSONRPCRequest& request)
@ -909,14 +918,7 @@ static void protx_list_help()
RPCHelpMan{"protx list",
"\nLists all ProTxs in your wallet or on-chain, depending on the given type.\n",
{
{"type", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", ""},
{"detailed", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", ""},
{"height", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", ""},
}}
.ToString() +
"If \"type\" is not specified, it defaults to \"registered\".\n"
"If \"detailed\" is not specified, it defaults to \"false\" and only the hashes of the ProTx will be returned.\n"
"If \"height\" is not specified, it defaults to the current chain-tip.\n"
{"type", RPCArg::Type::STR, /* default */ "registered",
"\nAvailable types:\n"
" registered - List all ProTx which are registered at the given chain height.\n"
" This will also include ProTx which failed PoSe verification.\n"
@ -925,7 +927,13 @@ static void protx_list_help()
" wallet - List only ProTx which are found in your wallet at the given chain height.\n"
" This will also include ProTx which failed PoSe verification.\n"
#endif
);
},
{"detailed", RPCArg::Type::BOOL, /* default */ "false", "If not specified, only the hashes of the ProTx will be returned."},
{"height", RPCArg::Type::NUM, /* default */ "current chain-tip", ""},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
#ifdef ENABLE_WALLET
@ -1085,15 +1093,16 @@ static void protx_info_help()
RPCHelpMan{"protx info",
"\nReturns detailed information about a deterministic masternode.\n",
{
GetHelpString("proTxHash"),
}}
.ToString() +
"\nResult:\n"
GetRpcArg("proTxHash"),
},
RPCResult{
"{ (json object) Details about a specific deterministic masternode\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("protx", "info \"0123456701234567012345670123456701234567012345670123456701234567\"")
);
},
RPCExamples{
HelpExampleCli("protx", "info \"0123456701234567012345670123456701234567012345670123456701234567\"")
},
}.ToString());
}
static UniValue protx_info(const JSONRPCRequest& request)
@ -1128,10 +1137,12 @@ static void protx_diff_help()
RPCHelpMan{"protx diff",
"\nCalculates a diff between two deterministic masternode lists. The result also contains proof data.\n",
{
{"baseBlock", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The starting block height."},
{"block", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The ending block height."},
}}
.ToString());
{"baseBlock", RPCArg::Type::NUM, RPCArg::Optional::NO, "The starting block height."},
{"block", RPCArg::Type::NUM, RPCArg::Optional::NO, "The ending block height."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static uint256 ParseBlock(const UniValue& v, std::string strName) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@ -1174,27 +1185,28 @@ static UniValue protx_diff(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"protx",
"Set of commands to execute ProTx related actions.\n"
"To get help on individual commands, use \"help protx command\".\n",
"To get help on individual commands, use \"help protx command\".\n"
"\nAvailable commands:\n"
#ifdef ENABLE_WALLET
" register - Create and send ProTx to network\n"
" register_fund - Fund, create and send ProTx to network\n"
" register_prepare - Create an unsigned ProTx\n"
" register_submit - Sign and submit a ProTx\n"
#endif
" list - List ProTxs\n"
" info - Return information about a ProTx\n"
#ifdef ENABLE_WALLET
" update_service - Create and send ProUpServTx to network\n"
" update_registrar - Create and send ProUpRegTx to network\n"
" revoke - Create and send ProUpRevTx to network\n"
#endif
" diff - Calculate a diff and a proof between two masternode lists\n",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"},
}}
.ToString() +
"\nAvailable commands:\n"
#ifdef ENABLE_WALLET
" register - Create and send ProTx to network\n"
" register_fund - Fund, create and send ProTx to network\n"
" register_prepare - Create an unsigned ProTx\n"
" register_submit - Sign and submit a ProTx\n"
#endif
" list - List ProTxs\n"
" info - Return information about a ProTx\n"
#ifdef ENABLE_WALLET
" update_service - Create and send ProUpServTx to network\n"
" update_registrar - Create and send ProUpRegTx to network\n"
" revoke - Create and send ProUpRevTx to network\n"
#endif
" diff - Calculate a diff and a proof between two masternode lists\n"
);
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue protx(const JSONRPCRequest& request)
@ -1237,15 +1249,17 @@ static void bls_generate_help()
throw std::runtime_error(
RPCHelpMan{"bls generate",
"\nReturns a BLS secret/public key pair.\n",
{}}.ToString() +
"\nResult:\n"
{},
RPCResult{
"{\n"
" \"secret\": \"xxxx\", (string) BLS secret key\n"
" \"public\": \"xxxx\", (string) BLS public key\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("bls generate", "")
);
},
RPCExamples{
HelpExampleCli("bls generate", "")
},
}.ToString());
}
static UniValue bls_generate(const JSONRPCRequest& request)
@ -1269,17 +1283,18 @@ static void bls_fromsecret_help()
RPCHelpMan{"bls fromsecret",
"\nParses a BLS secret key and returns the secret/public key pair.\n",
{
{"secret", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The BLS secret key"},
}}
.ToString() +
"\nResult:\n"
{"secret", RPCArg::Type::STR, RPCArg::Optional::NO, "The BLS secret key"},
},
RPCResult{
"{\n"
" \"secret\": \"xxxx\", (string) BLS secret key\n"
" \"public\": \"xxxx\", (string) BLS public key\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
);
},
RPCExamples{
HelpExampleCli("bls fromsecret", "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
},
}.ToString());
}
static UniValue bls_fromsecret(const JSONRPCRequest& request)
@ -1304,15 +1319,16 @@ static UniValue bls_fromsecret(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"bls",
"Set of commands to execute BLS related actions.\n"
"To get help on individual commands, use \"help bls command\".\n",
"To get help on individual commands, use \"help bls command\".\n"
"\nAvailable commands:\n"
" generate - Create a BLS secret/public key pair\n"
" fromsecret - Parse a BLS secret key and return the secret/public key pair\n",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"},
}}
.ToString() +
"\nAvailable commands:\n"
" generate - Create a BLS secret/public key pair\n"
" fromsecret - Parse a BLS secret key and return the secret/public key pair\n"
);
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue _bls(const JSONRPCRequest& request)

View File

@ -29,21 +29,22 @@ static void quorum_list_help()
RPCHelpMan{"quorum list",
"List of on-chain quorums\n",
{
{"count", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "Number of quorums to list. Will list active quorums if \"count\" is not specified."},
}}
.ToString() +
"\nResult:\n"
{"count", RPCArg::Type::NUM, /* default */ "", "Number of quorums to list. Will list active quorums if \"count\" is not specified."},
},
RPCResult{
"{\n"
" \"quorumName\" : [ (array of strings) List of quorum hashes per some quorum type.\n"
" \"quorumHash\" (string) Quorum hash. Note: most recent quorums come first.\n"
" ,...\n"
" ],\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("quorum", "list")
},
RPCExamples{
HelpExampleCli("quorum", "list")
+ HelpExampleCli("quorum", "list 10")
+ HelpExampleRpc("quorum", "list, 10")
);
},
}.ToString());
}
static UniValue quorum_list(const JSONRPCRequest& request)
@ -85,11 +86,13 @@ static void quorum_info_help()
RPCHelpMan{"quorum info",
"Return information about a quorum\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"quorumHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Block hash of quorum."},
{"includeSkShare", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "", "Include secret key share in output."},
}}
.ToString());
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Block hash of quorum."},
{"includeSkShare", RPCArg::Type::BOOL, /* default */ "", "Include secret key share in output."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue BuildQuorumInfo(const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare)
@ -159,11 +162,13 @@ static void quorum_dkgstatus_help()
"Return the status of the current DKG process.\n"
"Works only when SPORK_17_QUORUM_DKG_ENABLED spork is ON.\n",
{
{"detail_level", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0",
{"detail_level", RPCArg::Type::NUM, /* default */ "0",
"Detail level of output.\n"
"0=Only show counts. 1=Show member indexes. 2=Show member's ProTxHashes."},
}}
.ToString());
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_dkgstatus(const JSONRPCRequest& request)
@ -242,12 +247,14 @@ static void quorum_memberof_help()
RPCHelpMan{"quorum memberof",
"Checks which quorums the given masternode is a member of.\n",
{
{"proTxHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "ProTxHash of the masternode."},
{"scanQuorumsCount", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "",
{"proTxHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "ProTxHash of the masternode."},
{"scanQuorumsCount", RPCArg::Type::NUM, /* default */ "",
"Number of quorums to scan for. If not specified,\n"
"the active quorum count for each specific quorum type is used."},
}}
.ToString());
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_memberof(const JSONRPCRequest& request)
@ -301,15 +308,17 @@ static void quorum_sign_help()
RPCHelpMan{"quorum sign",
"Threshold-sign a message\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."},
{"quorumHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The quorum identifier."},
{"submit", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Submits the signature share to the network if this is true."},
}}
.ToString() +
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
{"quorumHash", RPCArg::Type::STR_HEX, /* default */ "", "The quorum identifier."},
{"submit", RPCArg::Type::BOOL, /* default */ "true", "Submits the signature share to the network if this is true."},
},
RPCResult{
"\nReturns an object containing the signature share if this is false.\n"
);
},
RPCExamples{""},
}.ToString());
}
static void quorum_verify_help()
@ -318,18 +327,20 @@ static void quorum_verify_help()
RPCHelpMan{"quorum verify",
"Test if a quorum signature is valid for a request id and a message hash\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."},
{"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "Quorum signature to verify."},
{"quorumHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "",
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
{"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "Quorum signature to verify."},
{"quorumHash", RPCArg::Type::STR_HEX, /* default */ "",
"The quorum identifier.\n"
"Set to \"\" if you want to specify signHeight instead."},
{"signHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "",
{"signHeight", RPCArg::Type::NUM, /* default */ "",
"The height at which the message was signed.\n"
"Only works when quorumHash is \"\"."},
}}
.ToString());
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static void quorum_hasrecsig_help()
@ -338,11 +349,13 @@ static void quorum_hasrecsig_help()
RPCHelpMan{"quorum hasrecsig",
"Test if a valid recovered signature is present\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."},
}}
.ToString());
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static void quorum_getrecsig_help()
@ -351,11 +364,13 @@ static void quorum_getrecsig_help()
RPCHelpMan{"quorum getrecsig",
"Get a recovered signature\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."},
}}
.ToString());
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static void quorum_isconflicting_help()
@ -364,11 +379,13 @@ static void quorum_isconflicting_help()
RPCHelpMan{"quorum isconflicting",
"Test if a conflict exists\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Message hash."},
}}
.ToString());
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"msgHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Message hash."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_sigs_cmd(const JSONRPCRequest& request)
@ -496,10 +513,12 @@ static void quorum_selectquorum_help()
RPCHelpMan{"quorum selectquorum",
"Returns the quorum that would/should sign a request\n",
{
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
}}
.ToString());
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "LLMQ type."},
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_selectquorum(const JSONRPCRequest& request)
@ -540,10 +559,12 @@ static void quorum_dkgsimerror_help()
"This enables simulation of errors and malicious behaviour in the DKG. Do NOT use this on mainnet\n"
"as you will get yourself very likely PoSe banned for this.\n",
{
{"type", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "Error type."},
{"rate", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Rate at which to simulate this error type."},
}}
.ToString());
{"type", RPCArg::Type::STR, RPCArg::Optional::NO, "Error type."},
{"rate", RPCArg::Type::NUM, RPCArg::Optional::NO, "Rate at which to simulate this error type."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_dkgsimerror(const JSONRPCRequest& request)
@ -570,17 +591,19 @@ static void quorum_getdata_help()
RPCHelpMan{"quorum getdata",
"Send a QGETDATA message to the specified peer.\n",
{
{"nodeId", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The internal nodeId of the peer to request quorum data from."},
{"llmqType", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "The quorum type related to the quorum data being requested."},
{"quorumHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The quorum hash related to the quorum data being requested."},
{"dataMask", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "",
{"nodeId", RPCArg::Type::NUM, RPCArg::Optional::NO, "The internal nodeId of the peer to request quorum data from."},
{"llmqType", RPCArg::Type::NUM, RPCArg::Optional::NO, "The quorum type related to the quorum data being requested."},
{"quorumHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The quorum hash related to the quorum data being requested."},
{"dataMask", RPCArg::Type::NUM, RPCArg::Optional::NO,
"Specify what data to request.\n"
"Possible values: 1 - Request quorum verification vector\n"
"2 - Request encrypted contributions for member defined by \"proTxHash\". \"proTxHash\" must be specified if this option is used.\n"
"3 - Request both, 1 and 2"},
{"proTxHash", RPCArg::Type::STR_HEX, /* opt */ true, /* default_val */ "", "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."},
}}
.ToString());
{"proTxHash", RPCArg::Type::STR_HEX, /* default */ "", "The proTxHash the contributions will be requested for. Must be member of the specified LLMQ."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue quorum_getdata(const JSONRPCRequest& request)
@ -619,25 +642,26 @@ static UniValue quorum_getdata(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"quorum",
"Set of commands for quorums/LLMQs.\n"
"To get help on individual commands, use \"help quorum command\".\n",
"To get help on individual commands, use \"help quorum command\".\n"
"\nAvailable commands:\n"
" list - List of on-chain quorums\n"
" info - Return information about a quorum\n"
" dkgsimerror - Simulates DKG errors and malicious behavior\n"
" dkgstatus - Return the status of the current DKG process\n"
" memberof - Checks which quorums the given masternode is a member of\n"
" sign - Threshold-sign a message\n"
" verify - Test if a quorum signature is valid for a request id and a message hash\n"
" hasrecsig - Test if a valid recovered signature is present\n"
" getrecsig - Get a recovered signature\n"
" isconflicting - Test if a conflict exists\n"
" selectquorum - Return the quorum that would/should sign a request\n"
" getdata - Request quorum data from other masternodes in the quorum\n",
{
{"command", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The command to execute"},
}}
.ToString() +
"\nAvailable commands:\n"
" list - List of on-chain quorums\n"
" info - Return information about a quorum\n"
" dkgsimerror - Simulates DKG errors and malicious behavior\n"
" dkgstatus - Return the status of the current DKG process\n"
" memberof - Checks which quorums the given masternode is a member of\n"
" sign - Threshold-sign a message\n"
" verify - Test if a quorum signature is valid for a request id and a message hash\n"
" hasrecsig - Test if a valid recovered signature is present\n"
" getrecsig - Get a recovered signature\n"
" isconflicting - Test if a conflict exists\n"
" selectquorum - Return the quorum that would/should sign a request\n"
" getdata - Request quorum data from other masternodes in the quorum\n"
);
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue _quorum(const JSONRPCRequest& request)
@ -678,11 +702,13 @@ static void verifychainlock_help()
RPCHelpMan{"verifychainlock",
"Test if a quorum signature is valid for a ChainLock.\n",
{
{"blockHash", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The block hash of the ChainLock."},
{"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The signature of the ChainLock."},
{"blockHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The height of the ChainLock. There will be an internal lookup of \"blockHash\" if this is not provided."},
}}
.ToString());
{"blockHash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash of the ChainLock."},
{"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The signature of the ChainLock."},
{"blockHeight", RPCArg::Type::NUM, /* default */ "", "The height of the ChainLock. There will be an internal lookup of \"blockHash\" if this is not provided."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue verifychainlock(const JSONRPCRequest& request)
@ -720,12 +746,14 @@ static void verifyislock_help()
RPCHelpMan{"verifyislock",
"Test if a quorum signature is valid for an InstantSend Lock\n",
{
{"id", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "Request id."},
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The transaction id."},
{"signature", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The InstantSend Lock signature to verify."},
{"maxHeight", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "", "The maximum height to search quorums from."},
}}
.ToString());
{"id", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Request id."},
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id."},
{"signature", RPCArg::Type::STR, RPCArg::Optional::NO, "The InstantSend Lock signature to verify."},
{"maxHeight", RPCArg::Type::NUM, /* default */ "", "The maximum height to search quorums from."},
},
RPCResults{},
RPCExamples{""},
}.ToString());
}
static UniValue verifyislock(const JSONRPCRequest& request)

View File

@ -276,12 +276,14 @@ UniValue help(const JSONRPCRequest& jsonRequest)
RPCHelpMan{"help",
"\nList all commands, or get help for a specified command.\n",
{
{"command", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The command to get help on"},
{"subcommand", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "The subcommand to get help on. Please note that not all subcommands support this at the moment"},
}}
.ToString() +
"\nResult:\n"
{"command", RPCArg::Type::STR, /* default */ "all commands", "The command to get help on"},
{"subcommand", RPCArg::Type::STR, /* default */ "all subcommands", "The subcommand to get help on. Please note that not all subcommands support this at the moment"},
},
RPCResult{
"\"text\" (string) The help text\n"
},
RPCExamples{""},
}.ToString()
);
std::string strCommand, strSubCommand;
@ -303,8 +305,11 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
throw std::runtime_error(
RPCHelpMan{"stop",
"\nStop Dash Core server.", {}}
.ToString());
"\nStop Dash Core server.",
{},
RPCResults{},
RPCExamples{""},
}.ToString());
// Event loop will exit after current HTTP requests have been handled, so
// this reply will get back to the client.
StartShutdown();
@ -319,14 +324,16 @@ static UniValue uptime(const JSONRPCRequest& jsonRequest)
if (jsonRequest.fHelp || jsonRequest.params.size() > 0)
throw std::runtime_error(
RPCHelpMan{"uptime",
"\nReturns the total uptime of the server.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns the total uptime of the server.\n",
{},
RPCResult{
"ttt (numeric) The number of seconds that the server has been running\n"
"\nExamples:\n"
+ HelpExampleCli("uptime", "")
},
RPCExamples{
HelpExampleCli("uptime", "")
+ HelpExampleRpc("uptime", "")
);
},
}.ToString());
return GetTime() - GetStartupTime();
}

View File

@ -147,12 +147,12 @@ struct Sections {
left += outer_type == OuterType::OBJ ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false);
}
left += ",";
PushSection({left, arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR)});
PushSection({left, arg.ToDescriptionString()});
break;
}
case RPCArg::Type::OBJ:
case RPCArg::Type::OBJ_USER_KEYS: {
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR);
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
PushSection({indent + "{", right});
for (const auto& arg_inner : arg.m_inner) {
Push(arg_inner, current_indent + 2, OuterType::OBJ);
@ -167,7 +167,7 @@ struct Sections {
auto left = indent;
left += outer_type == OuterType::OBJ ? "\"" + arg.m_name + "\": " : "";
left += "[";
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString(/* implicitly_required */ outer_type == OuterType::ARR);
const auto right = outer_type == OuterType::NAMED_ARG ? "" : arg.ToDescriptionString();
PushSection({left, right});
for (const auto& arg_inner : arg.m_inner) {
Push(arg_inner, current_indent + 2, OuterType::ARR);
@ -219,8 +219,12 @@ struct Sections {
}
};
RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
: m_name{name}, m_description{description}, m_args{args}
RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples)
: m_name{std::move(name)},
m_description{std::move(description)},
m_args{std::move(args)},
m_results{std::move(results)},
m_examples{std::move(examples)}
{
std::set<std::string> named_args;
for (const auto& arg : m_args) {
@ -229,6 +233,25 @@ RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description,
}
}
std::string RPCResults::ToDescriptionString() const
{
std::string result;
for (const auto& r : m_results) {
if (r.m_cond.empty()) {
result += "\nResult:\n";
} else {
result += "\nResult (" + r.m_cond + "):\n";
}
result += r.m_result;
}
return result;
}
std::string RPCExamples::ToDescriptionString() const
{
return m_examples.empty() ? m_examples : "\nExamples:\n" + m_examples;
}
std::string RPCHelpMan::ToString() const
{
std::string ret;
@ -237,8 +260,14 @@ std::string RPCHelpMan::ToString() const
ret += m_name;
bool was_optional{false};
for (const auto& arg : m_args) {
bool optional;
if (arg.m_fallback.which() == 1) {
optional = true;
} else {
optional = RPCArg::Optional::NO != boost::get<RPCArg::Optional>(arg.m_fallback);
}
ret += " ";
if (arg.m_optional) {
if (optional) {
if (!was_optional) ret += "( ";
was_optional = true;
} else {
@ -269,10 +298,16 @@ std::string RPCHelpMan::ToString() const
}
ret += sections.ToString();
// Result
ret += m_results.ToDescriptionString();
// Examples
ret += m_examples.ToDescriptionString();
return ret;
}
std::string RPCArg::ToDescriptionString(const bool implicitly_required) const
std::string RPCArg::ToDescriptionString() const
{
std::string ret;
ret += "(";
@ -310,19 +345,24 @@ std::string RPCArg::ToDescriptionString(const bool implicitly_required) const
// no default case, so the compiler can warn about missing cases
}
}
if (!implicitly_required) {
ret += ", ";
if (m_optional) {
ret += "optional";
if (!m_default_value.empty()) {
ret += ", default=" + m_default_value;
} else {
// TODO enable this assert, when all optional parameters have their default value documented
//assert(false);
}
} else {
ret += "required";
assert(m_default_value.empty()); // Default value is ignored, and must not be present
if (m_fallback.which() == 1) {
ret += ", optional, default=" + boost::get<std::string>(m_fallback);
} else {
switch (boost::get<RPCArg::Optional>(m_fallback)) {
case RPCArg::Optional::OMITTED: {
// nothing to do. Element is treated as if not present and has no default value
break;
}
case RPCArg::Optional::OMITTED_NAMED_ARG: {
ret += ", optional"; // Default value is "null"
break;
}
case RPCArg::Optional::NO: {
ret += ", required";
break;
}
// no default case, so the compiler can warn about missing cases
}
}
ret += ")";

View File

@ -16,6 +16,8 @@
#include <string>
#include <vector>
#include <boost/variant.hpp>
class CKeyStore;
class CPubKey;
class CScript;
@ -49,11 +51,28 @@ struct RPCArg {
AMOUNT, //!< Special type representing a floating point amount (can be either NUM or STR)
STR_HEX, //!< Special type that is a STR with only hex chars
};
enum class Optional {
/** Required arg */
NO,
/**
* Optinal arg that is a named argument and has a default value of
* `null`. When possible, the default value should be specified.
*/
OMITTED_NAMED_ARG,
/**
* Optional argument with default value omitted because they are
* implicitly clear. That is, elements in an array or object may not
* exist by default.
* When possible, the default value should be specified.
*/
OMITTED,
};
using Fallback = boost::variant<Optional, /* default value for optional args */ std::string>;
const std::string m_name; //!< The name of the arg (can be empty for inner args)
const Type m_type;
const std::vector<RPCArg> m_inner; //!< Only used for arrays or dicts
const bool m_optional;
const std::string m_default_value; //!< Only used for optional args
const Fallback m_fallback;
const std::string m_description;
const std::string m_oneline_description; //!< Should be empty unless it is supposed to override the auto-generated summary line
const std::vector<std::string> m_type_str; //!< Should be empty unless it is supposed to override the auto-generated type strings. Vector length is either 0 or 2, m_type_str.at(0) will override the type of the value in a key-value pair, m_type_str.at(1) will override the type in the argument description.
@ -61,15 +80,13 @@ struct RPCArg {
RPCArg(
const std::string& name,
const Type& type,
const bool opt,
const std::string& default_val,
const Fallback& fallback,
const std::string& description,
const std::string& oneline_description = "",
const std::vector<std::string>& type_str = {})
: m_name{name},
m_type{type},
m_optional{opt},
m_default_value{default_val},
m_fallback{fallback},
m_description{description},
m_oneline_description{oneline_description},
m_type_str{type_str}
@ -80,8 +97,7 @@ struct RPCArg {
RPCArg(
const std::string& name,
const Type& type,
const bool opt,
const std::string& default_val,
const Fallback& fallback,
const std::string& description,
const std::vector<RPCArg>& inner,
const std::string& oneline_description = "",
@ -89,8 +105,7 @@ struct RPCArg {
: m_name{name},
m_type{type},
m_inner{inner},
m_optional{opt},
m_default_value{default_val},
m_fallback{fallback},
m_description{description},
m_oneline_description{oneline_description},
m_type_str{type_str}
@ -111,15 +126,66 @@ struct RPCArg {
/**
* Return the description string, including the argument type and whether
* the argument is required.
* implicitly_required is set for arguments in an array, which are neither optional nor required.
*/
std::string ToDescriptionString(bool implicitly_required = false) const;
std::string ToDescriptionString() const;
};
struct RPCResult {
const std::string m_cond;
const std::string m_result;
explicit RPCResult(std::string result)
: m_cond{}, m_result{std::move(result)}
{
assert(!m_result.empty());
}
RPCResult(std::string cond, std::string result)
: m_cond{std::move(cond)}, m_result{std::move(result)}
{
assert(!m_cond.empty());
assert(!m_result.empty());
}
};
struct RPCResults {
const std::vector<RPCResult> m_results;
RPCResults()
: m_results{}
{
}
RPCResults(RPCResult result)
: m_results{{result}}
{
}
RPCResults(std::initializer_list<RPCResult> results)
: m_results{results}
{
}
/**
* Return the description string.
*/
std::string ToDescriptionString() const;
};
struct RPCExamples {
const std::string m_examples;
RPCExamples(
std::string examples)
: m_examples(std::move(examples))
{
}
std::string ToDescriptionString() const;
};
class RPCHelpMan
{
public:
RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args);
RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples);
std::string ToString() const;
@ -127,6 +193,8 @@ private:
const std::string m_name;
const std::string m_description;
const std::vector<RPCArg> m_args;
const RPCResults m_results;
const RPCExamples m_examples;
};
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr);

View File

@ -92,16 +92,16 @@ UniValue importprivkey(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"importprivkey",
"\nAdds a private key (as returned by dumpprivkey) to your wallet. Requires a new wallet backup.\n"
"Hint: use importmulti to import more than one private key.\n",
{
{"privkey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The private key (see dumpprivkey)"},
{"label", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Rescan the wallet for transactions"},
}}
.ToString() +
"Hint: use importmulti to import more than one private key.\n"
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
"may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
"\nExamples:\n"
"may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n",
{
{"privkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The private key (see dumpprivkey)"},
{"label", RPCArg::Type::STR, /* default */ "current label if address exists, otherwise \"\"", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"},
},
RPCResults{},
RPCExamples{
"\nDump a private key\n"
+ HelpExampleCli("dumpprivkey", "\"myaddress\"") +
"\nImport the private key with rescan\n"
@ -112,7 +112,8 @@ UniValue importprivkey(const JSONRPCRequest& request)
+ HelpExampleCli("importprivkey", "\"mykey\" \"\" false") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")
);
},
}.ToString());
if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot import private keys to a wallet with private keys disabled");
@ -183,16 +184,18 @@ UniValue abortrescan(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() > 0)
throw std::runtime_error(
RPCHelpMan{"abortrescan",
"\nStops current wallet rescan triggered by an RPC call, e.g. by an importprivkey call.\n", {}}
.ToString() +
"\nExamples:\n"
"\nStops current wallet rescan triggered by an RPC call, e.g. by an importprivkey call.\n",
{},
RPCResults{},
RPCExamples{
"\nImport a private key\n"
+ HelpExampleCli("importprivkey", "\"mykey\"") +
"\nAbort the running wallet rescan\n"
+ HelpExampleCli("abortrescan", "") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("abortrescan", "")
);
},
}.ToString());
if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false;
pwallet->AbortRescan();
@ -246,27 +249,28 @@ UniValue importaddress(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw std::runtime_error(
RPCHelpMan{"importaddress",
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n",
{
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The Dash address (or hex-encoded script)"},
{"label", RPCArg::Type::STR, /* opt */ true, /* default_val */ "\"\"", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Rescan the wallet for transactions"},
{"p2sh", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Add the P2SH version of the script as well"},
}}
.ToString() +
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
"may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
"If you have the full public key, you should call importpubkey instead of this.\n"
"\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
"as change, and not show up in many RPCs.\n"
"\nExamples:\n"
"as change, and not show up in many RPCs.\n",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The Dash address (or hex-encoded script)"},
{"label", RPCArg::Type::STR, /* default */ "\"\"", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"},
{"p2sh", RPCArg::Type::BOOL, /* default */ "false", "Add the P2SH version of the script as well"},
},
RPCResults{},
RPCExamples{
"\nImport an address with rescan\n"
+ HelpExampleCli("importaddress", "\"myaddress\"") +
"\nImport using a label without rescan\n"
+ HelpExampleCli("importaddress", "\"myaddress\" \"testing\" false") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false")
);
},
}.ToString());
std::string strLabel;
@ -330,10 +334,12 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
RPCHelpMan{"importprunedfunds",
"\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n",
{
{"rawtransaction", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "A raw transaction in hex funding an already-existing address in wallet"},
{"txoutproof", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex output from gettxoutproof that contains the transaction"},
}}
.ToString()
{"rawtransaction", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A raw transaction in hex funding an already-existing address in wallet"},
{"txoutproof", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex output from gettxoutproof that contains the transaction"},
},
RPCResults{},
RPCExamples{""},
}.ToString()
);
CMutableTransaction tx;
@ -397,14 +403,15 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
RPCHelpMan{"removeprunedfunds",
"\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.\n",
{
{"txid", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "The hex-encoded id of the transaction you are deleting"},
}}
.ToString() +
"\nExamples:\n"
+ HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded id of the transaction you are deleting"},
},
RPCResults{},
RPCExamples{
HelpExampleCli("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("removeprunedfunds", "\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"")
);
},
}.ToString());
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
@ -437,23 +444,24 @@ UniValue importpubkey(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw std::runtime_error(
RPCHelpMan{"importpubkey",
"\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n",
{
{"pubkey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The hex-encoded public key"},
{"label", RPCArg::Type::STR, /* opt */ true, /* default_val */ "\"\"", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Rescan the wallet for transactions"},
}}
.ToString() +
"\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
"may report that the imported pubkey exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n"
"\nExamples:\n"
"may report that the imported pubkey exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n",
{
{"pubkey", RPCArg::Type::STR, RPCArg::Optional::NO, "The hex-encoded public key"},
{"label", RPCArg::Type::STR, /* default */ "\"\"", "An optional label"},
{"rescan", RPCArg::Type::BOOL, /* default */ "true", "Rescan the wallet for transactions"},
},
RPCResults{},
RPCExamples{
"\nImport a public key with rescan\n"
+ HelpExampleCli("importpubkey", "\"mypubkey\"") +
"\nImport using a label without rescan\n"
+ HelpExampleCli("importpubkey", "\"mypubkey\" \"testing\" false") +
"\nAs a JSON-RPC call\n"
+ HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")
);
},
}.ToString());
std::string strLabel;
@ -510,17 +518,18 @@ UniValue importwallet(const JSONRPCRequest& request)
RPCHelpMan{"importwallet",
"\nImports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup to include imported keys.\n",
{
{"filename", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The wallet file"},
}}
.ToString() +
"\nExamples:\n"
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet file"},
},
RPCResults{},
RPCExamples{
"\nDump the wallet\n"
+ HelpExampleCli("dumpwallet", "\"test\"") +
"\nImport the wallet\n"
+ HelpExampleCli("importwallet", "\"test\"") +
"\nImport using the json rpc call\n"
+ HelpExampleRpc("importwallet", "\"test\"")
);
},
}.ToString());
if (fPruneMode)
throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode");
@ -668,18 +677,19 @@ UniValue importelectrumwallet(const JSONRPCRequest& request)
RPCHelpMan{"importselectrumwallet",
"\nImports keys from an Electrum wallet export file (.csv or .json)\n",
{
{"filename", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The Electrum wallet export file, should be in csv or json format"},
{"index", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Rescan the wallet for transactions starting from this block index"},
}}
.ToString() +
"\nExamples:\n"
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The Electrum wallet export file, should be in csv or json format"},
{"index", RPCArg::Type::NUM, /* default */ "0", "Rescan the wallet for transactions starting from this block index"},
},
RPCResults{},
RPCExamples{
"\nImport the wallet\n"
+ HelpExampleCli("importelectrumwallet", "\"test.csv\"")
+ HelpExampleCli("importelectrumwallet", "\"test.json\"") +
"\nImport using the json rpc call\n"
+ HelpExampleRpc("importelectrumwallet", "\"test.csv\"")
+ HelpExampleRpc("importelectrumwallet", "\"test.json\"")
);
},
}.ToString());
if (fPruneMode)
throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode");
@ -818,16 +828,17 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
"\nReveals the private key corresponding to 'address'.\n"
"Then the importprivkey can be used with this output\n",
{
{"address", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The dash address for the private key"},
}}
.ToString() +
"\nResult:\n"
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address for the private key"},
},
RPCResult{
"\"key\" (string) The private key\n"
"\nExamples:\n"
+ HelpExampleCli("dumpprivkey", "\"myaddress\"")
},
RPCExamples{
HelpExampleCli("dumpprivkey", "\"myaddress\"")
+ HelpExampleCli("importprivkey", "\"mykey\"")
+ HelpExampleRpc("dumpprivkey", "\"myaddress\"")
);
},
}.ToString());
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);
@ -861,18 +872,19 @@ UniValue dumphdinfo(const JSONRPCRequest& request)
throw std::runtime_error(
RPCHelpMan{"dumphdinfo",
"Returns an object containing sensitive private info about this HD wallet.\n",
{}}
.ToString() +
"\nResult:\n"
{},
RPCResult{
"{\n"
" \"hdseed\": \"seed\", (string) The HD seed (bip32, in hex)\n"
" \"mnemonic\": \"words\", (string) The mnemonic for this HD wallet (bip39, english words) \n"
" \"mnemonicpassphrase\": \"passphrase\", (string) The mnemonic passphrase for this HD wallet (bip39)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("dumphdinfo", "")
},
RPCExamples{
HelpExampleCli("dumphdinfo", "")
+ HelpExampleRpc("dumphdinfo", "")
);
},
}.ToString());
LOCK(pwallet->cs_wallet);
@ -913,19 +925,20 @@ UniValue dumpwallet(const JSONRPCRequest& request)
"Note that if your wallet contains keys which are not derived from your HD seed (e.g. imported keys), these are not covered by\n"
"only backing up the seed itself, and must be backed up too (e.g. ensure you back up the whole dumpfile).\n",
{
{"filename", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "The filename with path (either absolute or relative to dashd)"},
}}
.ToString() +
"\nResult:\n"
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The filename with path (either absolute or relative to dashd)"},
},
RPCResult{
"{ (json object)\n"
" \"keys\" : { (int) The number of keys contained in the wallet dump\n"
" \"filename\" : { (string) The filename with full absolute path\n"
" \"warning\" : { (string) A warning about not sharing the wallet dump with anyone\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("dumpwallet", "\"test\"")
},
RPCExamples{
HelpExampleCli("dumpwallet", "\"test\"")
+ HelpExampleRpc("dumpwallet", "\"test\"")
);
},
}.ToString());
auto locked_chain = pwallet->chain().lock();
LockAnnotation lock(::cs_main);
@ -1464,18 +1477,20 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
if (mainRequest.fHelp || mainRequest.params.size() < 1 || mainRequest.params.size() > 2)
throw std::runtime_error(
RPCHelpMan{"importmulti",
"\nImport addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options). Requires a new wallet backup.\n",
"\nImport addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options). Requires a new wallet backup.\n"
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
"may report that the imported keys, addresses or scripts exists but related transactions are still missing.\n",
{
{"requests", RPCArg::Type::ARR, /* opt */ false, /* default_val */ "", "Data to be imported",
{"requests", RPCArg::Type::ARR, RPCArg::Optional::NO, "Data to be imported",
{
{"", RPCArg::Type::OBJ, /* opt */ false, /* default_val */ "", "",
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{
{"desc", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys"
{"desc", RPCArg::Type::STR, /* default */ "", "Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys"
},
{"scriptPubKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", "Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor",
{"scriptPubKey", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor",
/* oneline_description */ "", {"\"<script>\" | { \"address\":\"<address>\" }", "string / json"}
},
{"timestamp", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "Creation time of the key in seconds since epoch (Jan 1 1970 GMT),\n"
{"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, "Creation time of the key in seconds since epoch (Jan 1 1970 GMT),\n"
" or the string \"now\" to substitute the current synced blockchain time. The timestamp of the oldest\n"
" key will determine how far back blockchain rescans need to begin for missing wallet transactions.\n"
" \"now\" can be specified to bypass scanning, for keys which are known to never have been used, and\n"
@ -1483,46 +1498,47 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
" creation time of all keys being imported by the importmulti call will be scanned.",
/* oneline_description */ "", {"timestamp | \"now\"", "integer / string"}
},
{"redeemscript", RPCArg::Type::STR, /* opt */ true, /* default_val */ "", "Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey"},
{"pubkeys", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "Array of strings giving pubkeys to import. They must occur in P2PKH scripts. They are not required when the private key is also provided (see the \"keys\" argument).",
{"redeemscript", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Allowed only if the scriptPubKey is a P2SH address or a P2SH scriptPubKey"},
{"pubkeys", RPCArg::Type::ARR, /* default */ "empty array", "Array of strings giving pubkeys to import. They must occur in P2PKH scripts. They are not required when the private key is also provided (see the \"keys\" argument).",
{
{"pubKey", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", ""},
{"pubKey", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
}
},
{"keys", RPCArg::Type::ARR, /* opt */ true, /* default_val */ "", "Array of strings giving private keys to import. The corresponding public keys must occur in the output or redeemscript.",
{"keys", RPCArg::Type::ARR, /* default */ "empty array", "Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript.",
{
{"key", RPCArg::Type::STR, /* opt */ false, /* default_val */ "", ""},
{"key", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
}
},
{"range", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "If a ranged descriptor is used, this specifies the start and end of the range to import",
{"range", RPCArg::Type::OBJ, /* default */ "", "If a ranged descriptor is used, this specifies the start and end of the range to import",
{
{"start", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0", "Start of the range to import"},
{"end", RPCArg::Type::NUM, /* opt */ false, /* default_val */ "", "End of the range to import (inclusive)"},
{"start", RPCArg::Type::NUM, /* default */ "0", "Start of the range to import"},
{"end", RPCArg::Type::NUM, RPCArg::Optional::NO, "End of the range to import (inclusive)"},
}
},
{"internal", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Stating whether matching outputs should be treated as not incoming payments (also known as change)"},
{"watchonly", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "false", "Stating whether matching outputs should be considered watched even when not all private keys are provided."},
{"label", RPCArg::Type::STR, /* opt */ true, /* default_val */ "''", "Label to assign to the address, only allowed with internal=false"},
{"internal", RPCArg::Type::BOOL, /* default */ "false", "Stating whether matching outputs should be treated as not incoming payments (also known as change)"},
{"watchonly", RPCArg::Type::BOOL, /* default */ "false", "Stating whether matching outputs should be considered watched even when not all private keys are provided."},
{"label", RPCArg::Type::STR, /* default */ "''", "Label to assign to the address, only allowed with internal=false"},
},
},
},
"\"requests\""},
{"options", RPCArg::Type::OBJ, /* opt */ true, /* default_val */ "", "",
{"options", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "",
{
{"rescan", RPCArg::Type::BOOL, /* opt */ true, /* default_val */ "true", "Stating if should rescan the blockchain after all imports"},
{"rescan", RPCArg::Type::BOOL, /* default */ "true", "Stating if should rescan the blockchain after all imports"},
},
"\"options\""},
}}
.ToString() +
"\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n"
"may report that the imported keys, addresses or scripts exists but related transactions are still missing.\n"
"\nExamples:\n" +
HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }, "
"{ \"scriptPubKey\": { \"address\": \"<my 2nd address>\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") +
HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'") +
},
RPCResult{
"\nResponse is an array with the same size as the input that has the execution result :\n"
" [{\"success\": true}, {\"success\": true, \"warnings\": [\"Ignoring irrelevant private key\"]}, {\"success\": false, \"error\": {\"code\": -1, \"message\": \"Internal Server Error\"}}, ...]\n");
" [{\"success\": true}, {\"success\": true, \"warnings\": [\"Ignoring irrelevant private key\"]}, {\"success\": false, \"error\": {\"code\": -1, \"message\": \"Internal Server Error\"}}, ...]\n"
},
RPCExamples{
HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }, "
"{ \"scriptPubKey\": { \"address\": \"<my 2nd address>\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") +
HelpExampleCli("importmulti", "'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'")
},
}.ToString()
);
RPCTypeCheck(mainRequest.params, {UniValue::VARR, UniValue::VOBJ});

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,9 @@ UniValue getzmqnotifications(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() != 0) {
throw std::runtime_error(
RPCHelpMan{"getzmqnotifications",
"\nReturns information about the active ZeroMQ notifications.\n", {}}
.ToString() +
"\nResult:\n"
"\nReturns information about the active ZeroMQ notifications.\n",
{},
RPCResult{
"[\n"
" { (json object)\n"
" \"type\": \"pubhashtx\", (string) Type of notification\n"
@ -29,10 +29,12 @@ UniValue getzmqnotifications(const JSONRPCRequest& request)
" },\n"
" ...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getzmqnotifications", "")
},
RPCExamples{
HelpExampleCli("getzmqnotifications", "")
+ HelpExampleRpc("getzmqnotifications", "")
);
},
}.ToString());
}
UniValue result(UniValue::VARR);