rippled
Loading...
Searching...
No Matches
OwnerInfo.cpp
1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/rpc/Context.h>
3
4#include <xrpl/json/json_value.h>
5#include <xrpl/protocol/ErrorCodes.h>
6#include <xrpl/protocol/RPCErr.h>
7#include <xrpl/protocol/jss.h>
8#include <xrpl/server/NetworkOPs.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 const strIdent = context.params.isMember(jss::account)
24 ? context.params[jss::account].asString()
25 : context.params[jss::ident].asString();
26 Json::Value ret;
27
28 // Get info on account.
29 auto const& closedLedger = context.ledgerMaster.getClosedLedger();
30 std::optional<AccountID> const accountID = parseBase58<AccountID>(strIdent);
31 ret[jss::accepted] = accountID.has_value()
32 ? context.netOps.getOwnerInfo(closedLedger, accountID.value())
34
35 auto const& currentLedger = context.ledgerMaster.getCurrentLedger();
36 ret[jss::current] = accountID.has_value()
37 ? context.netOps.getOwnerInfo(currentLedger, *accountID)
39 return ret;
40}
41
42} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
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:231
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Json::Value doOwnerInfo(RPC::JsonContext &context)
Definition OwnerInfo.cpp:16
Json::Value rpcError(error_code_i iError)
Definition RPCErr.cpp:12
@ rpcACT_MALFORMED
Definition ErrorCodes.h:70
T has_value(T... args)
LedgerMaster & ledgerMaster
Definition Context.h:24
NetworkOPs & netOps
Definition Context.h:23
Json::Value params
Definition Context.h:43
T value(T... args)