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/SField.h>
18#include <xrpl/protocol/STLedgerEntry.h> // IWYU pragma: keep
19#include <xrpl/protocol/SecretKey.h>
20#include <xrpl/protocol/Seed.h>
21#include <xrpl/protocol/UintTypes.h>
22#include <xrpl/server/NetworkOPs.h>
23
24#include <cstdint>
25#include <optional>
26#include <utility>
27
28namespace xrpl {
29
30class ReadView;
31
32namespace rpc {
33
34struct JsonContext;
35
48std::uint64_t
49getStartHint(SLE::ConstRef sle, AccountID const& accountID);
50
62bool
63isRelatedToAccount(ReadView const& ledger, SLE::ConstRef sle, AccountID const& accountID);
64
73bool
74isOwnerDirNodeField(SField const& field);
75
85parseAccountIds(json::Value const& jvArray);
86
96parseMPTIssuanceIDs(json::Value const& jvArray);
97
111std::optional<json::Value>
112readLimitField(unsigned int& limit, tuning::LimitRange const& range, JsonContext const& context);
113
125std::optional<Seed>
126getSeedFromRPC(json::Value const& params, json::Value& error);
127
137std::optional<Seed>
138parseXrplLibSeed(json::Value const& params);
139
150std::pair<rpc::Status, LedgerEntryType>
151chooseLedgerEntryType(json::Value const& params);
152
166bool
168
183std::optional<std::pair<PublicKey, SecretKey>>
185 json::Value const& params,
186 json::Value& error,
187 unsigned int apiVersion = kApiVersionIfUnspecified);
188
194 Asset& asset,
195 json::Value const& jv,
196 json::StaticString const& name,
197 beast::Journal j);
198
199} // namespace rpc
200
201} // namespace xrpl
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & ConstRef
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.
bool isOwnerDirNodeField(SField const &field)
Checks whether an SField is a UINT64 sf*Node owner-directory page-hint field probed by isRelatedToAcc...
std::uint64_t getStartHint(SLE::ConstRef sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
static constexpr auto kApiVersionIfUnspecified
Definition ApiVersion.h:44
HashSet< MPTID > parseMPTIssuanceIDs(json::Value const &jvArray)
Parses an array of MPT issuance IDs from a JSON value.
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.
HashSet< AccountID > parseAccountIds(json::Value const &jvArray)
Parses an array of account IDs from a JSON value.
bool isRelatedToAccount(ReadView const &ledger, SLE::ConstRef sle, AccountID const &accountID)
Tests if a ledger entry (SLE) is owned by the specified account.
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 > HashSet
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.