1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCHelpers.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())
34 auto srcID = parseBase58<AccountID>(params[jss::source_account].asString());
37 auto const srcAcct{std::move(srcID.value())};
40 if (!params.
isMember(jss::destination_account))
42 if (!params[jss::destination_account].isString())
48 parseBase58<AccountID>(params[jss::destination_account].asString());
51 auto const dstAcct{std::move(dstID.value())};
77 bool const credentialsPresent = params.
isMember(jss::credentials);
81 if (credentialsPresent)
83 auto const& creds(params[jss::credentials]);
84 if (!creds.isArray() || !creds)
90 "is non-empty array of CredentialID(hash256)"));
97 jss::credentials,
"array too long"));
100 lifeExtender.
reserve(creds.size());
101 for (
auto const& jo : creds)
108 jss::credentials,
"an array of CredentialID(hash256)"));
112 auto const credS = jo.asString();
118 jss::credentials,
"an array of CredentialID(hash256)"));
138 sleCred, ledger->info().parentCloseTime))
145 if ((*sleCred)[sfSubject] != srcAcct)
149 "credentials doesn't belong to the root account",
154 auto [it, ins] = sorted.
emplace(
155 (*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
162 lifeExtender.
push_back(std::move(sleCred));
168 bool depositAuthorized =
true;
172 (credentialsPresent &&
175 result[jss::source_account] = params[jss::source_account].
asString();
176 result[jss::destination_account] =
177 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.
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.