Skip to content

Commit 80e16ca

Browse files
committed
Merge #20012: rpc: Remove duplicate name and argNames from CRPCCommand
fa04f9b rpc: Remove duplicate name and argNames from CRPCCommand (MarcoFalke) fa92912 rpc: Use RPCHelpMan for check-rpc-mappings linter (MarcoFalke) faf8356 rpc: [refactor] Use concise C++11 code in CRPCConvertTable constructor (MarcoFalke) Pull request description: Currently, the RPC argument names are specified twice to simplify consistency linting. To avoid having to specify the argnames twice when adding new arguments, remove the linter and add an equivalent test based on RPCHelpMan. ACKs for top commit: laanwj: ACK fa04f9b Tree-SHA512: 3f5f32f5a09b22d879f24aa67031639d2612cff481d6aebc6cfe6fd757cafb3e7bf72120b30466f59292a260747b71e57322c189d5478b668519b9f32fcde31a
2 parents 6ba2ffd + fa04f9b commit 80e16ca

File tree

16 files changed

+284
-349
lines changed

16 files changed

+284
-349
lines changed

ci/lint/06_script.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ test/lint/git-subtree-check.sh src/univalue
2121
test/lint/git-subtree-check.sh src/leveldb
2222
test/lint/git-subtree-check.sh src/crc32c
2323
test/lint/check-doc.py
24-
test/lint/check-rpc-mappings.py .
2524
test/lint/lint-all.sh
2625

2726
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ -n "$CIRRUS_CRON" ]; then

src/qt/test/rpcnestedtests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static RPCHelpMan rpcNestedTest_rpc()
3333
}
3434

3535
static const CRPCCommand vRPCCommands[] = {
36-
{"test", "rpcNestedTest", &rpcNestedTest_rpc, {"arg1", "arg2", "arg3"}},
36+
{"test", &rpcNestedTest_rpc},
3737
};
3838

3939
void RPCNestedTests::rpcNestedTests()

src/rpc/blockchain.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,41 +2480,41 @@ void RegisterBlockchainRPCCommands(CRPCTable &t)
24802480
{
24812481
// clang-format off
24822482
static const CRPCCommand commands[] =
2483-
{ // category name actor (function) argNames
2484-
// --------------------- ------------------------ ----------------------- ----------
2485-
{ "blockchain", "getblockchaininfo", &getblockchaininfo, {} },
2486-
{ "blockchain", "getchaintxstats", &getchaintxstats, {"nblocks", "blockhash"} },
2487-
{ "blockchain", "getblockstats", &getblockstats, {"hash_or_height", "stats"} },
2488-
{ "blockchain", "getbestblockhash", &getbestblockhash, {} },
2489-
{ "blockchain", "getblockcount", &getblockcount, {} },
2490-
{ "blockchain", "getblock", &getblock, {"blockhash","verbosity|verbose"} },
2491-
{ "blockchain", "getblockhash", &getblockhash, {"height"} },
2492-
{ "blockchain", "getblockheader", &getblockheader, {"blockhash","verbose"} },
2493-
{ "blockchain", "getchaintips", &getchaintips, {} },
2494-
{ "blockchain", "getdifficulty", &getdifficulty, {} },
2495-
{ "blockchain", "getmempoolancestors", &getmempoolancestors, {"txid","verbose"} },
2496-
{ "blockchain", "getmempooldescendants", &getmempooldescendants, {"txid","verbose"} },
2497-
{ "blockchain", "getmempoolentry", &getmempoolentry, {"txid"} },
2498-
{ "blockchain", "getmempoolinfo", &getmempoolinfo, {} },
2499-
{ "blockchain", "getrawmempool", &getrawmempool, {"verbose", "mempool_sequence"} },
2500-
{ "blockchain", "gettxout", &gettxout, {"txid","n","include_mempool"} },
2501-
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, {"hash_type"} },
2502-
{ "blockchain", "pruneblockchain", &pruneblockchain, {"height"} },
2503-
{ "blockchain", "savemempool", &savemempool, {} },
2504-
{ "blockchain", "verifychain", &verifychain, {"checklevel","nblocks"} },
2505-
2506-
{ "blockchain", "preciousblock", &preciousblock, {"blockhash"} },
2507-
{ "blockchain", "scantxoutset", &scantxoutset, {"action", "scanobjects"} },
2508-
{ "blockchain", "getblockfilter", &getblockfilter, {"blockhash", "filtertype"} },
2483+
{ // category actor (function)
2484+
// --------------------- ------------------------
2485+
{ "blockchain", &getblockchaininfo, },
2486+
{ "blockchain", &getchaintxstats, },
2487+
{ "blockchain", &getblockstats, },
2488+
{ "blockchain", &getbestblockhash, },
2489+
{ "blockchain", &getblockcount, },
2490+
{ "blockchain", &getblock, },
2491+
{ "blockchain", &getblockhash, },
2492+
{ "blockchain", &getblockheader, },
2493+
{ "blockchain", &getchaintips, },
2494+
{ "blockchain", &getdifficulty, },
2495+
{ "blockchain", &getmempoolancestors, },
2496+
{ "blockchain", &getmempooldescendants, },
2497+
{ "blockchain", &getmempoolentry, },
2498+
{ "blockchain", &getmempoolinfo, },
2499+
{ "blockchain", &getrawmempool, },
2500+
{ "blockchain", &gettxout, },
2501+
{ "blockchain", &gettxoutsetinfo, },
2502+
{ "blockchain", &pruneblockchain, },
2503+
{ "blockchain", &savemempool, },
2504+
{ "blockchain", &verifychain, },
2505+
2506+
{ "blockchain", &preciousblock, },
2507+
{ "blockchain", &scantxoutset, },
2508+
{ "blockchain", &getblockfilter, },
25092509

25102510
/* Not shown in help */
2511-
{ "hidden", "invalidateblock", &invalidateblock, {"blockhash"} },
2512-
{ "hidden", "reconsiderblock", &reconsiderblock, {"blockhash"} },
2513-
{ "hidden", "waitfornewblock", &waitfornewblock, {"timeout"} },
2514-
{ "hidden", "waitforblock", &waitforblock, {"blockhash","timeout"} },
2515-
{ "hidden", "waitforblockheight", &waitforblockheight, {"height","timeout"} },
2516-
{ "hidden", "syncwithvalidationinterfacequeue", &syncwithvalidationinterfacequeue, {} },
2517-
{ "hidden", "dumptxoutset", &dumptxoutset, {"path"} },
2511+
{ "hidden", &invalidateblock, },
2512+
{ "hidden", &reconsiderblock, },
2513+
{ "hidden", &waitfornewblock, },
2514+
{ "hidden", &waitforblock, },
2515+
{ "hidden", &waitforblockheight, },
2516+
{ "hidden", &syncwithvalidationinterfacequeue, },
2517+
{ "hidden", &dumptxoutset, },
25182518
};
25192519
// clang-format on
25202520
for (const auto& c : commands) {

src/rpc/client.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,9 @@ class CRPCConvertTable
210210

211211
CRPCConvertTable::CRPCConvertTable()
212212
{
213-
const unsigned int n_elem =
214-
(sizeof(vRPCConvertParams) / sizeof(vRPCConvertParams[0]));
215-
216-
for (unsigned int i = 0; i < n_elem; i++) {
217-
members.insert(std::make_pair(vRPCConvertParams[i].methodName,
218-
vRPCConvertParams[i].paramIdx));
219-
membersByName.insert(std::make_pair(vRPCConvertParams[i].methodName,
220-
vRPCConvertParams[i].paramName));
213+
for (const auto& cp : vRPCConvertParams) {
214+
members.emplace(cp.methodName, cp.paramIdx);
215+
membersByName.emplace(cp.methodName, cp.paramName);
221216
}
222217
}
223218

src/rpc/mining.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,24 +1232,24 @@ void RegisterMiningRPCCommands(CRPCTable &t)
12321232
{
12331233
// clang-format off
12341234
static const CRPCCommand commands[] =
1235-
{ // category name actor (function) argNames
1236-
// --------------------- ------------------------ ----------------------- ----------
1237-
{ "mining", "getnetworkhashps", &getnetworkhashps, {"nblocks","height"} },
1238-
{ "mining", "getmininginfo", &getmininginfo, {} },
1239-
{ "mining", "prioritisetransaction", &prioritisetransaction, {"txid","dummy","fee_delta"} },
1240-
{ "mining", "getblocktemplate", &getblocktemplate, {"template_request"} },
1241-
{ "mining", "submitblock", &submitblock, {"hexdata","dummy"} },
1242-
{ "mining", "submitheader", &submitheader, {"hexdata"} },
1235+
{ // category actor (function)
1236+
// --------------------- -----------------------
1237+
{ "mining", &getnetworkhashps, },
1238+
{ "mining", &getmininginfo, },
1239+
{ "mining", &prioritisetransaction, },
1240+
{ "mining", &getblocktemplate, },
1241+
{ "mining", &submitblock, },
1242+
{ "mining", &submitheader, },
12431243

12441244

1245-
{ "generating", "generatetoaddress", &generatetoaddress, {"nblocks","address","maxtries"} },
1246-
{ "generating", "generatetodescriptor", &generatetodescriptor, {"num_blocks","descriptor","maxtries"} },
1247-
{ "generating", "generateblock", &generateblock, {"output","transactions"} },
1245+
{ "generating", &generatetoaddress, },
1246+
{ "generating", &generatetodescriptor, },
1247+
{ "generating", &generateblock, },
12481248

1249-
{ "util", "estimatesmartfee", &estimatesmartfee, {"conf_target", "estimate_mode"} },
1249+
{ "util", &estimatesmartfee, },
12501250

1251-
{ "hidden", "estimaterawfee", &estimaterawfee, {"conf_target", "threshold"} },
1252-
{ "hidden", "generate", &generate, {} },
1251+
{ "hidden", &estimaterawfee, },
1252+
{ "hidden", &generate, },
12531253
};
12541254
// clang-format on
12551255
for (const auto& c : commands) {

src/rpc/misc.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -699,23 +699,23 @@ void RegisterMiscRPCCommands(CRPCTable &t)
699699
{
700700
// clang-format off
701701
static const CRPCCommand commands[] =
702-
{ // category name actor (function) argNames
703-
// --------------------- ------------------------ ----------------------- ----------
704-
{ "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
705-
{ "control", "logging", &logging, {"include", "exclude"}},
706-
{ "util", "validateaddress", &validateaddress, {"address"} },
707-
{ "util", "createmultisig", &createmultisig, {"nrequired","keys","address_type"} },
708-
{ "util", "deriveaddresses", &deriveaddresses, {"descriptor", "range"} },
709-
{ "util", "getdescriptorinfo", &getdescriptorinfo, {"descriptor"} },
710-
{ "util", "verifymessage", &verifymessage, {"address","signature","message"} },
711-
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
712-
{ "util", "getindexinfo", &getindexinfo, {"index_name"} },
702+
{ // category actor (function)
703+
// --------------------- ------------------------
704+
{ "control", &getmemoryinfo, },
705+
{ "control", &logging, },
706+
{ "util", &validateaddress, },
707+
{ "util", &createmultisig, },
708+
{ "util", &deriveaddresses, },
709+
{ "util", &getdescriptorinfo, },
710+
{ "util", &verifymessage, },
711+
{ "util", &signmessagewithprivkey, },
712+
{ "util", &getindexinfo, },
713713

714714
/* Not shown in help */
715-
{ "hidden", "setmocktime", &setmocktime, {"timestamp"}},
716-
{ "hidden", "mockscheduler", &mockscheduler, {"delta_time"}},
717-
{ "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
718-
{ "hidden", "echojson", &echojson, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}},
715+
{ "hidden", &setmocktime, },
716+
{ "hidden", &mockscheduler, },
717+
{ "hidden", &echo, },
718+
{ "hidden", &echojson, },
719719
};
720720
// clang-format on
721721
for (const auto& c : commands) {

src/rpc/net.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -941,24 +941,24 @@ void RegisterNetRPCCommands(CRPCTable &t)
941941
{
942942
// clang-format off
943943
static const CRPCCommand commands[] =
944-
{ // category name actor (function) argNames
945-
// --------------------- ------------------------ ----------------------- ----------
946-
{ "network", "getconnectioncount", &getconnectioncount, {} },
947-
{ "network", "ping", &ping, {} },
948-
{ "network", "getpeerinfo", &getpeerinfo, {} },
949-
{ "network", "addnode", &addnode, {"node","command"} },
950-
{ "network", "disconnectnode", &disconnectnode, {"address", "nodeid"} },
951-
{ "network", "getaddednodeinfo", &getaddednodeinfo, {"node"} },
952-
{ "network", "getnettotals", &getnettotals, {} },
953-
{ "network", "getnetworkinfo", &getnetworkinfo, {} },
954-
{ "network", "setban", &setban, {"subnet", "command", "bantime", "absolute"} },
955-
{ "network", "listbanned", &listbanned, {} },
956-
{ "network", "clearbanned", &clearbanned, {} },
957-
{ "network", "setnetworkactive", &setnetworkactive, {"state"} },
958-
{ "network", "getnodeaddresses", &getnodeaddresses, {"count"} },
959-
960-
{ "hidden", "addconnection", &addconnection, {"address", "connection_type"} },
961-
{ "hidden", "addpeeraddress", &addpeeraddress, {"address", "port"} },
944+
{ // category actor
945+
// --------------------- -----------------------
946+
{ "network", &getconnectioncount, },
947+
{ "network", &ping, },
948+
{ "network", &getpeerinfo, },
949+
{ "network", &addnode, },
950+
{ "network", &disconnectnode, },
951+
{ "network", &getaddednodeinfo, },
952+
{ "network", &getnettotals, },
953+
{ "network", &getnetworkinfo, },
954+
{ "network", &setban, },
955+
{ "network", &listbanned, },
956+
{ "network", &clearbanned, },
957+
{ "network", &setnetworkactive, },
958+
{ "network", &getnodeaddresses, },
959+
960+
{ "hidden", &addconnection, },
961+
{ "hidden", &addpeeraddress, },
962962
};
963963
// clang-format on
964964
for (const auto& c : commands) {

src/rpc/rawtransaction.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,27 +1859,27 @@ void RegisterRawTransactionRPCCommands(CRPCTable &t)
18591859
{
18601860
// clang-format off
18611861
static const CRPCCommand commands[] =
1862-
{ // category name actor (function) argNames
1863-
// --------------------- ------------------------ ----------------------- ----------
1864-
{ "rawtransactions", "getrawtransaction", &getrawtransaction, {"txid","verbose","blockhash"} },
1865-
{ "rawtransactions", "createrawtransaction", &createrawtransaction, {"inputs","outputs","locktime","replaceable"} },
1866-
{ "rawtransactions", "decoderawtransaction", &decoderawtransaction, {"hexstring","iswitness"} },
1867-
{ "rawtransactions", "decodescript", &decodescript, {"hexstring"} },
1868-
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, {"hexstring","maxfeerate"} },
1869-
{ "rawtransactions", "combinerawtransaction", &combinerawtransaction, {"txs"} },
1870-
{ "rawtransactions", "signrawtransactionwithkey", &signrawtransactionwithkey, {"hexstring","privkeys","prevtxs","sighashtype"} },
1871-
{ "rawtransactions", "testmempoolaccept", &testmempoolaccept, {"rawtxs","maxfeerate"} },
1872-
{ "rawtransactions", "decodepsbt", &decodepsbt, {"psbt"} },
1873-
{ "rawtransactions", "combinepsbt", &combinepsbt, {"txs"} },
1874-
{ "rawtransactions", "finalizepsbt", &finalizepsbt, {"psbt", "extract"} },
1875-
{ "rawtransactions", "createpsbt", &createpsbt, {"inputs","outputs","locktime","replaceable"} },
1876-
{ "rawtransactions", "converttopsbt", &converttopsbt, {"hexstring","permitsigdata","iswitness"} },
1877-
{ "rawtransactions", "utxoupdatepsbt", &utxoupdatepsbt, {"psbt", "descriptors"} },
1878-
{ "rawtransactions", "joinpsbts", &joinpsbts, {"txs"} },
1879-
{ "rawtransactions", "analyzepsbt", &analyzepsbt, {"psbt"} },
1880-
1881-
{ "blockchain", "gettxoutproof", &gettxoutproof, {"txids", "blockhash"} },
1882-
{ "blockchain", "verifytxoutproof", &verifytxoutproof, {"proof"} },
1862+
{ // category actor (function)
1863+
// --------------------- -----------------------
1864+
{ "rawtransactions", &getrawtransaction, },
1865+
{ "rawtransactions", &createrawtransaction, },
1866+
{ "rawtransactions", &decoderawtransaction, },
1867+
{ "rawtransactions", &decodescript, },
1868+
{ "rawtransactions", &sendrawtransaction, },
1869+
{ "rawtransactions", &combinerawtransaction, },
1870+
{ "rawtransactions", &signrawtransactionwithkey, },
1871+
{ "rawtransactions", &testmempoolaccept, },
1872+
{ "rawtransactions", &decodepsbt, },
1873+
{ "rawtransactions", &combinepsbt, },
1874+
{ "rawtransactions", &finalizepsbt, },
1875+
{ "rawtransactions", &createpsbt, },
1876+
{ "rawtransactions", &converttopsbt, },
1877+
{ "rawtransactions", &utxoupdatepsbt, },
1878+
{ "rawtransactions", &joinpsbts, },
1879+
{ "rawtransactions", &analyzepsbt, },
1880+
1881+
{ "blockchain", &gettxoutproof, },
1882+
{ "blockchain", &verifytxoutproof, },
18831883
};
18841884
// clang-format on
18851885
for (const auto& c : commands) {

0 commit comments

Comments
 (0)