[RPC] Give RPC commands more information about the RPC request

This commit is contained in:
Jonas Schnelli
2016-09-22 09:46:41 +02:00
parent 23c32a9694
commit 69d1c25768
13 changed files with 558 additions and 547 deletions

View File

@@ -39,9 +39,9 @@ using namespace std;
*
* Or alternatively, create a specific query method for the information.
**/
UniValue getinfo(const UniValue& params, bool fHelp)
UniValue getinfo(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 0)
if (request.fHelp || request.params.size() != 0)
throw runtime_error(
"getinfo\n"
"\nDEPRECATED. Returns an object containing various state info.\n"
@@ -148,9 +148,9 @@ public:
};
#endif
UniValue validateaddress(const UniValue& params, bool fHelp)
UniValue validateaddress(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 1)
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
"validateaddress \"bitcoinaddress\"\n"
"\nReturn information about the given bitcoin address.\n"
@@ -181,7 +181,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
LOCK(cs_main);
#endif
CBitcoinAddress address(params[0].get_str());
CBitcoinAddress address(request.params[0].get_str());
bool isValid = address.IsValid();
UniValue ret(UniValue::VOBJ);
@@ -278,9 +278,9 @@ CScript _createmultisig_redeemScript(const UniValue& params)
return result;
}
UniValue createmultisig(const UniValue& params, bool fHelp)
UniValue createmultisig(const JSONRPCRequest& request)
{
if (fHelp || params.size() < 2 || params.size() > 2)
if (request.fHelp || request.params.size() < 2 || request.params.size() > 2)
{
string msg = "createmultisig nrequired [\"key\",...]\n"
"\nCreates a multi-signature address with n signature of m keys required.\n"
@@ -310,7 +310,7 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
}
// Construct using pay-to-script-hash:
CScript inner = _createmultisig_redeemScript(params);
CScript inner = _createmultisig_redeemScript(request.params);
CScriptID innerID(inner);
CBitcoinAddress address(innerID);
@@ -321,9 +321,9 @@ UniValue createmultisig(const UniValue& params, bool fHelp)
return result;
}
UniValue verifymessage(const UniValue& params, bool fHelp)
UniValue verifymessage(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 3)
if (request.fHelp || request.params.size() != 3)
throw runtime_error(
"verifymessage \"bitcoinaddress\" \"signature\" \"message\"\n"
"\nVerify a signed message\n"
@@ -346,9 +346,9 @@ UniValue verifymessage(const UniValue& params, bool fHelp)
LOCK(cs_main);
string strAddress = params[0].get_str();
string strSign = params[1].get_str();
string strMessage = params[2].get_str();
string strAddress = request.params[0].get_str();
string strSign = request.params[1].get_str();
string strMessage = request.params[2].get_str();
CBitcoinAddress addr(strAddress);
if (!addr.IsValid())
@@ -375,9 +375,9 @@ UniValue verifymessage(const UniValue& params, bool fHelp)
return (pubkey.GetID() == keyID);
}
UniValue signmessagewithprivkey(const UniValue& params, bool fHelp)
UniValue signmessagewithprivkey(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 2)
if (request.fHelp || request.params.size() != 2)
throw runtime_error(
"signmessagewithprivkey \"privkey\" \"message\"\n"
"\nSign a message with the private key of an address\n"
@@ -395,8 +395,8 @@ UniValue signmessagewithprivkey(const UniValue& params, bool fHelp)
+ HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"")
);
string strPrivkey = params[0].get_str();
string strMessage = params[1].get_str();
string strPrivkey = request.params[0].get_str();
string strMessage = request.params[1].get_str();
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strPrivkey);
@@ -417,9 +417,9 @@ UniValue signmessagewithprivkey(const UniValue& params, bool fHelp)
return EncodeBase64(&vchSig[0], vchSig.size());
}
UniValue setmocktime(const UniValue& params, bool fHelp)
UniValue setmocktime(const JSONRPCRequest& request)
{
if (fHelp || params.size() != 1)
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
"setmocktime timestamp\n"
"\nSet the local time to given timestamp (-regtest only)\n"
@@ -437,8 +437,8 @@ UniValue setmocktime(const UniValue& params, bool fHelp)
// in a long time.
LOCK(cs_main);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
SetMockTime(params[0].get_int64());
RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));
SetMockTime(request.params[0].get_int64());
uint64_t t = GetTime();
if(g_connman) {