rippled
Loading...
Searching...
No Matches
OwnerInfo.cpp
1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/misc/NetworkOPs.h>
3#include <xrpld/rpc/Context.h>
4
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/RPCErr.h>
8#include <xrpl/protocol/jss.h>
9
10namespace xrpl {
11
12// {
13// 'ident' : <indent>,
14// }
17{
18 if (!context.params.isMember(jss::account) && !context.params.isMember(jss::ident))
19 {
20 return RPC::missing_field_error(jss::account);
21 }
22
23 std::string strIdent = context.params.isMember(jss::account) ? context.params[jss::account].asString()
24 : context.params[jss::ident].asString();
25 Json::Value ret;
26
27 // Get info on account.
28 auto const& closedLedger = context.ledgerMaster.getClosedLedger();
29 std::optional<AccountID> const accountID = parseBase58<AccountID>(strIdent);
30 ret[jss::accepted] = accountID.has_value() ? context.netOps.getOwnerInfo(closedLedger, accountID.value())
32
33 auto const& currentLedger = context.ledgerMaster.getCurrentLedger();
34 ret[jss::current] =
35 accountID.has_value() ? context.netOps.getOwnerInfo(currentLedger, *accountID) : rpcError(rpcACT_MALFORMED);
36 return ret;
37}
38
39} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
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.
std::shared_ptr< Ledger const > getClosedLedger()
std::shared_ptr< ReadView const > getCurrentLedger()
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
Json::Value missing_field_error(std::string const &name)
Definition ErrorCodes.h:227
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value doOwnerInfo(RPC::JsonContext &)
Definition OwnerInfo.cpp:16
Json::Value rpcError(error_code_i iError)
Definition RPCErr.cpp:12
@ rpcACT_MALFORMED
Definition ErrorCodes.h:71
T has_value(T... args)
LedgerMaster & ledgerMaster
Definition Context.h:25
NetworkOPs & netOps
Definition Context.h:24
Json::Value params
Definition Context.h:44
T value(T... args)