20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/paths/RippleState.h>
22 #include <ripple/ledger/ReadView.h>
23 #include <ripple/net/RPCErr.h>
24 #include <ripple/protocol/ErrorCodes.h>
25 #include <ripple/protocol/jss.h>
26 #include <ripple/resource/Fees.h>
27 #include <ripple/rpc/Context.h>
28 #include <ripple/rpc/impl/RPCHelpers.h>
29 #include <ripple/rpc/impl/Tuning.h>
44 STAmount const& saBalance(line.getBalance());
45 STAmount const& saLimit(line.getLimit());
46 STAmount const& saLimitPeer(line.getLimitPeer());
49 jPeer[jss::account] =
to_string(line.getAccountIDPeer());
55 jPeer[jss::balance] = saBalance.
getText();
57 jPeer[jss::limit] = saLimit.
getText();
58 jPeer[jss::limit_peer] = saLimitPeer.
getText();
59 jPeer[jss::quality_in] = line.getQualityIn().value;
60 jPeer[jss::quality_out] = line.getQualityOut().value;
62 jPeer[jss::authorized] =
true;
63 if (line.getAuthPeer())
64 jPeer[jss::peer_authorized] =
true;
65 if (line.getNoRipple() || !line.getDefaultRipple())
66 jPeer[jss::no_ripple] = line.getNoRipple();
67 if (line.getNoRipplePeer() || !line.getDefaultRipple())
68 jPeer[jss::no_ripple_peer] = line.getNoRipplePeer();
70 jPeer[jss::freeze] =
true;
71 if (line.getFreezePeer())
72 jPeer[jss::freeze_peer] =
true;
85 auto const& params(context.
params);
86 if (!params.isMember(jss::account))
94 std::string strIdent(params[jss::account].asString());
99 for (
auto it = jv.begin(); it != jv.end(); ++it)
100 result[it.memberName()] = *it;
108 if (params.isMember(jss::peer))
109 strPeer = params[jss::peer].asString();
110 auto hasPeer = !strPeer.
empty();
117 for (
auto it = jv.begin(); it != jv.end(); ++it)
118 result[it.memberName()] = *it;
128 VisitData visitData = {{}, accountID, hasPeer, raPeerAccount};
129 unsigned int reserve(limit);
133 if (params.isMember(jss::marker))
150 if (sleLine->getFieldAmount(
sfLowLimit).getIssuer() == accountID)
151 startHint = sleLine->getFieldU64(
sfLowNode);
152 else if (sleLine->getFieldAmount(
sfHighLimit).getIssuer() == accountID)
163 visitData.
items.reserve(reserve);
169 visitData.
items.reserve(++reserve);
182 if (line !=
nullptr &&
186 visitData.
items.emplace_back(line);
197 if (visitData.
items.size() == reserve)
199 result[jss::limit] = limit;
203 visitData.
items.pop_back();
208 for (
auto const& item : visitData.
items)
Wraps a trust line SLE for convenience.
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
Resource::Charge & loadType
Value get(UInt index, const Value &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
std::string getText() const override
AccountID const & raPeerAccount
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)
Json::Value missing_field_error(std::string const &name)
const SF_UINT64 sfLowNode
const SF_AMOUNT sfLowLimit
AccountID const & accountID
Value & append(const Value &value)
Append value to array at the end.
static constexpr LimitRange accountLines
Limits for the account_lines command.
@ objectValue
object value (collection of name/value pairs).
Keylet account(AccountID const &id) noexcept
AccountID root.
static RippleState::pointer makeItem(AccountID const &accountID, std::shared_ptr< SLE const > sle)
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
const SF_AMOUNT sfHighLimit
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.
void addLine(Json::Value &jsonLines, RippleState const &line)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Issue const & issue() const
std::vector< RippleState::pointer > items
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_UINT64 sfHighNode
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
Json::Value doAccountLines(RPC::JsonContext &context)
std::string toBase58(AccountID const &) const
Return ripple::toBase58 for the AccountID.
std::string asString() const
Returns the unquoted string value.