20 #include <ripple/app/main/Application.h>
21 #include <ripple/ledger/ReadView.h>
22 #include <ripple/ledger/View.h>
23 #include <ripple/net/RPCErr.h>
24 #include <ripple/protocol/ErrorCodes.h>
25 #include <ripple/protocol/PublicKey.h>
26 #include <ripple/protocol/STAccount.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/resource/Fees.h>
29 #include <ripple/rpc/Context.h>
30 #include <ripple/rpc/impl/RPCHelpers.h>
31 #include <ripple/rpc/impl/Tuning.h>
41 jDst[jss::amount] = line[
sfAmount].getText();
42 jDst[jss::balance] = line[
sfBalance].getText();
47 jDst[jss::public_key_hex] =
strHex(pk);
51 jDst[jss::expiration] = *v;
53 jDst[jss::cancel_after] = *v;
55 jDst[jss::source_tag] = *v;
57 jDst[jss::destination_tag] = *v;
70 auto const& params(context.
params);
71 if (!params.isMember(jss::account))
79 auto id = parseBase58<AccountID>(params[jss::account].asString());
84 AccountID const accountID{std::move(
id.value())};
90 if (params.isMember(jss::destination_account))
91 strDst = params[jss::destination_account].asString();
94 return strDst.
empty() ? std::nullopt : parseBase58<AccountID>(strDst);
96 if (!strDst.
empty() && !raDstAccount)
113 VisitData visitData = {{}, accountID, raDstAccount};
114 visitData.items.reserve(limit);
115 uint256 startAfter = beast::zero;
118 if (params.isMember(jss::marker))
120 if (!params[jss::marker].isString())
138 startHint = boost::lexical_cast<std::uint64_t>(value);
140 catch (boost::bad_lexical_cast&)
147 auto const sle = ledger->
read({
ltANY, startAfter});
165 [&visitData, &accountID, &count, &limit, &marker, &nextHint](
173 if (++count == limit)
175 marker = sleCur->
key();
179 if (count <= limit && sleCur->getType() ==
ltPAYCHAN &&
181 (!visitData.raDstAccount ||
184 visitData.items.emplace_back(sleCur);
196 if (count == limit + 1 && marker)
198 result[jss::limit] = limit;
199 result[jss::marker] =
203 result[jss::account] =
toBase58(accountID);
205 for (
auto const& item : visitData.items)
209 result[jss::channels] = std::move(jsonChannels);
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
const SF_UINT32 sfSourceTag
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 SF_ACCOUNT sfDestination
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
Resource::Charge & loadType
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)
std::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
Integers of any length that is a multiple of 32-bits.
Value & append(const Value &value)
Append value to array at the end.
const SF_UINT32 sfSettleDelay
@ 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.
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.
const SF_UINT32 sfDestinationTag
const SF_AMOUNT sfBalance
static constexpr LimitRange accountChannels
Limits for the account_channels command.
const SF_UINT32 sfCancelAfter
Json::Value doAccountChannels(RPC::JsonContext &context)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
const SF_ACCOUNT sfAccount
std::string strHex(FwdIt begin, FwdIt end)
void addChannel(Json::Value &jsonLines, SLE const &line)
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a SLE is owned by accountID.
@ ltPAYCHAN
A ledger object describing a single unidirectional XRP payment channel.