1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
4#include <xrpl/ledger/ReadView.h>
5#include <xrpl/ledger/helpers/CredentialHelpers.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())
35 auto srcID = parseBase58<AccountID>(params[jss::source_account].asString());
38 auto const srcAcct{srcID.value()};
41 if (!params.
isMember(jss::destination_account))
43 if (!params[jss::destination_account].isString())
49 auto dstID = parseBase58<AccountID>(params[jss::destination_account].asString());
52 auto const dstAcct{dstID.value()};
76 bool const reqAuth = ((sleDest->getFlags() & lsfDepositAuth) != 0u) && (srcAcct != dstAcct);
77 bool const credentialsPresent = params.
isMember(jss::credentials);
81 if (credentialsPresent)
83 auto const& creds(params[jss::credentials]);
84 if (!creds.isArray() || !creds)
89 jss::credentials,
"is non-empty array of CredentialID(hash256)"));
97 lifeExtender.
reserve(creds.size());
98 for (
auto const& jo : creds)
105 jss::credentials,
"an array of CredentialID(hash256)"));
109 auto const credS = jo.asString();
115 jss::credentials,
"an array of CredentialID(hash256)"));
125 if ((sleCred->getFlags() & lsfAccepted) == 0u)
137 if ((*sleCred)[sfSubject] != srcAcct)
144 auto [it, ins] = sorted.
emplace((*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
150 lifeExtender.
push_back(std::move(sleCred));
156 bool depositAuthorized =
true;
163 result[jss::source_account] = params[jss::source_account].
asString();
164 result[jss::destination_account] = params[jss::destination_account].
asString();
165 if (credentialsPresent)
166 result[jss::credentials] = params[jss::credentials];
168 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.
std::size_t constexpr maxCredentialsArraySize
The maximum number of credentials can be passed in array.
Json::Value rpcError(error_code_i iError)
Json::Value doDepositAuthorized(RPC::JsonContext &)