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/jss.h>
26 #include <ripple/protocol/PublicKey.h>
27 #include <ripple/protocol/STAccount.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>
46 jDst[jss::public_key_hex] =
strHex (pk);
50 jDst[jss::expiration] = *v;
52 jDst[jss::cancel_after] = *v;
54 jDst[jss::source_tag] = *v;
56 jDst[jss::destination_tag] = *v;
68 auto const& params (context.
params);
69 if (! params.isMember (jss::account))
77 std::string strIdent (params[jss::account].asString ());
87 if (params.isMember (jss::destination_account))
88 strDst = params[jss::destination_account].asString ();
89 auto hasDst = ! strDst.
empty ();
110 VisitData visitData = {{}, accountID, hasDst, raDstAccount};
111 visitData.
items.reserve(limit+1);
115 if (params.isMember (jss::marker))
127 auto const sleChannel = ledger->
read({
ltPAYCHAN, startAfter});
133 if (!visitData.hasDst ||
136 visitData.
items.emplace_back(sleChannel);
150 limit-visitData.
items.size()+1,
152 if (sleCur && sleCur->getType() == ltPAYCHAN &&
153 (*sleCur)[sfAccount] == accountID &&
154 (!visitData.hasDst ||
155 visitData.raDstAccount == (*sleCur)[sfDestination]))
157 visitData.items.emplace_back(sleCur);
167 if (visitData.items.size () == limit+1)
169 result[jss::limit] = limit;
171 result[jss::marker] =
to_string (visitData.items.back()->key());
172 visitData.items.pop_back ();
175 result[jss::account] = context.app.accountIDCache().toBase58 (accountID);
177 for (
auto const& item : visitData.items)
181 result[jss::channels] = std::move(jsonChannels);
boost::optional< KeyType > publicKeyType(Slice const &slice)
Returns the type of public key.
const Charge feeMediumBurdenRPC
@ arrayValue
array value (ordered list)
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string to_string(ListDisposition disposition)
const SF_U64 sfOwnerNode(access, STI_UINT64, 4, "OwnerNode")
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
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_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
Json::Value missing_field_error(std::string const &name)
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
AccountID const & accountID
Value & append(const Value &value)
Append value to array at the end.
@ objectValue
object value (collection of name/value pairs).
static const account_t account
std::string getText() const override
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.
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
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.
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
std::vector< RippleState::pointer > items
static constexpr LimitRange accountChannels
Limits for the account_channels command.
const SF_U32 sfSettleDelay(access, STI_UINT32, 39, "SettleDelay")
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_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
Json::Value doAccountChannels(RPC::JsonContext &context)
std::string strHex(FwdIt begin, FwdIt end)
void addChannel(Json::Value &jsonLines, SLE const &line)
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
std::string asString() const
Returns the unquoted string value.