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 ();
58 auto const& params (context.
params);
59 if (! params.isMember (jss::account))
67 std::string strIdent (params[jss::account].asString ());
72 for (
auto it = jv.begin (); it != jv.end (); ++it)
73 result[it.memberName ()] = (*it);
90 unsigned int reserve (limit);
94 if (params.isMember(jss::marker))
104 auto const sleOffer = ledger->
read({
ltOFFER, startAfter});
106 if (! sleOffer || accountID != sleOffer->getAccountID (
sfAccount))
114 offers.reserve (reserve);
120 offers.reserve (++reserve);
124 startAfter, startHint, reserve,
127 if (offer->getType () ==
ltOFFER)
129 offers.emplace_back (offer);
139 if (offers.size () == reserve)
141 result[jss::limit] = limit;
143 result[jss::marker] =
to_string (offers.back ()->key ());
147 for (
auto const& offer : offers)
void appendOfferJson(std::shared_ptr< SLE const > const &offer, Json::Value &offers)
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
Resource::Charge & loadType
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
std::string getText() const override
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
std::string to_string(ListDisposition disposition)
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
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)
Json::Value missing_field_error(std::string const &name)
const SF_U256 sfBookDirectory(access, STI_HASH256, 16, "BookDirectory")
@ objectValue
object value (collection of name/value pairs).
static const account_t account
bool SetHex(const char *psz, bool bStrict=false)
Parse a hex string into a base_uint The input can be:
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
Json::Value doAccountOffers(RPC::JsonContext &context)
STAmount amountFromQuality(std::uint64_t rate)
Json::Value rpcError(int iError, Json::Value jvResult)
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
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.
const SF_Amount sfTakerGets(access, STI_AMOUNT, 5, "TakerGets")
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.
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.