Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIv2(ledger_entry) : check error #4630

Merged
merged 9 commits into from
Sep 8, 2023
16 changes: 7 additions & 9 deletions src/ripple/protocol/impl/Issue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <ripple/protocol/Issue.h>

#include <ripple/json/json_errors.h>
#include <ripple/protocol/AccountID.h>
#include <ripple/protocol/UintTypes.h>
#include <ripple/protocol/jss.h>
Expand Down Expand Up @@ -78,7 +79,7 @@ issueFromJson(Json::Value const& v)
{
if (!v.isObject())
{
Throw<std::runtime_error>(
Throw<Json::error>(
"issueFromJson can only be specified with a 'object' Json value");
}

Expand All @@ -87,37 +88,34 @@ issueFromJson(Json::Value const& v)

if (!curStr.isString())
{
Throw<std::runtime_error>(
Throw<Json::error>(
"issueFromJson currency must be a string Json value");
}

auto const currency = to_currency(curStr.asString());
if (currency == badCurrency() || currency == noCurrency())
{
Throw<std::runtime_error>(
"issueFromJson currency must be a valid currency");
Throw<Json::error>("issueFromJson currency must be a valid currency");
}

if (isXRP(currency))
{
if (!issStr.isNull())
{
Throw<std::runtime_error>("Issue, XRP should not have issuer");
Throw<Json::error>("Issue, XRP should not have issuer");
}
return xrpIssue();
}

if (!issStr.isString())
{
Throw<std::runtime_error>(
"issueFromJson issuer must be a string Json value");
Throw<Json::error>("issueFromJson issuer must be a string Json value");
}
auto const issuer = parseBase58<AccountID>(issStr.asString());

if (!issuer)
{
Throw<std::runtime_error>(
"issueFromJson issuer must be a valid account");
Throw<Json::error>("issueFromJson issuer must be a valid account");
}

return Issue{currency, *issuer};
Expand Down
Loading