diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -37,7 +37,6 @@ #include - static const std::string WALLET_ENDPOINT_BASE = "/wallet/"; static inline bool GetAvoidReuseFlag(CWallet *const pwallet, @@ -179,27 +178,28 @@ return NullUniValue; } - if (request.fHelp || request.params.size() > 2) { - throw std::runtime_error(RPCHelpMan{ - "getnewaddress", - "\nReturns a new Bitcoin address for receiving payments.\n" - "If 'label' is specified, it is added to the address book \n" - "so payments received with the address will be associated with " - "'label'.\n", - { - {"label", RPCArg::Type::STR, /* default */ "null", - "The label name for the address to be linked to. If not " - "provided, the default label \"\" is used. It can also be set " - "to the empty string \"\" to represent the default label. The " - "label does not need to exist, it will be created if there is " - "no label by the given name."}, - }, - RPCResult{"\"address\" (string) The new bitcoin address\n"}, - RPCExamples{HelpExampleCli("getnewaddress", "") + - HelpExampleRpc("getnewaddress", "")}, - } - .ToString()); + RPCHelpMan{ + "getnewaddress", + "\nReturns a new Bitcoin address for receiving payments.\n" + "If 'label' is specified, it is added to the address book \n" + "so payments received with the address will be associated with " + "'label'.\n", + { + {"label", RPCArg::Type::STR, /* default */ "null", + "The label name for the address to be linked to. If not provided, " + "the default label \"\" is used. It can also be set to the empty " + "string \"\" to represent the default label. The label does not " + "need to exist, it will be created if there is no label by the " + "given name."}, + {"address_type", RPCArg::Type::STR, + /* default */ "set by -addresstype", + "The address type to use. Options are \"legacy\"."}, + }, + RPCResult{"\"address\" (string) The new bitcoin address\n"}, + RPCExamples{HelpExampleCli("getnewaddress", "") + + HelpExampleRpc("getnewaddress", "")}, } + .Check(request); LOCK(pwallet->cs_wallet); @@ -251,18 +251,16 @@ return NullUniValue; } - if (request.fHelp || request.params.size() > 1) { - throw std::runtime_error(RPCHelpMan{ - "getrawchangeaddress", - "\nReturns a new Bitcoin address, for receiving change.\n" - "This is for use with raw transactions, NOT normal use.\n", - {}, - RPCResult{"\"address\" (string) The address\n"}, - RPCExamples{HelpExampleCli("getrawchangeaddress", "") + - HelpExampleRpc("getrawchangeaddress", "")}, - } - .ToString()); + RPCHelpMan{ + "getrawchangeaddress", + "\nReturns a new Bitcoin address, for receiving change.\n" + "This is for use with raw transactions, NOT normal use.\n", + {}, + RPCResult{"\"address\" (string) The address\n"}, + RPCExamples{HelpExampleCli("getrawchangeaddress", "") + + HelpExampleRpc("getrawchangeaddress", "")}, } + .Check(request); LOCK(pwallet->cs_wallet); @@ -311,27 +309,25 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 2) { - throw std::runtime_error(RPCHelpMan{ - "setlabel", - "\nSets the label associated with the given address.\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The bitcoin address to be associated with a label."}, - {"label", RPCArg::Type::STR, RPCArg::Optional::NO, - "The label to assign to the address."}, - }, - RPCResults{}, - RPCExamples{ - HelpExampleCli( - "setlabel", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + - HelpExampleRpc( - "setlabel", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")}, - } - .ToString()); + RPCHelpMan{ + "setlabel", + "\nSets the label associated with the given address.\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The bitcoin address to be associated with a label."}, + {"label", RPCArg::Type::STR, RPCArg::Optional::NO, + "The label to assign to the address."}, + }, + RPCResults{}, + RPCExamples{ + HelpExampleCli("setlabel", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") + + HelpExampleRpc( + "setlabel", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")}, } + .Check(request); + LOCK(pwallet->cs_wallet); CTxDestination dest = @@ -422,59 +418,52 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 2 || - request.params.size() > 6) { - throw std::runtime_error(RPCHelpMan{ - "sendtoaddress", - "\nSend an amount to a given address.\n" + - HelpRequiringPassphrase(pwallet) + "\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The bitcoin address to send to."}, - {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, - "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"}, - {"comment", RPCArg::Type::STR, - RPCArg::Optional::OMITTED_NAMED_ARG, - "A comment used to store what the transaction is for.\n" - " This is not part of the " - "transaction, just kept in your wallet."}, - {"comment_to", RPCArg::Type::STR, - RPCArg::Optional::OMITTED_NAMED_ARG, - "A comment to store the name of the person or organization\n" - " to which you're sending the " - "transaction. This is not part of the \n" - " transaction, just kept in " - "your wallet."}, - {"subtractfeefromamount", RPCArg::Type::BOOL, - /* default */ "false", - "The fee will be deducted from the amount being sent.\n" - " The recipient will receive " - "less bitcoins than you enter in the amount field."}, - {"avoid_reuse", RPCArg::Type::BOOL, - /* default */ "true", - "(only available if avoid_reuse wallet flag is set) Avoid " - "spending from dirty addresses; addresses are considered\n" - " dirty if they have previously " - "been used in a transaction."}, - }, - RPCResult{ - "\"txid\" (string) The transaction id.\n"}, - RPCExamples{ - HelpExampleCli("sendtoaddress", - "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + - HelpExampleCli("sendtoaddress", - "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" - "dd\" 0.1 \"donation\" \"seans " - "outpost\"") + - HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44" - "Jvaydd\" 0.1 \"\" \"\" true") + - HelpExampleRpc("sendtoaddress", - "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" - "dd\", 0.1, \"donation\", \"seans " - "outpost\"")}, - } - .ToString()); - } + RPCHelpMan{ + "sendtoaddress", + "\nSend an amount to a given address.\n" + + HelpRequiringPassphrase(pwallet) + "\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The bitcoin address to send to."}, + {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, + "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"}, + {"comment", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, + "A comment used to store what the transaction is for.\n" + " This is not part of the " + "transaction, just kept in your wallet."}, + {"comment_to", RPCArg::Type::STR, + RPCArg::Optional::OMITTED_NAMED_ARG, + "A comment to store the name of the person or organization\n" + " to which you're sending the " + "transaction. This is not part of the \n" + " transaction, just kept in " + "your wallet."}, + {"subtractfeefromamount", RPCArg::Type::BOOL, + /* default */ "false", + "The fee will be deducted from the amount being sent.\n" + " The recipient will receive " + "less bitcoins than you enter in the amount field."}, + {"avoid_reuse", RPCArg::Type::BOOL, + /* default */ "true", + "(only available if avoid_reuse wallet flag is set) Avoid " + "spending from dirty addresses; addresses are considered\n" + " dirty if they have previously " + "been used in a transaction."}, + }, + RPCResult{"\"txid\" (string) The transaction id.\n"}, + RPCExamples{ + HelpExampleCli("sendtoaddress", + "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" + "dd\" 0.1 \"donation\" \"seans " + "outpost\"") + + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44" + "Jvaydd\" 0.1 \"\" \"\" true") + + HelpExampleRpc("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay" + "dd\", 0.1, \"donation\", \"seans " + "outpost\"")}, + } + .Check(request); // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now @@ -532,34 +521,29 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 0) { - throw std::runtime_error(RPCHelpMan{ - "listaddressgroupings", - "\nLists groups of addresses which have had their " - "common ownership\n" - "made public by common use as inputs or as the " - "resulting change\n" - "in past transactions\n", - {}, - RPCResult{ - "[\n" - " [\n" - " [\n" - " \"address\", (string) The bitcoin address\n" - " amount, (numeric) The amount in " + - CURRENCY_UNIT + - "\n" - " \"label\" (string, optional) The label\n" - " ]\n" - " ,...\n" - " ]\n" - " ,...\n" - "]\n"}, - RPCExamples{HelpExampleCli("listaddressgroupings", "") + - HelpExampleRpc("listaddressgroupings", "")}, - } - .ToString()); - } + RPCHelpMan{ + "listaddressgroupings", + "\nLists groups of addresses which have had their common ownership\n" + "made public by common use as inputs or as the resulting change\n" + "in past transactions\n", + {}, + RPCResult{"[\n" + " [\n" + " [\n" + " \"address\", (string) The bitcoin address\n" + " amount, (numeric) The amount in " + + CURRENCY_UNIT + + "\n" + " \"label\" (string, optional) The label\n" + " ]\n" + " ,...\n" + " ]\n" + " ,...\n" + "]\n"}, + RPCExamples{HelpExampleCli("listaddressgroupings", "") + + HelpExampleRpc("listaddressgroupings", "")}, + } + .Check(request); // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now @@ -601,39 +585,35 @@ return NullUniValue; } - if (request.fHelp || request.params.size() != 2) { - throw std::runtime_error(RPCHelpMan{ - "signmessage", - "\nSign a message with the private key of an address" + - HelpRequiringPassphrase(pwallet) + "\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The bitcoin address to use for the private key."}, - {"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"}, - RPCExamples{ - "\nUnlock the wallet for 30 seconds\n" + - HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + - "\nCreate the signature\n" + - HelpExampleCli( - "signmessage", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + - "\nVerify the signature\n" + - HelpExampleCli("verifymessage", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4" - "XX\" \"signature\" \"my " - "message\"") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc( - "signmessage", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")}, - } - .ToString()); + RPCHelpMan{ + "signmessage", + "\nSign a message with the private key of an address" + + HelpRequiringPassphrase(pwallet) + "\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The bitcoin address to use for the private key."}, + {"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"}, + RPCExamples{ + "\nUnlock the wallet for 30 seconds\n" + + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + + "\nCreate the signature\n" + + HelpExampleCli( + "signmessage", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + + "\nVerify the signature\n" + + HelpExampleCli("verifymessage", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" " + "\"signature\" \"my message\"") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc( + "signmessage", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")}, } + .Check(request); auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); @@ -681,39 +661,34 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || - request.params.size() > 2) { - throw std::runtime_error(RPCHelpMan{ - "getreceivedbyaddress", - "\nReturns the total amount received by the given address in " - "transactions with at least minconf confirmations.\n", - { - {"address", RPCArg::Type::STR, RPCArg::Optional::NO, - "The bitcoin address for transactions."}, - {"minconf", RPCArg::Type::NUM, /* default */ "1", - "Only include transactions confirmed at least this many " - "times."}, - }, - RPCResult{"amount (numeric) The total amount in " + - CURRENCY_UNIT + " received at this address.\n"}, - RPCExamples{ - "\nThe amount from transactions with at least 1 " - "confirmation\n" + - HelpExampleCli("getreceivedbyaddress", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + - "\nThe amount including unconfirmed transactions, zero " - "confirmations\n" + - HelpExampleCli("getreceivedbyaddress", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") + - "\nThe amount with at least 6 confirmations\n" + - HelpExampleCli("getreceivedbyaddress", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") + - "\nAs a JSON-RPC call\n" + - HelpExampleRpc("getreceivedbyaddress", - "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")}, - } - .ToString()); + RPCHelpMan{ + "getreceivedbyaddress", + "\nReturns the total amount received by the given address in " + "transactions with at least minconf confirmations.\n", + { + {"address", RPCArg::Type::STR, RPCArg::Optional::NO, + "The bitcoin address for transactions."}, + {"minconf", RPCArg::Type::NUM, /* default */ "1", + "Only include transactions confirmed at least this many times."}, + }, + RPCResult{"amount (numeric) The total amount in " + CURRENCY_UNIT + + " received at this address.\n"}, + RPCExamples{ + "\nThe amount from transactions with at least 1 confirmation\n" + + HelpExampleCli("getreceivedbyaddress", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") + + "\nThe amount including unconfirmed transactions, zero " + "confirmations\n" + + HelpExampleCli("getreceivedbyaddress", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") + + "\nThe amount with at least 6 confirmations\n" + + HelpExampleCli("getreceivedbyaddress", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") + + "\nAs a JSON-RPC call\n" + + HelpExampleRpc("getreceivedbyaddress", + "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")}, } + .Check(request); // Make sure the results are valid at least up to the most recent block // the user could have gotten from another RPC command prior to now @@ -773,36 +748,30 @@ return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || - request.params.size() > 2) { - throw std::runtime_error(RPCHelpMan{ - "getreceivedbylabel", - "\nReturns the total amount received by addresses with