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>
25#include <xrpl/protocol/ErrorCodes.h>
26#include <xrpl/protocol/Indexes.h>
27#include <xrpl/protocol/RPCErr.h>
28#include <xrpl/protocol/jss.h>
46 if (!params.
isMember(jss::source_account))
48 if (!params[jss::source_account].isString())
53 auto srcID = parseBase58<AccountID>(params[jss::source_account].asString());
56 auto const srcAcct{std::move(srcID.value())};
59 if (!params.
isMember(jss::destination_account))
61 if (!params[jss::destination_account].isString())
67 parseBase58<AccountID>(params[jss::destination_account].asString());
70 auto const dstAcct{std::move(dstID.value())};
96 bool const credentialsPresent = params.
isMember(jss::credentials);
100 if (credentialsPresent)
102 auto const& creds(params[jss::credentials]);
103 if (!creds.isArray() || !creds)
109 "is non-empty array of CredentialID(hash256)"));
116 jss::credentials,
"array too long"));
119 lifeExtender.
reserve(creds.size());
120 for (
auto const& jo : creds)
127 jss::credentials,
"an array of CredentialID(hash256)"));
131 auto const credS = jo.asString();
137 jss::credentials,
"an array of CredentialID(hash256)"));
157 sleCred, ledger->info().parentCloseTime))
164 if ((*sleCred)[sfSubject] != srcAcct)
168 "credentials doesn't belong to the root account",
173 auto [it, ins] = sorted.
emplace(
174 (*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]);
181 lifeExtender.
push_back(std::move(sleCred));
187 bool depositAuthorized =
true;
191 (credentialsPresent &&
194 result[jss::source_account] = params[jss::source_account].
asString();
195 result[jss::destination_account] =
196 params[jss::destination_account].
asString();
197 if (credentialsPresent)
198 result[jss::credentials] = params[jss::credentials];
200 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.