20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/paths/TrustLine.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>
47 STAmount const& saBalance(line.getBalance());
48 STAmount const& saLimit(line.getLimit());
49 STAmount const& saLimitPeer(line.getLimitPeer());
52 jPeer[jss::account] =
to_string(line.getAccountIDPeer());
58 jPeer[jss::balance] = saBalance.
getText();
60 jPeer[jss::limit] = saLimit.
getText();
61 jPeer[jss::limit_peer] = saLimitPeer.
getText();
62 jPeer[jss::quality_in] = line.getQualityIn().value;
63 jPeer[jss::quality_out] = line.getQualityOut().value;
65 jPeer[jss::authorized] =
true;
66 if (line.getAuthPeer())
67 jPeer[jss::peer_authorized] =
true;
68 if (line.getNoRipple() || !line.getDefaultRipple())
69 jPeer[jss::no_ripple] = line.getNoRipple();
70 if (line.getNoRipplePeer() || !line.getDefaultRipple())
71 jPeer[jss::no_ripple_peer] = line.getNoRipplePeer();
73 jPeer[jss::freeze] =
true;
74 if (line.getFreezePeer())
75 jPeer[jss::freeze_peer] =
true;
90 auto const& params(context.
params);
91 if (!params.isMember(jss::account))
99 std::string strIdent(params[jss::account].asString());
104 for (
auto it = jv.begin(); it != jv.end(); ++it)
105 result[it.memberName()] = *it;
113 if (params.isMember(jss::peer))
114 strPeer = params[jss::peer].asString();
115 auto hasPeer = !strPeer.
empty();
122 for (
auto it = jv.begin(); it != jv.end(); ++it)
123 result[it.memberName()] = *it;
137 bool ignoreDefault = params.isMember(jss::ignore_default) &&
138 params[jss::ignore_default].asBool();
142 {}, accountID, hasPeer, raPeerAccount, ignoreDefault, 0};
143 uint256 startAfter = beast::zero;
146 if (params.isMember(jss::marker))
148 if (!params[jss::marker].isString())
166 startHint = boost::lexical_cast<std::uint64_t>(value);
168 catch (boost::bad_lexical_cast&)
175 auto const sle = ledger->
read({
ltANY, startAfter});
194 [&visitData, &count, &marker, &limit, &nextHint](
202 if (++count == limit)
204 marker = sleCur->
key();
224 if (!ignore && count <= limit)
232 line->getAccountIDPeer()))
234 visitData.
items.emplace_back(*line);
248 if (count == limit + 1 && marker)
250 result[jss::limit] = limit;
251 result[jss::marker] =
255 result[jss::account] =
toBase58(accountID);
257 for (
auto const& item : visitData.
items)
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
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.
Issue const & issue() const
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
Resource::Charge & loadType
std::string getText() const override
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
AccountID const & raPeerAccount
std::vector< RPCTrustLine > items
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)
AccountID const & getIssuer() const
Json::Value missing_field_error(std::string const &name)
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.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
LedgerEntryType getType() const
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.
std::uint64_t getStartHint(std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
static std::optional< RPCTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
@ ltRIPPLE_STATE
A ledger object which describes a bidirectional trust line.
std::uint32_t getFieldU32(SField const &field) const
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
STAmount const & getFieldAmount(SField const &field) const
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a SLE is owned by accountID.
void addLine(Json::Value &jsonLines, RPCTrustLine const &line)
Json::Value doAccountLines(RPC::JsonContext &context)