1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/core/ServiceRegistry.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/helpers/CredentialHelpers.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/ErrorCodes.h>
12#include <xrpl/protocol/Indexes.h>
13#include <xrpl/protocol/LedgerFormats.h>
14#include <xrpl/protocol/Protocol.h>
15#include <xrpl/protocol/RPCErr.h>
16#include <xrpl/protocol/SField.h>
17#include <xrpl/protocol/jss.h>
40 if (!params.
isMember(jss::source_account))
42 if (!params[jss::source_account].isString())
51 auto const srcAcct{srcID.value()};
54 if (!params.
isMember(jss::destination_account))
56 if (!params[jss::destination_account].isString())
65 auto const dstAcct{dstID.value()};
89 bool const reqAuth = sleDest->isFlag(lsfDepositAuth) && (srcAcct != dstAcct);
90 bool const credentialsPresent = params.
isMember(jss::credentials);
94 if (credentialsPresent)
96 auto const& creds(params[jss::credentials]);
97 if (!creds.isArray() || !creds)
102 jss::credentials,
"is non-empty array of CredentialID(hash256)"));
110 lifeExtender.
reserve(creds.size());
111 for (
auto const& jo : creds)
118 jss::credentials,
"an array of CredentialID(hash256)"));
122 auto const credS = jo.asString();
128 jss::credentials,
"an array of CredentialID(hash256)"));
138 if (!sleCred->isFlag(lsfAccepted))
150 if ((*sleCred)[sfSubject] != srcAcct)
157 auto [it, ins] = sorted.
emplace((*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
163 lifeExtender.
push_back(std::move(sleCred));
169 bool depositAuthorized =
true;
176 result[jss::source_account] = params[jss::source_account].
asString();
177 result[jss::destination_account] = params[jss::destination_account].
asString();
178 if (credentialsPresent)
179 result[jss::credentials] = params[jss::credentials];
181 result[jss::deposit_authorized] = depositAuthorized;
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
std::shared_ptr< STLedgerEntry const > const_pointer
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, json::Value &result)
Looks up a ledger from a request and fills a json::Value with ledger data.
json::Value makeError(ErrorCodeI code)
Returns a new json object that reflects the error code.
void injectError(ErrorCodeI code, json::Value &json)
Add or update the json update to reflect the error code.
std::string expectedFieldMessage(std::string const &name, std::string const &type)
json::Value missingFieldError(std::string const &name)
bool checkExpired(SLE const &sleCredential, NetClock::time_point const &closed)
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
json::Value rpcError(ErrorCodeI iError)
constexpr std::size_t kMaxCredentialsArraySize
The maximum number of credentials can be passed in array.
json::Value doDepositAuthorized(RPC::JsonContext &)