Skip to content

Commit

Permalink
Merge branch 'mpt-direct-pay' into mpt-dex-integration-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Mar 7, 2024
2 parents 14cd015 + b00eab6 commit 39cb392
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/ripple/protocol/Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ validAsset(Asset const& asset);
bool
equalAssets(Asset const& asset1, Asset const& asset2);

bool
validJSONAsset(Json::Value const& jv);

} // namespace ripple

#endif // RIPPLE_PROTOCOL_ASSET_H_INCLUDED
8 changes: 8 additions & 0 deletions src/ripple/protocol/impl/Asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,12 @@ equalAssets(Asset const& asset1, Asset const& asset2)
return asset1.mptIssue().mpt() == asset2.mptIssue().mpt();
}

bool
validJSONAsset(Json::Value const& jv)
{
return (jv.isMember(jss::currency) && !jv.isMember(jss::mpt_issuance_id)) ||
(!jv.isMember(jss::currency) && !jv.isMember(jss::issuer) &&
jv.isMember(jss::mpt_issuance_id));
}

} // namespace ripple
5 changes: 2 additions & 3 deletions src/ripple/protocol/impl/STAmount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,8 @@ amountFromJson(SField const& name, Json::Value const& v)
}
else if (v.isObject())
{
if ((!v.isMember(jss::currency) && !v.isMember(jss::mpt_issuance_id)) ||
(v.isMember(jss::currency) && v.isMember(jss::mpt_issuance_id)))
Throw<std::runtime_error>("invalid asset");
if (!validJSONAsset(v))
Throw<std::runtime_error>("Invalid Asset's Json specification");

value = v[jss::value];
if (v.isMember(jss::mpt_issuance_id))
Expand Down

0 comments on commit 39cb392

Please sign in to comment.