20#include <xrpld/app/misc/CredentialHelpers.h>
21#include <xrpld/ledger/ReadView.h>
22#include <xrpld/rpc/Context.h>
23#include <xrpld/rpc/detail/RPCHelpers.h>
24#include <xrpl/protocol/ErrorCodes.h>
25#include <xrpl/protocol/Indexes.h>
26#include <xrpl/protocol/RPCErr.h>
27#include <xrpl/protocol/jss.h>
45 if (!params.
isMember(jss::source_account))
47 if (!params[jss::source_account].isString())
52 auto srcID = parseBase58<AccountID>(params[jss::source_account].asString());
55 auto const srcAcct{std::move(srcID.value())};
58 if (!params.
isMember(jss::destination_account))
60 if (!params[jss::destination_account].isString())
66 parseBase58<AccountID>(params[jss::destination_account].asString());
69 auto const dstAcct{std::move(dstID.value())};
95 bool const credentialsPresent = params.
isMember(jss::credentials);
99 if (credentialsPresent)
101 auto const& creds(params[jss::credentials]);
102 if (!creds.isArray() || !creds)
108 "is non-empty array of CredentialID(hash256)"));
115 jss::credentials,
"array too long"));
118 lifeExtender.
reserve(creds.size());
119 for (
auto const& jo : creds)
126 jss::credentials,
"an array of CredentialID(hash256)"));
130 auto const credS = jo.asString();
136 jss::credentials,
"an array of CredentialID(hash256)"));
156 sleCred, ledger->info().parentCloseTime))
163 if ((*sleCred)[sfSubject] != srcAcct)
167 "credentials doesn't belong to the root account",
172 auto [it, ins] = sorted.
emplace(
173 (*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
180 lifeExtender.
push_back(std::move(sleCred));
186 bool depositAuthorized =
true;
190 (credentialsPresent &&
193 result[jss::source_account] = params[jss::source_account].
asString();
194 result[jss::destination_account] =
195 params[jss::destination_account].
asString();
196 if (credentialsPresent)
197 result[jss::credentials] = params[jss::credentials];
199 result[jss::deposit_authorized] = depositAuthorized;
std::string asString() const
Returns the unquoted string value.
bool isMember(const char *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.
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
std::string expected_field_message(std::string const &name, std::string const &type)
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.
Json::Value missing_field_error(std::string const &name)
bool checkExpired(std::shared_ptr< SLE const > const &sleCredential, NetClock::time_point const &closed)
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value rpcError(int iError)
Json::Value doDepositAuthorized(RPC::JsonContext &context)
std::size_t constexpr maxCredentialsArraySize
The maximum number of credentials can be passed in array.