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 std::string strIdent(params[jss::account].asString());
89 if (params.isMember(jss::destination_account))
90 strDst = params[jss::destination_account].asString();
91 auto hasDst = !strDst.
empty();
112 VisitData visitData = {{}, accountID, hasDst, raDstAccount};
113 visitData.
items.reserve(limit + 1);
117 if (params.isMember(jss::marker))
129 auto const sleChannel = ledger->
read({
ltPAYCHAN, startAfter});
134 if (!visitData.hasDst ||
137 visitData.
items.emplace_back(sleChannel);
155 limit - visitData.
items.size() + 1,
157 if (sleCur && sleCur->getType() == ltPAYCHAN &&
158 (*sleCur)[sfAccount] == accountID &&
159 (!visitData.hasDst ||
160 visitData.raDstAccount == (*sleCur)[sfDestination]))
162 visitData.items.emplace_back(sleCur);
172 if (visitData.items.size() == limit + 1)
174 result[jss::limit] = limit;
176 result[jss::marker] =
to_string(visitData.items.back()->key());
177 visitData.items.pop_back();
180 result[jss::account] = context.app.accountIDCache().toBase58(accountID);
182 for (
auto const& item : visitData.items)
186 result[jss::channels] = std::move(jsonChannels);
const SF_UINT32 sfSourceTag
const SF_UINT64 sfOwnerNode
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
const SF_ACCOUNT sfDestination
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
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.
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)
AccountID const & accountID
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.
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.
bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
const SF_UINT32 sfDestinationTag
std::vector< RippleState::pointer > items
const SF_AMOUNT sfBalance
static constexpr LimitRange accountChannels
Limits for the account_channels command.
const SF_UINT32 sfCancelAfter
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.
Json::Value doAccountChannels(RPC::JsonContext &context)
const SF_ACCOUNT sfAccount
std::string strHex(FwdIt begin, FwdIt end)
void addChannel(Json::Value &jsonLines, SLE const &line)
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
std::string asString() const
Returns the unquoted string value.