1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
4#include <xrpl/ledger/CredentialHelpers.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/Indexes.h>
8#include <xrpl/protocol/RPCErr.h>
9#include <xrpl/protocol/jss.h>
27 if (!params.
isMember(jss::source_account))
29 if (!params[jss::source_account].isString())
32 auto srcID = parseBase58<AccountID>(params[jss::source_account].asString());
35 auto const srcAcct{std::move(srcID.value())};
38 if (!params.
isMember(jss::destination_account))
40 if (!params[jss::destination_account].isString())
43 auto dstID = parseBase58<AccountID>(params[jss::destination_account].asString());
46 auto const dstAcct{std::move(dstID.value())};
70 bool const reqAuth = (sleDest->getFlags() &
lsfDepositAuth) && (srcAcct != dstAcct);
71 bool const credentialsPresent = params.
isMember(jss::credentials);
75 if (credentialsPresent)
77 auto const& creds(params[jss::credentials]);
78 if (!creds.isArray() || !creds)
89 lifeExtender.
reserve(creds.size());
90 for (
auto const& jo : creds)
100 auto const credS = jo.asString();
127 if ((*sleCred)[sfSubject] != srcAcct)
133 auto [it, ins] = sorted.
emplace((*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
139 lifeExtender.
push_back(std::move(sleCred));
145 bool depositAuthorized =
true;
150 result[jss::source_account] = params[jss::source_account].
asString();
151 result[jss::destination_account] = params[jss::destination_account].
asString();
152 if (credentialsPresent)
153 result[jss::credentials] = params[jss::credentials];
155 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::string expected_field_message(std::string const &name, std::string const &type)
Json::Value missing_field_error(std::string const &name)
void inject_error(error_code_i code, Json::Value &json)
Add or update the json update to reflect the error code.
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 make_error(error_code_i code)
Returns a new json object that reflects the error code.
bool checkExpired(std::shared_ptr< SLE const > 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.
Json::Value doDepositAuthorized(RPC::JsonContext &context)
std::size_t constexpr maxCredentialsArraySize
The maximum number of credentials can be passed in array.
Json::Value rpcError(error_code_i iError)