20 #include <ripple/app/main/Application.h>
21 #include <ripple/json/json_value.h>
22 #include <ripple/ledger/ReadView.h>
23 #include <ripple/ledger/View.h>
24 #include <ripple/net/RPCErr.h>
25 #include <ripple/protocol/ErrorCodes.h>
26 #include <ripple/protocol/jss.h>
27 #include <ripple/resource/Fees.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/impl/RPCHelpers.h>
30 #include <ripple/rpc/impl/Tuning.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();
59 auto const& params(context.
params);
60 if (!params.isMember(jss::account))
68 auto id = parseBase58<AccountID>(params[jss::account].asString());
74 auto const accountID{std::move(
id.value())};
77 result[jss::account] =
toBase58(accountID);
91 uint256 startAfter = beast::zero;
94 if (params.isMember(jss::marker))
96 if (!params[jss::marker].isString())
114 startHint = boost::lexical_cast<std::uint64_t>(value);
116 catch (boost::bad_lexical_cast&)
123 auto const sle = ledger->
read({
ltANY, startAfter});
141 [&offers, &count, &marker, &limit, &nextHint, &accountID](
149 if (++count == limit)
155 if (count <= limit && sle->getType() ==
ltOFFER)
157 offers.emplace_back(sle);
169 if (count == limit + 1 && marker)
171 result[jss::limit] = limit;
172 result[jss::marker] =
176 for (
auto const& offer : offers)
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
void appendOfferJson(std::shared_ptr< SLE const > const &offer, Json::Value &offers)
Json::Value rpcError(int iError)
@ 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.
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
const SF_UINT32 sfSequence
Resource::Charge & loadType
const SF_UINT256 sfBookDirectory
std::string getText() const override
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
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 expected_field_error(std::string const &name, std::string const &type)
const SF_UINT32 sfExpiration
Json::Value missing_field_error(std::string const &name)
const SF_AMOUNT sfTakerPays
@ ltOFFER
A ledger object which describes an offer on the DEX.
@ objectValue
object value (collection of name/value pairs).
Keylet account(AccountID const &id) noexcept
AccountID root.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
const SF_AMOUNT sfTakerGets
Json::Value doAccountOffers(RPC::JsonContext &context)
STAmount amountFromQuality(std::uint64_t rate)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static constexpr LimitRange accountOffers
Limits for the account_offers command.
std::uint64_t getStartHint(std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
std::uint64_t getQuality(uint256 const &uBase)
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a SLE is owned by accountID.