1#include <xrpld/app/misc/Transaction.h>
2#include <xrpld/app/paths/TrustLine.h>
3#include <xrpld/app/rdb/RelationalDatabase.h>
4#include <xrpld/app/tx/detail/NFTokenUtils.h>
5#include <xrpld/rpc/Context.h>
6#include <xrpld/rpc/DeliveredAmount.h>
7#include <xrpld/rpc/detail/RPCHelpers.h>
9#include <xrpl/ledger/View.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/RPCErr.h>
12#include <xrpl/protocol/nftPageMask.h>
13#include <xrpl/resource/Fees.h>
15#include <boost/algorithm/string/case_conv.hpp>
16#include <boost/algorithm/string/predicate.hpp>
24 if (sle->getType() == ltRIPPLE_STATE)
26 if (sle->getFieldAmount(sfLowLimit).getIssuer() == accountID)
27 return sle->getFieldU64(sfLowNode);
28 else if (sle->getFieldAmount(sfHighLimit).getIssuer() == accountID)
29 return sle->getFieldU64(sfHighNode);
32 if (!sle->isFieldPresent(sfOwnerNode))
35 return sle->getFieldU64(sfOwnerNode);
41 if (sle->getType() == ltRIPPLE_STATE)
43 return (sle->getFieldAmount(sfLowLimit).getIssuer() == accountID) ||
44 (sle->getFieldAmount(sfHighLimit).getIssuer() == accountID);
46 else if (sle->isFieldPresent(sfAccount))
54 return sle->getAccountID(sfAccount) == accountID ||
55 (sle->isFieldPresent(sfDestination) && sle->getAccountID(sfDestination) == accountID);
57 else if (sle->getType() == ltSIGNER_LIST)
60 return sle->key() == accountSignerList.
key;
62 else if (sle->getType() == ltNFTOKEN_OFFER)
66 return sle->getAccountID(sfOwner) == accountID;
76 for (
auto const& jv : jvArray)
80 auto const id = parseBase58<AccountID>(jv.asString());
91 limit =
range.rDefault;
95 auto const& jvLimit = context.
params[jss::limit];
96 if (!(jvLimit.isUInt() || (jvLimit.isInt() && jvLimit.asInt() >= 0)))
99 limit = jvLimit.asUInt();
133 static seed_match_t
const seedTypes[]{
135 {jss::seed.c_str(), [](
std::string const& s) {
return parseBase58<Seed>(s); }},
144 seed_match_t
const* seedType =
nullptr;
146 for (
auto const& t : seedTypes)
158 "Exactly one of the following must be specified: " +
std::string(jss::passphrase) +
", " +
164 auto const& param = params[seedType->first];
165 if (!param.isString())
171 auto const fieldContents = param.asString();
185 bool const has_key_type = params.
isMember(jss::key_type);
188 static char const*
const secretTypes[]{
189 jss::passphrase.c_str(), jss::secret.c_str(), jss::seed.c_str(), jss::seed_hex.c_str()};
192 char const* secretType =
nullptr;
194 for (
auto t : secretTypes)
203 if (count == 0 || secretType ==
nullptr)
212 "Exactly one of the following must be specified: " +
std::string(jss::passphrase) +
", " +
222 if (!params[jss::key_type].isString())
241 if (strcmp(secretType, jss::secret.c_str()) == 0)
254 if (strcmp(secretType, jss::seed_hex.c_str()) != 0)
281 if (!params[jss::secret].isString())
302 LogicError(
"keypairForSignature: invalid key type");
314#pragma push_macro("LEDGER_ENTRY")
317#define LEDGER_ENTRY(tag, value, name, rpcName, ...) {jss::name, jss::rpcName, tag},
319#include <xrpl/protocol/detail/ledger_entries.macro>
322#pragma pop_macro("LEDGER_ENTRY")
325 auto const& p = params[jss::type];
331 "xrpl::RPC::chooseLedgerEntryType : first valid result type");
338 auto const filter = p.asString();
340 return boost::iequals(std::get<0>(t), filter) || std::get<1>(t) == filter;
342 if (iter == types.end())
347 "xrpl::RPC::chooseLedgerEntryType : second valid result "
361 case LedgerEntryType::ltAMENDMENTS:
362 case LedgerEntryType::ltDIR_NODE:
363 case LedgerEntryType::ltFEE_SETTINGS:
364 case LedgerEntryType::ltLEDGER_HASHES:
365 case LedgerEntryType::ltNEGATIVE_UNL:
std::string asString() const
Returns the unquoted string value.
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
Seeds are used to generate deterministic secret keys.
An immutable linear range of bytes.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
static constexpr std::size_t size()
Json::Value invalid_field_error(std::string const &name)
bool isRelatedToAccount(ReadView const &ledger, std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Tests if a ledger entry (SLE) is owned by the specified account.
std::pair< RPC::Status, LedgerEntryType > chooseLedgerEntryType(Json::Value const ¶ms)
Chooses the ledger entry type based on RPC parameters.
bool isAccountObjectsValidType(LedgerEntryType const &type)
Checks if the type is a valid filtering type for the account_objects method.
std::uint64_t getStartHint(std::shared_ptr< SLE const > const &sle, AccountID const &accountID)
Gets the start hint for traversing account objects.
Json::Value expected_field_error(std::string const &name, std::string const &type)
Json::Value missing_field_error(std::string const &name)
std::optional< Seed > parseRippleLibSeed(Json::Value const &value)
Parses a RippleLib seed from RPC parameters.
hash_set< AccountID > parseAccountIds(Json::Value const &jvArray)
Parses an array of account IDs from a JSON value.
static constexpr std::integral_constant< unsigned, Version > apiVersion
Json::Value make_param_error(std::string const &message)
Returns a new json object that indicates invalid parameters.
std::string invalid_field_message(std::string const &name)
std::optional< std::pair< PublicKey, SecretKey > > keypairForSignature(Json::Value const ¶ms, Json::Value &error, unsigned int apiVersion)
Generates a keypair for signature from RPC parameters.
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
std::optional< Seed > getSeedFromRPC(Json::Value const ¶ms, Json::Value &error)
Extracts a Seed from RPC 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.
bool contains_error(Json::Value const &json)
Returns true if the json contains an rpc error specification.
Keylet signers(AccountID const &account) noexcept
A SignerList.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
std::optional< KeyType > keyTypeFromString(std::string const &s)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
std::pair< PublicKey, SecretKey > generateKeyPair(KeyType type, Seed const &seed)
Generate a key pair deterministically.
Json::Value rpcError(error_code_i iError)
LedgerEntryType
Identifiers for on-ledger objects.
@ ltANY
A special type, matching any ledger entry type.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
std::string decodeBase58Token(std::string const &s, TokenType type)
std::optional< Seed > parseGenericSeed(std::string const &str, bool rfc1751=true)
Attempt to parse a string as a seed.
A pair of SHAMap key and LedgerEntryType.
Status represents the results of an operation that might fail.
Represents RPC limit parameter values that have a min, default and max.