Skip to content

Commit f8617c2

Browse files
committed
rpc: Named arguments for blockchain calls
>>> based on bitcoin/bitcoin@495eb44
1 parent a00e323 commit f8617c2

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/rpc/blockchain.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ UniValue getrawmempool(const JSONRPCRequest& request)
447447
"\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
448448

449449
"\nArguments:\n"
450-
"1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n"
450+
"1. verbose (boolean, optional, default=false) True for a json object, false for array of transaction ids\n"
451451

452452
"\nResult: (for verbose = false):\n"
453453
"[ (json array of string)\n"
@@ -490,11 +490,11 @@ UniValue getblockhash(const JSONRPCRequest& request)
490490
{
491491
if (request.fHelp || request.params.size() != 1)
492492
throw std::runtime_error(
493-
"getblockhash index\n"
494-
"\nReturns hash of block in best-block-chain at index provided.\n"
493+
"getblockhash height\n"
494+
"\nReturns hash of block in best-block-chain at height provided.\n"
495495

496496
"\nArguments:\n"
497-
"1. index (numeric, required) The block index\n"
497+
"1. height (numeric, required) The height index\n"
498498

499499
"\nResult:\n"
500500
"\"hash\" (string) The block hash\n"
@@ -516,13 +516,13 @@ UniValue getblock(const JSONRPCRequest& request)
516516
{
517517
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
518518
throw std::runtime_error(
519-
"getblock \"hash\" ( verbose )\n"
519+
"getblock \"blockhash\" ( verbose )\n"
520520
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
521521
"If verbose is true, returns an Object with information about block <hash>.\n"
522522

523523
"\nArguments:\n"
524-
"1. \"hash\" (string, required) The block hash\n"
525-
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
524+
"1. \"blockhash\" (string, required) The block hash\n"
525+
"2. verbose (boolean, optional, default=true) True for a json object, false for the hex encoded data\n"
526526

527527
"\nResult (for verbose = true):\n"
528528
"{\n"
@@ -588,13 +588,13 @@ UniValue getblockheader(const JSONRPCRequest& request)
588588
{
589589
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
590590
throw std::runtime_error(
591-
"getblockheader \"hash\" ( verbose )\n"
591+
"getblockheader \"blockhash\" ( verbose )\n"
592592
"\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash' header.\n"
593593
"If verbose is true, returns an Object with information about block <hash> header.\n"
594594

595595
"\nArguments:\n"
596-
"1. \"hash\" (string, required) The block hash\n"
597-
"2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
596+
"1. \"blockhash\" (string, required) The block hash\n"
597+
"2. verbose (boolean, optional, default=true) True for a json object, false for the hex encoded data\n"
598598

599599
"\nResult (for verbose = true):\n"
600600
"{\n"
@@ -646,16 +646,16 @@ UniValue getsupplyinfo(const JSONRPCRequest& request)
646646
{
647647
if (request.fHelp || request.params.size() > 1)
648648
throw std::runtime_error(
649-
"getsupplyinfo ( forceupdate )\n"
650-
"\nIf forceupdate=false (default if no argument is given): return the last cached money supply"
649+
"getsupplyinfo ( force_update )\n"
650+
"\nIf force_update=false (default if no argument is given): return the last cached money supply"
651651
"\n(sum of spendable transaction outputs) and the height of the chain when it was last updated"
652652
"\n(it is updated periodically, whenever the chainstate is flushed)."
653653
"\n"
654-
"\nIf forceupdate=true: Flush the chainstate to disk and return the money supply updated to"
654+
"\nIf force_update=true: Flush the chainstate to disk and return the money supply updated to"
655655
"\nthe current chain height.\n"
656656

657657
"\nArguments:\n"
658-
"1. forceupdate (boolean, optional, default=false) flush chainstate to disk and update cache\n"
658+
"1. force_update (boolean, optional, default=false) flush chainstate to disk and update cache\n"
659659

660660
"\nResult:\n"
661661
"{\n"
@@ -796,13 +796,13 @@ UniValue gettxout(const JSONRPCRequest& request)
796796
{
797797
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
798798
throw std::runtime_error(
799-
"gettxout \"txid\" n ( includemempool )\n"
799+
"gettxout \"txid\" n ( include_mempool )\n"
800800
"\nReturns details about an unspent transaction output.\n"
801801

802802
"\nArguments:\n"
803803
"1. \"txid\" (string, required) The transaction id\n"
804804
"2. n (numeric, required) vout value\n"
805-
"3. includemempool (boolean, optional) Whether to included the mem pool\n"
805+
"3. include_mempool (boolean, optional) Whether to included the mem pool\n"
806806

807807
"\nResult:\n"
808808
"{\n"
@@ -876,11 +876,11 @@ UniValue verifychain(const JSONRPCRequest& request)
876876
{
877877
if (request.fHelp || request.params.size() > 1)
878878
throw std::runtime_error(
879-
"verifychain ( numblocks )\n"
879+
"verifychain ( nblocks )\n"
880880
"\nVerifies blockchain database.\n"
881881

882882
"\nArguments:\n"
883-
"1. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
883+
"1. nblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
884884

885885
"\nResult:\n"
886886
"true|false (boolean) Verified or not\n"
@@ -1189,11 +1189,11 @@ UniValue invalidateblock(const JSONRPCRequest& request)
11891189
{
11901190
if (request.fHelp || request.params.size() != 1)
11911191
throw std::runtime_error(
1192-
"invalidateblock \"hash\"\n"
1192+
"invalidateblock \"blockhash\"\n"
11931193
"\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
11941194

11951195
"\nArguments:\n"
1196-
"1. hash (string, required) the hash of the block to mark as invalid\n"
1196+
"1. blockhash (string, required) the hash of the block to mark as invalid\n"
11971197

11981198
"\nExamples:\n" +
11991199
HelpExampleCli("invalidateblock", "\"blockhash\"") + HelpExampleRpc("invalidateblock", "\"blockhash\""));
@@ -1229,12 +1229,12 @@ UniValue reconsiderblock(const JSONRPCRequest& request)
12291229
{
12301230
if (request.fHelp || request.params.size() != 1)
12311231
throw std::runtime_error(
1232-
"reconsiderblock \"hash\"\n"
1232+
"reconsiderblock \"blockhash\"\n"
12331233
"\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
12341234
"This can be used to undo the effects of invalidateblock.\n"
12351235

12361236
"\nArguments:\n"
1237-
"1. hash (string, required) the hash of the block to reconsider\n"
1237+
"1. blockhash (string, required) the hash of the block to reconsider\n"
12381238

12391239
"\nExamples:\n" +
12401240
HelpExampleCli("reconsiderblock", "\"blockhash\"") + HelpExampleRpc("reconsiderblock", "\"blockhash\""));
@@ -1300,7 +1300,7 @@ void validaterange(const UniValue& params, int& heightStart, int& heightEnd, int
13001300
}
13011301

13021302
UniValue getblockindexstats(const JSONRPCRequest& request) {
1303-
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
1303+
if (request.fHelp || request.params.size() != 2)
13041304
throw std::runtime_error(
13051305
"getblockindexstats height range\n"
13061306
"\nReturns aggregated BlockIndex data for blocks "
@@ -1441,33 +1441,33 @@ UniValue getfeeinfo(const JSONRPCRequest& request)
14411441
}
14421442

14431443
static const CRPCCommand commands[] =
1444-
{ // category name actor (function) okSafeMode
1445-
// --------------------- ------------------------ ----------------------- ----------
1446-
{ "blockchain", "getblockindexstats", &getblockindexstats, true },
1447-
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true },
1448-
{ "blockchain", "getbestblockhash", &getbestblockhash, true },
1449-
{ "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true },
1450-
{ "blockchain", "getblockcount", &getblockcount, true },
1451-
{ "blockchain", "getblock", &getblock, true },
1452-
{ "blockchain", "getblockhash", &getblockhash, true },
1453-
{ "blockchain", "getblockheader", &getblockheader, false },
1454-
{ "blockchain", "getchaintips", &getchaintips, true },
1455-
{ "blockchain", "getdifficulty", &getdifficulty, true },
1456-
{ "blockchain", "getfeeinfo", &getfeeinfo, true },
1457-
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true },
1458-
{ "blockchain", "getsupplyinfo", &getsupplyinfo, true },
1459-
{ "blockchain", "getrawmempool", &getrawmempool, true },
1460-
{ "blockchain", "gettxout", &gettxout, true },
1461-
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
1462-
{ "blockchain", "verifychain", &verifychain, true },
1444+
{ // category name actor (function) okSafe argNames
1445+
// --------------------- ------------------------ ----------------------- ------ --------
1446+
{ "blockchain", "getblockindexstats", &getblockindexstats, true, {"height","range"} },
1447+
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true, {} },
1448+
{ "blockchain", "getbestblockhash", &getbestblockhash, true, {} },
1449+
{ "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true, {} },
1450+
{ "blockchain", "getblockcount", &getblockcount, true, {} },
1451+
{ "blockchain", "getblock", &getblock, true, {"blockhash","verbose"} },
1452+
{ "blockchain", "getblockhash", &getblockhash, true, {"height"} },
1453+
{ "blockchain", "getblockheader", &getblockheader, false, {"blockhash","verbose"} },
1454+
{ "blockchain", "getchaintips", &getchaintips, true, {} },
1455+
{ "blockchain", "getdifficulty", &getdifficulty, true, {} },
1456+
{ "blockchain", "getfeeinfo", &getfeeinfo, true, {"blocks"} },
1457+
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true, {} },
1458+
{ "blockchain", "getsupplyinfo", &getsupplyinfo, true, {"force_update"} },
1459+
{ "blockchain", "getrawmempool", &getrawmempool, true, {"verbose"} },
1460+
{ "blockchain", "gettxout", &gettxout, true, {"txid","n","include_mempool"} },
1461+
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, {} },
1462+
{ "blockchain", "verifychain", &verifychain, true, {"nblocks"} },
14631463

14641464
/* Not shown in help */
1465-
{ "hidden", "invalidateblock", &invalidateblock, true },
1466-
{ "hidden", "reconsiderblock", &reconsiderblock, true },
1467-
{ "hidden", "waitfornewblock", &waitfornewblock, true },
1468-
{ "hidden", "waitforblock", &waitforblock, true },
1469-
{ "hidden", "waitforblockheight", &waitforblockheight, true },
1470-
{ "hidden", "syncwithvalidationinterfacequeue", &syncwithvalidationinterfacequeue, true },
1465+
{ "hidden", "invalidateblock", &invalidateblock, true, {"blockhash"} },
1466+
{ "hidden", "reconsiderblock", &reconsiderblock, true, {"blockhash"} },
1467+
{ "hidden", "waitfornewblock", &waitfornewblock, true, {"timeout"} },
1468+
{ "hidden", "waitforblock", &waitforblock, true, {"blockhash","timeout"} },
1469+
{ "hidden", "waitforblockheight", &waitforblockheight, true, {"height","timeout"} },
1470+
{ "hidden", "syncwithvalidationinterfacequeue", &syncwithvalidationinterfacequeue, true, {} },
14711471

14721472

14731473
};

0 commit comments

Comments
 (0)