Merge #18499: rpc: Make rpc documentation not depend on call-time rpc args (#4893)

This commit is contained in:
Munkybooty 2022-06-27 12:40:22 -04:00 committed by GitHub
parent d9c70e2916
commit 9c839dd836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 22 deletions

View File

@ -130,7 +130,7 @@ static void gobject_prepare_help(const JSONRPCRequest& request)
{
RPCHelpMan{"gobject prepare",
"Prepare governance object by signing and creating tx\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"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"},
@ -253,7 +253,7 @@ static void gobject_list_prepared_help(const JSONRPCRequest& request)
{
RPCHelpMan{"gobject list-prepared",
"Returns a list of governance objects prepared by this wallet with \"gobject prepare\" sorted by their creation time.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"count", RPCArg::Type::NUM, /* default */ "10", "Maximum number of objects to return."},
},
@ -591,7 +591,7 @@ static void gobject_vote_many_help(const JSONRPCRequest& request)
{
RPCHelpMan{"gobject vote-many",
"Vote on a governance object by all masternodes for which the voting key is present in the local wallet\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"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]"},
@ -645,7 +645,7 @@ static void gobject_vote_alias_help(const JSONRPCRequest& request)
{
RPCHelpMan{"gobject vote-alias",
"Vote on a governance object by masternode's voting key (if present in local wallet)\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"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]"},

View File

@ -323,7 +323,7 @@ static void protx_register_fund_help(const JSONRPCRequest& request)
"masternode.\n"
"A few of the limitations you see in the arguments are temporary and might be lifted after DIP3\n"
"is fully deployed.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
GetRpcArg("collateralAddress"),
GetRpcArg("ipAndPort"),
@ -353,7 +353,7 @@ static void protx_register_help(const JSONRPCRequest& request)
"\nSame as \"protx register_fund\", but with an externally referenced collateral.\n"
"The collateral is specified through \"collateralHash\" and \"collateralIndex\" and must be an unspent\n"
"transaction output spendable by this wallet. It must also not be used by any other masternode.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
GetRpcArg("collateralHash"),
GetRpcArg("collateralIndex"),
@ -414,7 +414,7 @@ static void protx_register_submit_help(const JSONRPCRequest& request)
"\nCombines the unsigned ProTx and a signature of the signMessage, signs all inputs\n"
"which were added to cover fees and submits the resulting transaction to the network.\n"
"Note: See \"help protx register_prepare\" for more info about creating a ProTx and a message to sign.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"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."},
@ -627,7 +627,7 @@ static void protx_update_service_help(const JSONRPCRequest& request)
"\nCreates and sends a ProUpServTx to the network. This will update the IP address\n"
"of a masternode.\n"
"If this is done for a masternode that got PoSe-banned, the ProUpServTx will also revive this masternode.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
GetRpcArg("proTxHash"),
GetRpcArg("ipAndPort"),
@ -723,7 +723,7 @@ static void protx_update_registrar_help(const JSONRPCRequest& request)
"\nCreates and sends a ProUpRegTx to the network. This will update the operator key, voting key and payout\n"
"address of the masternode specified by \"proTxHash\".\n"
"The owner key of the masternode must be known to your wallet.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
GetRpcArg("proTxHash"),
GetRpcArg("operatorPubKey_update"),
@ -812,7 +812,7 @@ static void protx_revoke_help(const JSONRPCRequest& request)
"put it into the PoSe-banned state. It will also set the service field of the masternode\n"
"to zero. Use this in case your operator key got compromised or you want to stop providing your service\n"
"to the masternode owner.\n"
+ HelpRequiringPassphrase() + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
GetRpcArg("proTxHash"),
GetRpcArg("operatorKey"),

View File

@ -70,11 +70,6 @@ bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string&
return false;
}
std::string HelpRequiringPassphrase()
{
return "\nRequires wallet passphrase to be set with walletpassphrase call.";
}
std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
{
std::string wallet_name;
@ -336,7 +331,7 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
RPCHelpMan{"sendtoaddress",
"\nSend an amount to a given address." +
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to send to."},
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"},
@ -536,7 +531,7 @@ static UniValue signmessage(const JSONRPCRequest& request)
{
RPCHelpMan{"signmessage",
"\nSign a message with the private key of an address" +
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The dash address to use for the private key."},
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
@ -816,7 +811,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
{
RPCHelpMan{"sendmany",
"\nSend multiple times. Amounts are double-precision floating point numbers." +
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"dummy", RPCArg::Type::STR, RPCArg::Optional::NO, "Must be set to \"\" for backwards compatibility.", "\"\""},
{"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "A json object with addresses and amounts",
@ -1814,7 +1809,7 @@ static UniValue keypoolrefill(const JSONRPCRequest& request)
{
RPCHelpMan{"keypoolrefill",
"\nFills the keypool."+
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"newsize", RPCArg::Type::NUM, /* default */ itostr(DEFAULT_KEYPOOL_SIZE), "The new keypool size"},
},
@ -3263,7 +3258,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second 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." +
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"hexstring", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction hex string"},
{"prevtxs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "A json array of previous dependent transaction outputs",
@ -3735,7 +3730,7 @@ UniValue walletprocesspsbt(const JSONRPCRequest& request)
RPCHelpMan{"walletprocesspsbt",
"\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
"that we can sign for." +
HelpRequiringPassphrase() + "\n",
HELP_REQUIRING_PASSPHRASE,
{
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
{"sign", RPCArg::Type::BOOL, /* default */ "true", "Also sign the transaction when updating"},

View File

@ -19,6 +19,8 @@ class CTransaction;
struct PartiallySignedTransaction;
struct WalletContext;
static const std::string HELP_REQUIRING_PASSPHRASE{"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
namespace util {
class Ref;
} // namespace util
@ -33,7 +35,6 @@ Span<const CRPCCommand> GetWalletRPCCommands();
*/
std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request);
std::string HelpRequiringPassphrase();
void EnsureWalletIsUnlocked(CWallet *);
WalletContext& EnsureWalletContext(const util::Ref& context);