Skip to content

Commit 125048f

Browse files
committed
MERGE-FIX: Fix linter (mostly RPC help)
I also moved some RPC methods that were not at the end of the file with the other ELEMENTS RPC methods. This makes the diff on my machine look crazy. Let's hope GitHub has more intelligent diffs..
1 parent efe4e8f commit 125048f

File tree

13 files changed

+1141
-997
lines changed

13 files changed

+1141
-997
lines changed

src/rpc/blockchain.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,9 +2402,10 @@ UniValue getsidechaininfo(const JSONRPCRequest& request)
24022402
{
24032403
if (request.fHelp || request.params.size() != 0)
24042404
throw std::runtime_error(
2405-
"getsidechaininfo\n"
2406-
"Returns an object containing various state info regarding sidechain functionality.\n"
2407-
"\nResult:\n"
2405+
RPCHelpMan{"getsidechaininfo",
2406+
"Returns an object containing various state info regarding sidechain functionality.\n",
2407+
{},
2408+
RPCResult{
24082409
"{\n"
24092410
" \"fedpegscript\": \"xxxx\", (string) The fedpegscript in hex\n"
24102411
" \"pegged_asset\" : \"xxxx\", (string) Pegged asset type in hex\n"
@@ -2416,10 +2417,12 @@ UniValue getsidechaininfo(const JSONRPCRequest& request)
24162417
" \"parent_pegged_asset\": \"xxxx\", (boolean) If the parent chain has Confidential Assets, the asset id of the pegged asset in that chain.\n"
24172418
" \"enforce_pak\": \"xxxx\", (boolean) If peg-out authorization is being enforced.\n"
24182419
"}\n"
2419-
"\nExamples:\n"
2420-
+ HelpExampleCli("getsidechaininfo", "")
2421-
+ HelpExampleRpc("getsidechaininfo", "")
2422-
);
2420+
},
2421+
RPCExamples{
2422+
HelpExampleCli("getsidechaininfo", "")
2423+
+ HelpExampleRpc("getsidechaininfo", "")
2424+
},
2425+
}.ToString());
24232426

24242427
LOCK(cs_main);
24252428

src/rpc/mining.cpp

Lines changed: 102 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -984,19 +984,25 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
984984
return result;
985985
}
986986

987+
//
988+
// ELEMENTS:
989+
987990
UniValue getnewblockhex(const JSONRPCRequest& request)
988991
{
989992
if (request.fHelp || request.params.size() > 1)
990993
throw std::runtime_error(
991-
"getnewblockhex ( min_tx_age )\n"
992-
"\nGets hex representation of a proposed, unmined new block\n"
993-
"\nArguments:\n"
994-
"1. min_tx_age (numeric, optional, default=0) How many seconds a transaction must have been in the mempool to be inluded in the block proposal. This may help with faster block convergence among functionaries using compact blocks.\n"
995-
"\nResult\n"
994+
RPCHelpMan{"getnewblockhex",
995+
"\nGets hex representation of a proposed, unmined new block\n",
996+
{
997+
{"min_tx_age", RPCArg::Type::NUM, /* default */ "0", "How many seconds a transaction must have been in the mempool to be inluded in the block proposal. This may help with faster block convergence among functionaries using compact blocks."},
998+
},
999+
RPCResult{
9961000
"blockhex (hex) The block hex\n"
997-
"\nExamples:\n"
998-
+ HelpExampleCli("getnewblockhex", "")
999-
);
1001+
},
1002+
RPCExamples{
1003+
HelpExampleCli("getnewblockhex", ""),
1004+
}
1005+
}.ToString());
10001006

10011007
int required_wait = !request.params[0].isNull() ? request.params[0].get_int() : 0;
10021008
if (required_wait < 0) {
@@ -1026,26 +1032,31 @@ UniValue combineblocksigs(const JSONRPCRequest& request)
10261032
{
10271033
if (request.fHelp || request.params.size() != 2)
10281034
throw std::runtime_error(
1029-
"combineblocksigs \"blockhex\" [\"signature\",...]\n"
1030-
"\nMerges signatures on a block proposal\n"
1031-
"\nArguments:\n"
1032-
"1. \"blockhex\" (string, required) The hex-encoded block from getnewblockhex\n"
1033-
"2. \"signatures\" (string) A json array of pubkey/signature pairs\n"
1034-
" [\n"
1035-
" {\n"
1036-
" \"pubkey\":\"hex\", (string) The pubkey for the signature in hex\n"
1037-
" \"sig\":\"hex\" (string) A signature (in the form of a hex-encoded scriptSig)\n"
1038-
" ,...\n"
1039-
" },\n"
1040-
" ]\n"
1041-
"\nResult\n"
1035+
RPCHelpMan{"combineblocksigs",
1036+
"\nMerges signatures on a block proposal\n",
1037+
{
1038+
{"blockhex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded block from getnewblockhex"},
1039+
{"signatures", RPCArg::Type::ARR, RPCArg::Optional::NO, "A json array of pubkey/signature pairs",
1040+
{
1041+
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
1042+
{
1043+
{"pubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The pubkey for the signature in hex"},
1044+
{"sig", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "A signature (in the form of a hex-encoded scriptSig)"},
1045+
},
1046+
},
1047+
},
1048+
},
1049+
},
1050+
RPCResult{
10421051
"{\n"
10431052
" \"hex\": \"value\", (string) The signed block\n"
10441053
" \"complete\": true|false (numeric) If block is complete \n"
1045-
"}\n"
1046-
"\nExamples:\n"
1047-
+ HelpExampleCli("combineblocksigs", "<hex> '[{\"pubkey\":\"hex\",\"sig\":\"hex\"}, ...]'")
1048-
);
1054+
"}\n",
1055+
},
1056+
RPCExamples{
1057+
HelpExampleCli("combineblocksigs", "<hex> '[{\"pubkey\":\"hex\",\"sig\":\"hex\"}, ...]'"),
1058+
},
1059+
}.ToString());
10491060

10501061
if (!g_signed_blocks) {
10511062
throw JSONRPCError(RPC_MISC_ERROR, "Signed blocks are not active for this network.");
@@ -1092,16 +1103,19 @@ UniValue getcompactsketch(const JSONRPCRequest& request)
10921103
{
10931104
if (request.fHelp || request.params.size() != 1)
10941105
throw std::runtime_error(
1095-
"getcompactsketch block_hex\n"
1096-
"\nGets hex representation of a proposed compact block sketch.\n"
1097-
"It is consumed by `consumecompactsketch.`\n"
1098-
"Arguments:\n"
1099-
"1. \"block_hex\" (string, required), Hex serialized block proposal from `getnewblockhex`.\n"
1100-
"\nResult\n"
1106+
RPCHelpMan{"getcompactsketch block_hex",
1107+
"\nGets hex representation of a proposed compact block sketch.\n"
1108+
"It is consumed by `consumecompactsketch.`\n",
1109+
{
1110+
{"block_hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialized block proposal from `getnewblockhex`."},
1111+
},
1112+
RPCResult{
11011113
"sketch (string) The block serialized block sketch in hex\n"
1102-
"\nExamples:\n"
1103-
+ HelpExampleCli("getcompactsketch", "")
1104-
);
1114+
},
1115+
RPCExamples{
1116+
HelpExampleCli("getcompactsketch", ""),
1117+
}
1118+
}.ToString());
11051119

11061120
CBlock block;
11071121
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
@@ -1120,23 +1134,26 @@ UniValue consumecompactsketch(const JSONRPCRequest& request)
11201134
{
11211135
if (request.fHelp || request.params.size() != 1)
11221136
throw std::runtime_error(
1123-
"consumecompactsketch sketch\n"
1124-
"\nTakes hex representation of a proposed compact block sketch and fills it in\n"
1125-
"using mempool. Returns the block if complete, and a list\n"
1126-
"of missing transaction indices serialized as a native structure."
1127-
"NOTE: The latest instance of this call will have a partially filled block\n"
1128-
"cached in memory to be used in `consumegetblocktxn` to finalize the block.\n"
1129-
"Arguments:\n"
1130-
"1. \"sketch\" (string, required), Hex string of compact block sketch.\n"
1131-
"\nResult\n"
1137+
RPCHelpMan{"consumecompactsketch sketch",
1138+
"\nTakes hex representation of a proposed compact block sketch and fills it in\n"
1139+
"using mempool. Returns the block if complete, and a list\n"
1140+
"of missing transaction indices serialized as a native structure."
1141+
"NOTE: The latest instance of this call will have a partially filled block\n"
1142+
"cached in memory to be used in `consumegetblocktxn` to finalize the block.\n",
1143+
{
1144+
{"sketch", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex string of compact block sketch."},
1145+
},
1146+
RPCResult{
11321147
"{\n"
11331148
" blockhex (hex) The filled block hex. Only returns when block is final\n"
11341149
" block_tx_req (hex) The serialized structure of missing transaction indices, given to serving node\n"
11351150
" found_transactions (hex) The serialized list of found transactions to be used in finalizecompactblock\n"
11361151
"}\n"
1137-
"\nExamples:\n"
1138-
+ HelpExampleCli("consumecompactsketch", "<sketch>")
1139-
);
1152+
},
1153+
RPCExamples{
1154+
HelpExampleCli("consumecompactsketch", "<sketch>"),
1155+
}
1156+
}.ToString());
11401157

11411158
UniValue ret(UniValue::VOBJ);
11421159

@@ -1193,17 +1210,19 @@ UniValue consumegetblocktxn(const JSONRPCRequest& request)
11931210
{
11941211
if (request.fHelp || request.params.size() != 2)
11951212
throw std::runtime_error(
1196-
"consumegetblocktxn full_block block_tx_req\n"
1197-
"Consumes a transaction request for a compact block sketch."
1198-
"Arguments:\n"
1199-
"1. \"full_block\" (string, required), Hex serialied block that corresponds to the block request `block_tx_req`.\n"
1200-
"2. \"block_tx_req\" (string, required), Hex serialied BlockTransactionsRequest, aka getblocktxn network message.\n"
1201-
"\nResult\n"
1213+
RPCHelpMan{"consumegetblocktxn",
1214+
"Consumes a transaction request for a compact block sketch.",
1215+
{
1216+
{"full_block", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialied block that corresponds to the block request `block_tx_req`."},
1217+
{"block_tx_req", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialied BlockTransactionsRequest, aka getblocktxn network message."},
1218+
},
1219+
RPCResult{
12021220
"block_transactions (hex) The serialized list of found transactions aka BlockTransactions\n"
1203-
"\nExamples:\n"
1204-
+ HelpExampleCli("consumegetblocktxn", "<block_tx_req>")
1205-
);
1206-
1221+
},
1222+
RPCExamples{
1223+
HelpExampleCli("consumegetblocktxn", "<block_tx_req>")
1224+
}
1225+
}.ToString());
12071226

12081227
CBlock block;
12091228
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
@@ -1235,17 +1254,20 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
12351254
{
12361255
if (request.fHelp || request.params.size() != 3)
12371256
throw std::runtime_error(
1238-
"finalizecompactblock compact_hex block_transactions found_transactions\n"
1239-
"Takes the two transaction lists, fills out the compact block and attempts to finalize it."
1240-
"Arguments:\n"
1241-
"1. \"compact_hex\" (string, required), Hex serialized compact block.\n"
1242-
"2. \"block_transactions\" (string, required), Hex serialized BlockTransactions, the response to getblocktxn.\n"
1243-
"3. \"found_transactions\" (string, required), Hex serialized list of transactions that were found in response to receiving a compact sketch in `consumecompactsketch`.\n"
1244-
"\nResult\n"
1257+
RPCHelpMan{"finalizecompactblock",
1258+
"Takes the two transaction lists, fills out the compact block and attempts to finalize it.",
1259+
{
1260+
{"compact_hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialized compact block."},
1261+
{"block_transactions", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialized BlockTransactions, the response to getblocktxn."},
1262+
{"found_transactions", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex serialized list of transactions that were found in response to receiving a compact sketch in `consumecompactsketch`."},
1263+
},
1264+
RPCResult{
12451265
"block (hex) The serialized final block.\n"
1246-
"\nExamples:\n"
1247-
+ HelpExampleCli("finalizecompactblock", "<compact_hex> <block_transactions> <found_transactions>")
1248-
);
1266+
},
1267+
RPCExamples{
1268+
HelpExampleCli("finalizecompactblock", "<compact_hex> <block_transactions> <found_transactions>")
1269+
}
1270+
}.ToString());
12491271

12501272
// Compact block
12511273
std::vector<unsigned char> compact_block_bytes(ParseHex(request.params[0].get_str()));
@@ -1289,15 +1311,17 @@ UniValue testproposedblock(const JSONRPCRequest& request)
12891311
{
12901312
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
12911313
throw std::runtime_error(
1292-
"testproposedblock \"blockhex\"\n"
1293-
"\nChecks a block proposal for validity, and that it extends chaintip\n"
1294-
"\nArguments:\n"
1295-
"1. \"blockhex\" (string, required) The hex-encoded block from getnewblockhex\n"
1296-
"2. \"acceptnonstd\" (bool, optional) If set false, returns error if block contains non-standard transaction. Default is set via `-acceptnonstdtxn`. If PAK enforcement is set, block commitment mismatches with configuration PAK lists are rejected as well.\n"
1297-
"\nResult\n"
1298-
"\nExamples:\n"
1299-
+ HelpExampleCli("testproposedblock", "<hex>")
1300-
);
1314+
RPCHelpMan{"testproposedblock",
1315+
"\nChecks a block proposal for validity, and that it extends chaintip\n",
1316+
{
1317+
{"blockhex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded block from getnewblockhex"},
1318+
{"acceptnonstd", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "If set false, returns error if block contains non-standard transaction. Default is set via `-acceptnonstdtxn`. If PAK enforcement is set, block commitment mismatches with configuration PAK lists are rejected as well."},
1319+
},
1320+
RPCResults{},
1321+
RPCExamples{
1322+
HelpExampleCli("testproposedblock", "<hex>")
1323+
}
1324+
}.ToString());
13011325

13021326
CBlock block;
13031327
if (!DecodeHexBlk(block, request.params[0].get_str()))
@@ -1357,6 +1381,9 @@ UniValue testproposedblock(const JSONRPCRequest& request)
13571381
return NullUniValue;
13581382
}
13591383

1384+
// END ELEMENTS
1385+
//
1386+
13601387
// clang-format off
13611388

13621389
static const CRPCCommand commands[] =

src/rpc/misc.cpp

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -633,17 +633,19 @@ UniValue tweakfedpegscript(const JSONRPCRequest& request)
633633
{
634634
if (request.fHelp || request.params.size() != 1)
635635
throw std::runtime_error(
636-
"tweakfedpegscript \"claim_script\"\n"
637-
"\nReturns a tweaked fedpegscript.\n"
638-
"\nArguments:\n"
639-
"1. \"claim_script\" (string, required) Script to tweak the fedpegscript with. For example obtained as a result of getpeginaddress.\n"
640-
"\nResult:\n"
636+
RPCHelpMan{"tweakfedpegscript",
637+
"\nReturns a tweaked fedpegscript.\n",
638+
{
639+
{"claim_script", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Script to tweak the fedpegscript with. For example obtained as a result of getpeginaddress."},
640+
},
641+
RPCResult{
641642
"{\n"
642643
"\"script\" (string) The fedpegscript tweaked with claim_script\n"
643644
"\"address\" (string) The address corresponding to the tweaked fedpegscript\n"
644645
"}\n"
645-
);
646-
646+
},
647+
RPCExamples{""},
648+
}.ToString());
647649

648650
if (!IsHex(request.params[0].get_str())) {
649651
throw JSONRPCError(RPC_TYPE_ERROR, "the first argument must be a hex string");
@@ -685,18 +687,20 @@ UniValue getpakinfo(const JSONRPCRequest& request)
685687
{
686688
if (request.fHelp || request.params.size() != 0)
687689
throw std::runtime_error(
688-
"getpakinfo\n"
689-
"\nReturns relevant pegout authorization key (PAK) information about this node, both from command line arguments and blockchain data.\n"
690-
"\nResult:\n"
690+
RPCHelpMan{"getpakinfo",
691+
"\nReturns relevant pegout authorization key (PAK) information about this node, both from command line arguments and blockchain data.\n",
692+
{},
693+
RPCResult{
691694
"{\n"
692695
"\"config_paklist\" (array) The PAK list loaded from beta.conf at startup\n"
693696
"\"block_paklist\" (array) The PAK list loaded from latest block commitment\n"
694697
"}\n"
695-
);
698+
},
699+
RPCExamples{""},
700+
}.ToString());
696701

697702
LOCK(cs_main);
698703

699-
700704
UniValue paklist_value(UniValue::VOBJ);
701705
if (g_paklist_config) {
702706
paklist_value = FormatPAKList(*g_paklist_config);
@@ -728,11 +732,16 @@ UniValue dumpassetlabels(const JSONRPCRequest& request)
728732
{
729733
if (request.fHelp || request.params.size() != 0)
730734
throw std::runtime_error(
731-
"dumpassetlabels\n"
732-
"\nLists all known asset id/label pairs in this wallet. This list can be modified with `-assetdir` configuration argument.\n"
733-
+ HelpExampleCli("dumpassetlabels", "" )
735+
RPCHelpMan{"dumpassetlabels",
736+
"\nLists all known asset id/label pairs in this wallet. This list can be modified with `-assetdir` configuration argument.\n",
737+
{},
738+
RPCResult{""},
739+
RPCExamples{
740+
HelpExampleCli("dumpassetlabels", "" )
734741
+ HelpExampleRpc("dumpassetlabels", "" )
735-
);
742+
},
743+
}.ToString());
744+
736745
UniValue obj(UniValue::VOBJ);
737746
for (const auto& as : gAssetsDir.GetKnownAssets()) {
738747
obj.pushKV(gAssetsDir.GetLabel(as), as.GetHex());
@@ -780,22 +789,23 @@ class BlindingPubkeyAdderVisitor : public boost::static_visitor<>
780789
UniValue createblindedaddress(const JSONRPCRequest& request)
781790
{
782791
if (request.fHelp || request.params.size() != 2)
783-
{
784792
throw std::runtime_error(
785-
"createblindedaddress address blinding_key\n"
786-
"\nCreates a blinded address using the provided blinding key.\n"
787-
"\nArguments:\n"
788-
"1. \"address\" (string, required) The unblinded address to be blinded.\n"
789-
"2. \"blinding_key\" (string, required) The blinding public key. This can be obtained for a given address using `validateaddress`.\n"
790-
"\nResult:\n"
793+
RPCHelpMan{"createblindedaddress",
794+
"\nCreates a blinded address using the provided blinding key.\n",
795+
{
796+
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The unblinded address to be blinded."},
797+
{"blinding_key", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The blinding public key. This can be obtained for a given address using `validateaddress`."},
798+
},
799+
RPCResult{
791800
"\"blinded_address\" (string) The blinded address.\n"
792-
"\nExamples:\n"
801+
},
802+
RPCExamples{
793803
"\nCreate a multisig address from 2 addresses\n"
794804
+ HelpExampleCli("createblindedaddress", "HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16 ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d") +
795805
"\nAs a json rpc call\n"
796806
+ HelpExampleRpc("createblindedaddress", "HEZk3iQi1jC49bxUriTtynnXgWWWdAYx16, ec09811118b6febfa5ebe68642e5091c418fbace07e655da26b4a845a691fc2d")
797-
);
798-
}
807+
},
808+
}.ToString());
799809

800810
CTxDestination address = DecodeDestination(request.params[0].get_str());
801811
if (!IsValidDestination(address)) {

0 commit comments

Comments
 (0)