rippled
Loading...
Searching...
No Matches
RPCHelpers.h
1#ifndef XRPL_RPC_RPCHELPERS_H_INCLUDED
2#define XRPL_RPC_RPCHELPERS_H_INCLUDED
3
4#include <xrpld/app/misc/NetworkOPs.h>
5#include <xrpld/app/misc/TxQ.h>
6#include <xrpld/rpc/Context.h>
7#include <xrpld/rpc/Status.h>
8#include <xrpld/rpc/detail/Tuning.h>
9
10#include <xrpl/beast/core/SemanticVersion.h>
11#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.pb.h>
12#include <xrpl/protocol/ApiVersion.h>
13#include <xrpl/protocol/SecretKey.h>
14
15#include <optional>
16#include <variant>
17
18namespace Json {
19class Value;
20}
21
22namespace ripple {
23
24class ReadView;
25class Transaction;
26
27namespace RPC {
28
29struct JsonContext;
30
34
35// --> strIdent: public key, account ID, or regular seed.
36// --> bStrict: Only allow account id or public key.
37//
38// Returns a Json::objectValue, containing error information if there was one.
41 AccountID& result,
42 std::string const& strIdent,
43 bool bStrict = false);
44
53 AccountID& result,
54 std::string const& strIdent,
55 bool bStrict = false);
56
62getStartHint(std::shared_ptr<SLE const> const& sle, AccountID const& accountID);
63
70bool
72 ReadView const& ledger,
74 AccountID const& accountID);
75
85bool
87 ReadView const& ledger,
88 AccountID const& account,
90 uint256 dirIndex,
91 uint256 entryIndex,
92 std::uint32_t const limit,
93 Json::Value& jvResult);
94
99template <class T>
100Status
101getLedger(T& ledger, uint256 const& ledgerHash, Context& context);
102
107template <class T>
108Status
109getLedger(T& ledger, uint32_t ledgerIndex, Context& context);
110
116template <class T>
117Status
118getLedger(T& ledger, LedgerShortcut shortcut, Context& context);
119
128
134Status
137 JsonContext&,
138 Json::Value& result);
139
140template <class T, class R>
141Status
142ledgerFromRequest(T& ledger, GRPCContext<R>& context);
143
144template <class T>
145Status
147 T& ledger,
148 org::xrpl::rpc::v1::LedgerSpecifier const& specifier,
149 Context& context);
150
152parseAccountIds(Json::Value const& jvArray);
153
154bool
156
165void
166injectSLE(Json::Value& jv, SLE const& sle);
167
175 unsigned int& limit,
176 Tuning::LimitRange const&,
177 JsonContext const&);
178
180getSeedFromRPC(Json::Value const& params, Json::Value& error);
181
183parseRippleLibSeed(Json::Value const& params);
184
187
194bool
196
201
204 Json::Value const& params,
205 Json::Value& error,
206 unsigned int apiVersion = apiVersionIfUnspecified);
207
208} // namespace RPC
209
210} // namespace ripple
211
212#endif
Represents a JSON value.
Definition json_value.h:130
JSON (JavaScript Object Notation).
Definition json_errors.h:6
Status
Return codes from Backend operations.
Status ledgerFromRequest(T &ledger, GRPCContext< R > &context)
error_code_i accountFromStringWithCode(AccountID &result, std::string const &strIdent, bool bStrict)
Decode account ID from string.
std::optional< Seed > getSeedFromRPC(Json::Value const &params, Json::Value &error)
std::variant< std::shared_ptr< Ledger const >, Json::Value > getLedgerByContext(RPC::JsonContext &context)
Return a ledger based on ledger_hash or ledger_index, or an RPC error.
bool isAccountObjectsValidType(LedgerEntryType const &type)
Check if the type is a valid filtering type for account_objects method.
static constexpr std::integral_constant< unsigned, Version > apiVersion
Definition ApiVersion.h:39
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a SLE is owned by accountID.
void injectSLE(Json::Value &jv, SLE const &sle)
Inject JSON describing ledger entry.
Status getLedger(T &ledger, uint256 const &ledgerHash, Context &context)
Get ledger by hash If there is no error in the return value, the ledger pointer will have been filled...
std::pair< RPC::Status, LedgerEntryType > chooseLedgerEntryType(Json::Value const &params)
bool getAccountObjects(ReadView const &ledger, AccountID const &account, std::optional< std::vector< LedgerEntryType > > const &typeFilter, uint256 dirIndex, uint256 entryIndex, std::uint32_t const limit, Json::Value &jvResult)
Gathers all objects for an account in a ledger.
std::optional< Json::Value > readLimitField(unsigned int &limit, Tuning::LimitRange const &range, JsonContext const &context)
Retrieve the limit value from a JsonContext, or set a default - then restrict the limit by max and mi...
Json::Value accountFromString(AccountID &result, std::string const &strIdent, bool bStrict)
static constexpr auto apiVersionIfUnspecified
Definition ApiVersion.h:44
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.
Status ledgerFromSpecifier(T &ledger, org::xrpl::rpc::v1::LedgerSpecifier const &specifier, Context &context)
std::optional< AccountID > accountFromStringStrict(std::string const &account)
Get an AccountID from an account ID or public key.
hash_set< AccountID > parseAccountIds(Json::Value const &jvArray)
std::uint64_t getStartHint(std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
bool isHexTxID(std::string const &txid)
std::optional< Seed > parseRippleLibSeed(Json::Value const &value)
std::optional< std::pair< PublicKey, SecretKey > > keypairForSignature(Json::Value const &params, Json::Value &error, unsigned int apiVersion)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
base_uint< 256 > uint256
Definition base_uint.h:539
LedgerEntryType
Identifiers for on-ledger objects.
Represents RPC limit parameter values that have a min, default and max.