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 ripple {
11
12// {
13// 'ident' : <indent>,
14// }
17{
18 if (!context.params.isMember(jss::account) &&
19 !context.params.isMember(jss::ident))
20 {
21 return RPC::missing_field_error(jss::account);
22 }
23
24 std::string strIdent = context.params.isMember(jss::account)
25 ? context.params[jss::account].asString()
26 : context.params[jss::ident].asString();
27 Json::Value ret;
28
29 // Get info on account.
30 auto const& closedLedger = context.ledgerMaster.getClosedLedger();
31 std::optional<AccountID> const accountID = parseBase58<AccountID>(strIdent);
32 ret[jss::accepted] = accountID.has_value()
33 ? context.netOps.getOwnerInfo(closedLedger, accountID.value())
35
36 auto const& currentLedger = context.ledgerMaster.getCurrentLedger();
37 ret[jss::current] = accountID.has_value()
38 ? context.netOps.getOwnerInfo(currentLedger, *accountID)
40 return ret;
41}
42
43} // namespace ripple
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< ReadView const > getCurrentLedger()
std::shared_ptr< Ledger const > getClosedLedger()
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:264
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
@ rpcACT_MALFORMED
Definition ErrorCodes.h:71
Json::Value rpcError(int iError)
Definition RPCErr.cpp:12
Json::Value doOwnerInfo(RPC::JsonContext &)
Definition OwnerInfo.cpp:16
T has_value(T... args)
LedgerMaster & ledgerMaster
Definition Context.h:25
NetworkOPs & netOps
Definition Context.h:24
T value(T... args)