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 std::string strIdent(params[jss::account].asString());
73 for (
auto it = jv.begin(); it != jv.end(); ++it)
74 result[it.memberName()] = (*it);
91 unsigned int reserve(limit);
95 if (params.isMember(jss::marker))
107 auto const sleOffer = ledger->
read({
ltOFFER, startAfter});
109 if (!sleOffer || accountID != sleOffer->getAccountID(
sfAccount))
117 offers.reserve(reserve);
123 offers.reserve(++reserve);
133 if (offer->getType() ==
ltOFFER)
135 offers.emplace_back(offer);
145 if (offers.size() == reserve)
147 result[jss::limit] = limit;
149 result[jss::marker] =
to_string(offers.back()->key());
153 for (
auto const& offer : offers)
void appendOfferJson(std::shared_ptr< SLE const > const &offer, Json::Value &offers)
const SF_UINT64 sfOwnerNode
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
const SF_HASH256 sfBookDirectory
const SF_UINT32 sfSequence
Resource::Charge & loadType
std::string getText() const override
std::string to_string(ListDisposition disposition)
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.
virtual AccountIDCache const & accountIDCache() const =0
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
@ 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)
Json::Value rpcError(int iError, Json::Value jvResult)
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.
bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
bool forEachItemAfter(ReadView const &view, AccountID const &id, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> f)
Iterate all items after an item in an owner directory.
const SF_ACCOUNT sfAccount
std::uint64_t getQuality(uint256 const &uBase)
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
std::string toBase58(AccountID const &) const
Return ripple::toBase58 for the AccountID.
std::string asString() const
Returns the unquoted string value.