mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improved error message on mistyped command [RIPD-1527]:
Previously if you mistyped the "submit_multisigned" command as "submit_multisign", the returned message was "Internal error". Not very helpful. It turns out this was caused by a small amount of code in RPCCall.cpp. Removing that code improves two situations: 1. It improves the situation with a mistyped command. Now the command returns "Unknown method" and provides the string of the mistyped command. 2. The "transaction_entry", if properly entered in its command line form, would fire an assert. That assert is now removed. In the process, it was discovered that the command line form of the "transaction_entry" command has not worked correctly for at least a year. Therefore support for that the command line form of "transaction_entry" is added along with appropriate unit tests.
This commit is contained in:
@@ -879,6 +879,31 @@ private:
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
// transaction_entry <tx_hash> <ledger_hash/ledger_index>
|
||||
Json::Value parseTransactionEntry (Json::Value const& jvParams)
|
||||
{
|
||||
// Parameter count should have already been verified.
|
||||
assert (jvParams.size() == 2);
|
||||
|
||||
std::string const txHash = jvParams[0u].asString();
|
||||
if (txHash.length() != 64)
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
Json::Value jvRequest;
|
||||
jvRequest[jss::tx_hash] = txHash;
|
||||
|
||||
jvParseLedger (jvRequest, jvParams[1u].asString());
|
||||
|
||||
// jvParseLedger inserts a "ledger_index" of 0 if it doesn't
|
||||
// find a match.
|
||||
if (jvRequest.isMember(jss::ledger_index) &&
|
||||
jvRequest[jss::ledger_index] == 0)
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
|
||||
// tx <transaction_id>
|
||||
Json::Value parseTx (Json::Value const& jvParams)
|
||||
{
|
||||
@@ -1073,7 +1098,7 @@ public:
|
||||
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
||||
{ "server_state", &RPCParser::parseAsIs, 0, 0 },
|
||||
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
||||
// { "transaction_entry", &RPCParser::parseTransactionEntry, -1, -1 },
|
||||
{ "transaction_entry", &RPCParser::parseTransactionEntry, 2, 2 },
|
||||
{ "tx", &RPCParser::parseTx, 1, 2 },
|
||||
{ "tx_account", &RPCParser::parseTxAccount, 1, 7 },
|
||||
{ "tx_history", &RPCParser::parseTxHistory, 1, 1 },
|
||||
@@ -1323,12 +1348,6 @@ rpcClient(std::vector<std::string> const& args,
|
||||
jvParams.append(jvRequest[i]);
|
||||
}
|
||||
|
||||
if (jvRequest.isMember(jss::params))
|
||||
{
|
||||
auto const& params = jvRequest[jss::params];
|
||||
assert(params.size() == 1);
|
||||
jvParams.append(params[0u]);
|
||||
}
|
||||
{
|
||||
boost::asio::io_service isService;
|
||||
RPCCall::fromNetwork (
|
||||
|
||||
Reference in New Issue
Block a user