mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
rpc: Add MaybeArg() and Arg() default helper
This commit is contained in:
@@ -110,7 +110,7 @@ static RPCHelpMan getnetworkhashps()
|
||||
{
|
||||
ChainstateManager& chainman = EnsureAnyChainman(request.context);
|
||||
LOCK(cs_main);
|
||||
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].getInt<int>() : 120, !request.params[1].isNull() ? request.params[1].getInt<int>() : -1, chainman.ActiveChain());
|
||||
return GetNetworkHashPS(self.Arg<int>(0), self.Arg<int>(1), chainman.ActiveChain());
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -217,12 +217,12 @@ static RPCHelpMan generatetodescriptor()
|
||||
"\nGenerate 11 blocks to mydesc\n" + HelpExampleCli("generatetodescriptor", "11 \"mydesc\"")},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
const int num_blocks{request.params[0].getInt<int>()};
|
||||
const uint64_t max_tries{request.params[2].isNull() ? DEFAULT_MAX_TRIES : request.params[2].getInt<int>()};
|
||||
const auto num_blocks{self.Arg<int>(0)};
|
||||
const auto max_tries{self.Arg<uint64_t>(2)};
|
||||
|
||||
CScript coinbase_script;
|
||||
std::string error;
|
||||
if (!getScriptFromDescriptor(request.params[1].get_str(), coinbase_script, error)) {
|
||||
if (!getScriptFromDescriptor(self.Arg<std::string>(1), coinbase_script, error)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error);
|
||||
}
|
||||
|
||||
@@ -468,9 +468,10 @@ static RPCHelpMan prioritisetransaction()
|
||||
LOCK(cs_main);
|
||||
|
||||
uint256 hash(ParseHashV(request.params[0], "txid"));
|
||||
const auto dummy{self.MaybeArg<double>(1)};
|
||||
CAmount nAmount = request.params[2].getInt<int64_t>();
|
||||
|
||||
if (!(request.params[1].isNull() || request.params[1].get_real() == 0)) {
|
||||
if (dummy && *dummy != 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Priority is no longer supported, dummy argument to prioritisetransaction must be 0.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user