1#include <xrpld/app/main/Application.h>
2#include <xrpld/app/misc/NetworkOPs.h>
3#include <xrpld/rpc/BookChanges.h>
4#include <xrpld/rpc/Context.h>
5#include <xrpld/rpc/detail/RPCHelpers.h>
6#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
8#include <xrpl/basics/Log.h>
9#include <xrpl/ledger/ReadView.h>
10#include <xrpl/protocol/ErrorCodes.h>
11#include <xrpl/protocol/RPCErr.h>
12#include <xrpl/protocol/UintTypes.h>
13#include <xrpl/protocol/jss.h>
14#include <xrpl/resource/Fees.h>
48 if (!taker_pays.
isMember(jss::currency))
51 if (!taker_pays[jss::currency].isString())
54 if (!taker_gets.
isMember(jss::currency))
57 if (!taker_gets[jss::currency].isString())
62 if (!
to_currency(pay_currency, taker_pays[jss::currency].asString()))
64 JLOG(context.
j.
info()) <<
"Bad taker_pays currency.";
67 "Invalid field 'taker_pays.currency', bad currency.");
72 if (!
to_currency(get_currency, taker_gets[jss::currency].asString()))
74 JLOG(context.
j.
info()) <<
"Bad taker_gets currency.";
77 "Invalid field 'taker_gets.currency', bad currency.");
82 if (taker_pays.
isMember(jss::issuer))
84 if (!taker_pays[jss::issuer].isString())
87 if (!
to_issuer(pay_issuer, taker_pays[jss::issuer].asString()))
90 "Invalid field 'taker_pays.issuer', bad issuer.");
95 "Invalid field 'taker_pays.issuer', bad issuer account one.");
102 if (
isXRP(pay_currency) && !
isXRP(pay_issuer))
105 "Unneeded field 'taker_pays.issuer' for "
106 "XRP currency specification.");
108 if (!
isXRP(pay_currency) &&
isXRP(pay_issuer))
111 "Invalid field 'taker_pays.issuer', expected non-XRP issuer.");
115 if (taker_gets.
isMember(jss::issuer))
117 if (!taker_gets[jss::issuer].isString())
120 if (!
to_issuer(get_issuer, taker_gets[jss::issuer].asString()))
123 "Invalid field 'taker_gets.issuer', bad issuer.");
128 "Invalid field 'taker_gets.issuer', bad issuer account one.");
135 if (
isXRP(get_currency) && !
isXRP(get_issuer))
138 "Unneeded field 'taker_gets.issuer' for "
139 "XRP currency specification.");
141 if (!
isXRP(get_currency) &&
isXRP(get_issuer))
144 "Invalid field 'taker_gets.issuer', expected non-XRP issuer.");
152 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}, domain},
192 takerID ? *takerID : beast::zero,
209 if (ledger ==
nullptr)
bool isObjectOrNull() const
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
virtual JobQueue & getJobQueue()=0
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
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
static LimitRange constexpr bookOffers
Limits for the book_offers command.
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
Json::Value computeBookChanges(std::shared_ptr< L const > const &lpAccepted)
Json::Value invalid_field_error(std::string const &name)
Json::Value object_field_error(std::string const &name)
Json::Value expected_field_error(std::string const &name, std::string const &type)
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 missing_field_error(std::string const &name)
Charge const feeMediumBurdenRPC
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AccountID const & noAccount()
A placeholder for empty accounts.
bool isXRP(AccountID const &c)
AccountID const & xrpAccount()
Compute AccountID from public key.
bool to_issuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
Json::Value doBookChanges(RPC::JsonContext &context)
Json::Value rpcError(int iError)
Json::Value doBookOffers(RPC::JsonContext &context)
bool to_currency(Currency &, std::string const &)
Tries to convert a string to a Currency, returns true on success.
Resource::Charge & loadType