1#include <xrpld/app/main/Application.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/detail/RPCHelpers.h>
4#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
5#include <xrpld/rpc/detail/Tuning.h>
7#include <xrpl/basics/Log.h>
8#include <xrpl/basics/base_uint.h>
9#include <xrpl/beast/utility/Journal.h>
10#include <xrpl/beast/utility/Zero.h>
11#include <xrpl/core/Job.h>
12#include <xrpl/json/json_value.h>
13#include <xrpl/ledger/ReadView.h>
14#include <xrpl/protocol/AccountID.h>
15#include <xrpl/protocol/Asset.h>
16#include <xrpl/protocol/Book.h>
17#include <xrpl/protocol/ErrorCodes.h>
18#include <xrpl/protocol/Issue.h>
19#include <xrpl/protocol/RPCErr.h>
20#include <xrpl/protocol/UintTypes.h>
21#include <xrpl/protocol/jss.h>
22#include <xrpl/resource/Fees.h>
23#include <xrpl/server/NetworkOPs.h>
30std::optional<json::Value>
38 if (taker.
isMember(jss::mpt_issuance_id) &&
45 (taker.
isMember(jss::mpt_issuance_id) && !taker[jss::mpt_issuance_id].
isString()))
48 (boost::format(
"%s.currency") % name.
cStr()).str(),
"string");
61 auto const assetError = [&]() {
62 if (name == jss::taker_pays)
73 JLOG(j.
info()) << boost::format(
"Bad %s currency.") % name.
cStr();
76 (boost::format(
"Invalid field '%s.currency', bad currency.") % name.
cStr()).str());
80 else if (taker.
isMember(jss::mpt_issuance_id))
87 (boost::format(
"Invalid field '%s.mpt_issuance_id'") % name.
cStr()).str());
102 auto const issuerError = [&]() {
103 if (name == jss::taker_pays)
114 if (!taker[jss::issuer].isString())
117 (boost::format(
"%s.issuer") % name.
cStr()).str(),
"string");
124 (boost::format(
"Invalid field '%s.issuer', bad issuer.") % name.
cStr()).str());
131 (boost::format(
"Invalid field '%s.issuer', bad issuer account one.") %
146 "Unneeded field '%s.issuer' for XRP currency "
156 (boost::format(
"Invalid field '%s.issuer', expected non-XRP issuer.") % name.
cStr())
238 if (book.in == book.out)
240 JLOG(context.
j.
info()) <<
"taker_gets same as taker_pays.";
244 unsigned int limit = 0;
256 {book.in, book.out, domain},
257 takerID ? *takerID : beast::kZero,
A generic endpoint for log messages.
Lightweight wrapper to tag static string.
constexpr char const * cStr() const
std::string asString() const
Returns the unquoted string value.
bool isObjectOrNull() const
bool isMember(char const *key) const
Return true if the object has a member named key.
constexpr TIss const & get() const
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
A currency issued by an account.
int getJobCountGE(JobType t) const
All waiting jobs at or greater than this priority.
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
static constexpr LimitRange kBookOffers
Limits for the book_offers command.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, json::Value &result)
Looks up a ledger from a request and fills a json::Value with ledger data.
json::Value objectFieldError(std::string const &name)
json::Value makeError(ErrorCodeI code)
Returns a new json object that reflects the error code.
json::Value invalidFieldError(std::string const &name)
json::Value missingFieldError(std::string const &name)
json::Value expectedFieldError(std::string const &name, std::string const &type)
Charge const kFeeMediumBurdenRpc
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< json::Value > parseTakerIssuerJSON(Asset &asset, json::Value const &taker, json::StaticString const &name, beast::Journal j)
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
std::optional< json::Value > parseTakerAssetJSON(Asset &asset, json::Value const &taker, json::StaticString const &name, beast::Journal j)
bool isXRP(AccountID const &c)
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
bool toCurrency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.
json::Value rpcError(ErrorCodeI iError)
BaseUInt< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
std::optional< json::Value > validateTakerJSON(json::Value const &taker, json::StaticString const &name)
AccountID const & noAccount()
A placeholder for empty accounts.
AccountID const & xrpAccount()
Compute AccountID from public key.
json::Value doBookOffers(RPC::JsonContext &)
bool toIssuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
Resource::Charge & loadType