20#include <xrpld/ledger/ReadView.h>
21#include <xrpld/ledger/View.h>
22#include <xrpld/rpc/Context.h>
23#include <xrpld/rpc/detail/RPCHelpers.h>
24#include <xrpld/rpc/detail/Tuning.h>
26#include <xrpl/json/json_value.h>
27#include <xrpl/protocol/ErrorCodes.h>
28#include <xrpl/protocol/RPCErr.h>
29#include <xrpl/protocol/jss.h>
30#include <xrpl/resource/Fees.h>
40 offer->getFieldAmount(sfTakerPays).setJson(obj[jss::taker_pays]);
41 offer->getFieldAmount(sfTakerGets).setJson(obj[jss::taker_gets]);
42 obj[jss::seq] =
offer->getFieldU32(sfSequence);
43 obj[jss::flags] =
offer->getFieldU32(sfFlags);
44 obj[jss::quality] = dirRate.
getText();
45 if (
offer->isFieldPresent(sfExpiration))
46 obj[jss::expiration] =
offer->getFieldU32(sfExpiration);
59 auto const& params(context.
params);
60 if (!params.isMember(jss::account))
63 if (!params[jss::account].isString())
71 auto id = parseBase58<AccountID>(params[jss::account].asString());
77 auto const accountID{std::move(
id.value())};
80 result[jss::account] =
toBase58(accountID);
94 uint256 startAfter = beast::zero;
97 if (params.isMember(jss::marker))
99 if (!params[jss::marker].isString())
117 startHint = boost::lexical_cast<std::uint64_t>(value);
119 catch (boost::bad_lexical_cast&)
126 auto const sle = ledger->read({
ltANY, startAfter});
144 [&
offers, &count, &marker, &limit, &nextHint, &accountID](
148 UNREACHABLE(
"ripple::doAccountOffers : null SLE");
152 if (++count == limit)
158 if (count <= limit && sle->getType() == ltOFFER)
172 if (count == limit + 1 && marker)
174 result[jss::limit] = limit;
175 result[jss::marker] =
std::string getText() const override
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
static LimitRange constexpr accountOffers
Limits for the account_offers command.
Json::Value invalid_field_error(std::string const &name)
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a SLE is owned by accountID.
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
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.
std::uint64_t getStartHint(std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
Json::Value missing_field_error(std::string const &name)
Charge const feeMediumBurdenRPC
Keylet account(AccountID const &id) noexcept
AccountID root.
owner_count< ltOFFER > offers
Match the number of offers in the account's owner directory.
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::uint64_t getQuality(uint256 const &uBase)
STAmount amountFromQuality(std::uint64_t rate)
Json::Value rpcError(int iError)
Json::Value doAccountOffers(RPC::JsonContext &context)
std::string to_string(base_uint< Bits, Tag > const &a)
@ ltANY
A special type, matching any ledger entry type.
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
void appendOfferJson(std::shared_ptr< SLE const > const &offer, Json::Value &offers)
Resource::Charge & loadType