20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/misc/NetworkOPs.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/ledger/ReadView.h>
24 #include <ripple/net/RPCErr.h>
25 #include <ripple/protocol/ErrorCodes.h>
26 #include <ripple/protocol/UintTypes.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/resource/Fees.h>
29 #include <ripple/rpc/Context.h>
30 #include <ripple/rpc/impl/RPCHelpers.h>
64 if (!taker_pays.
isMember(jss::currency))
67 if (!taker_pays[jss::currency].isString())
70 if (!taker_gets.
isMember(jss::currency))
73 if (!taker_gets[jss::currency].isString())
78 if (!
to_currency(pay_currency, taker_pays[jss::currency].asString()))
80 JLOG(context.
j.
info()) <<
"Bad taker_pays currency.";
83 "Invalid field 'taker_pays.currency', bad currency.");
88 if (!
to_currency(get_currency, taker_gets[jss::currency].asString()))
90 JLOG(context.
j.
info()) <<
"Bad taker_gets currency.";
93 "Invalid field 'taker_gets.currency', bad currency.");
98 if (taker_pays.
isMember(jss::issuer))
100 if (!taker_pays[jss::issuer].isString())
103 if (!
to_issuer(pay_issuer, taker_pays[jss::issuer].asString()))
106 "Invalid field 'taker_pays.issuer', bad issuer.");
111 "Invalid field 'taker_pays.issuer', bad issuer account one.");
118 if (
isXRP(pay_currency) && !
isXRP(pay_issuer))
121 "Unneeded field 'taker_pays.issuer' for "
122 "XRP currency specification.");
124 if (!
isXRP(pay_currency) &&
isXRP(pay_issuer))
127 "Invalid field 'taker_pays.issuer', expected non-XRP issuer.");
131 if (taker_gets.
isMember(jss::issuer))
133 if (!taker_gets[jss::issuer].isString())
136 if (!
to_issuer(get_issuer, taker_gets[jss::issuer].asString()))
139 "Invalid field 'taker_gets.issuer', bad issuer.");
144 "Invalid field 'taker_gets.issuer', bad issuer account one.");
151 if (
isXRP(get_currency) && !
isXRP(get_issuer))
154 "Unneeded field 'taker_gets.issuer' for "
155 "XRP currency specification.");
157 if (!
isXRP(get_currency) &&
isXRP(get_issuer))
160 "Invalid field 'taker_gets.issuer', expected non-XRP issuer.");
162 boost::optional<AccountID> takerID;
168 takerID = parseBase58<AccountID>(context.
params[jss::taker].
asString());
173 if (pay_currency == get_currency && pay_issuer == get_issuer)
175 JLOG(context.
j.
info()) <<
"taker_gets same as taker_pays.";
191 {{pay_currency, pay_issuer}, {get_currency, get_issuer}},
192 takerID ? *takerID : beast::zero,
bool to_currency(Currency ¤cy, std::string const &code)
Tries to convert a string to a Currency, returns true on success.
const Charge feeMediumBurdenRPC
Resource::Charge & loadType
static constexpr LimitRange bookOffers
Limits for the book_offers command.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Json::Value object_field_error(std::string const &name)
Json::Value expected_field_error(std::string const &name, std::string const &type)
Json::Value missing_field_error(std::string const &name)
virtual void getBookPage(std::shared_ptr< ReadView const > &lpLedger, Book const &book, AccountID const &uTakerID, bool const bProof, unsigned int iLimit, Json::Value const &jvMarker, Json::Value &jvResult)=0
virtual JobQueue & getJobQueue()=0
AccountID const & xrpAccount()
Compute AccountID from public key.
bool isXRP(AccountID const &c)
bool isMember(const char *key) const
Return true if the object has a member named key.
Json::Value doBookOffers(RPC::JsonContext &context)
Json::Value rpcError(int iError, Json::Value jvResult)
int getJobCountGE(JobType t) const
All waiting jobs at or greater than this priority.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value invalid_field_error(std::string const &name)
bool isObjectOrNull() const
AccountID const & noAccount()
A placeholder for empty accounts.
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
bool to_issuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
std::string asString() const
Returns the unquoted string value.