rippled
Loading...
Searching...
No Matches
xrpld
rpc
handlers
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
10
namespace
ripple
{
11
12
// {
13
// 'ident' : <indent>,
14
// }
15
Json::Value
16
doOwnerInfo
(
RPC::JsonContext
& context)
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
())
34
:
rpcError
(
rpcACT_MALFORMED
);
35
36
auto
const
& currentLedger = context.
ledgerMaster
.
getCurrentLedger
();
37
ret[jss::current] = accountID.
has_value
()
38
? context.
netOps
.
getOwnerInfo
(currentLedger, *accountID)
39
:
rpcError
(
rpcACT_MALFORMED
);
40
return
ret;
41
}
42
43
}
// namespace ripple
std::string
Json::Value
Represents a JSON value.
Definition
json_value.h:131
Json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition
json_value.cpp:471
Json::Value::isMember
bool isMember(char const *key) const
Return true if the object has a member named key.
Definition
json_value.cpp:1030
ripple::LedgerMaster::getCurrentLedger
std::shared_ptr< ReadView const > getCurrentLedger()
Definition
LedgerMaster.cpp:1540
ripple::LedgerMaster::getClosedLedger
std::shared_ptr< Ledger const > getClosedLedger()
Definition
LedgerMaster.h:60
ripple::NetworkOPs::getOwnerInfo
virtual Json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
ripple::RPC::missing_field_error
Json::Value missing_field_error(std::string const &name)
Definition
ErrorCodes.h:264
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:6
ripple::rpcACT_MALFORMED
@ rpcACT_MALFORMED
Definition
ErrorCodes.h:71
ripple::rpcError
Json::Value rpcError(int iError)
Definition
RPCErr.cpp:12
ripple::doOwnerInfo
Json::Value doOwnerInfo(RPC::JsonContext &)
Definition
OwnerInfo.cpp:16
std::optional::has_value
T has_value(T... args)
std::optional
ripple::RPC::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition
Context.h:25
ripple::RPC::Context::netOps
NetworkOPs & netOps
Definition
Context.h:24
ripple::RPC::JsonContext
Definition
Context.h:34
ripple::RPC::JsonContext::params
Json::Value params
Definition
Context.h:44
std::optional::value
T value(T... args)
Generated by
1.9.8