xrpld
Loading...
Searching...
No Matches
RPCHelpers.h
1#pragma once
2
3#include <xrpld/rpc/Context.h>
4#include <xrpld/rpc/Status.h>
5#include <xrpld/rpc/detail/Tuning.h>
6
7#include <xrpl/basics/UnorderedContainers.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/core/ServiceRegistry.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/ApiVersion.h>
13#include <xrpl/protocol/Asset.h>
14#include <xrpl/protocol/ErrorCodes.h>
15#include <xrpl/protocol/LedgerFormats.h>
16#include <xrpl/protocol/PublicKey.h>
17#include <xrpl/protocol/STLedgerEntry.h> // IWYU pragma: keep
18#include <xrpl/protocol/SecretKey.h>
19#include <xrpl/protocol/Seed.h>
20#include <xrpl/server/NetworkOPs.h>
21
22#include <cstdint>
23#include <optional>
24#include <utility>
25
26namespace xrpl {
27
28class ReadView;
29
30namespace rpc {
31
32struct JsonContext;
33
46std::uint64_t
47getStartHint(SLE::const_ref sle, AccountID const& accountID);
48
60bool
61isRelatedToAccount(ReadView const& ledger, SLE::const_ref sle, AccountID const& accountID);
62
72parseAccountIds(json::Value const& jvArray);
73
87std::optional<json::Value>
88readLimitField(unsigned int& limit, tuning::LimitRange const& range, JsonContext const& context);
89
101std::optional<Seed>
102getSeedFromRPC(json::Value const& params, json::Value& error);
103
113std::optional<Seed>
114parseXrplLibSeed(json::Value const& params);
115
126std::pair<rpc::Status, LedgerEntryType>
127chooseLedgerEntryType(json::Value const& params);
128
142bool
144
159std::optional<std::pair<PublicKey, SecretKey>>
161 json::Value const& params,
162 json::Value& error,
163 unsigned int apiVersion = kApiVersionIfUnspecified);
164
170 Asset& asset,
171 json::Value const& jv,
172 json::StaticString const& name,
173 beast::Journal j);
174
175} // namespace rpc
176
177} // namespace xrpl
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & const_ref
API version numbers used in later API versions.
Definition ApiVersion.h:36
std::pair< rpc::Status, LedgerEntryType > chooseLedgerEntryType(json::Value const &params)
Chooses the ledger entry type based on RPC parameters.
std::uint64_t getStartHint(SLE::const_ref sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
bool isRelatedToAccount(ReadView const &ledger, SLE::const_ref sle, AccountID const &accountID)
Tests if a ledger entry (SLE) is owned by the specified account.
static constexpr auto kApiVersionIfUnspecified
Definition ApiVersion.h:44
ErrorCodeI parseSubUnsubJson(Asset &asset, json::Value const &params, json::StaticString const &name, beast::Journal j)
Parse subscribe/unsubscribe parameters.
std::optional< json::Value > readLimitField(unsigned int &limit, tuning::LimitRange const &range, JsonContext const &context)
Retrieves the limit value from a JsonContext or sets a default.
hash_set< AccountID > parseAccountIds(json::Value const &jvArray)
Parses an array of account IDs from a JSON value.
std::optional< Seed > getSeedFromRPC(json::Value const &params, json::Value &error)
Extracts a Seed from RPC parameters.
std::optional< Seed > parseXrplLibSeed(json::Value const &value)
Parses a XrplLib seed from RPC parameters.
std::optional< std::pair< PublicKey, SecretKey > > keypairForSignature(json::Value const &params, json::Value &error, unsigned int apiVersion)
Generates a keypair for signature from RPC parameters.
bool isAccountObjectsValidType(LedgerEntryType const &type)
Checks if the type is a valid filtering type for the account_objects method.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
ErrorCodeI
Definition ErrorCodes.h:23
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Definition RangeSet.h:37
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
LedgerEntryType
Identifiers for on-ledger objects.
Represents RPC limit parameter values that have a min, default and max.