xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
handlers
account
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/AccountID.h>
6
#include <xrpl/protocol/ErrorCodes.h>
7
#include <xrpl/protocol/RPCErr.h>
8
#include <xrpl/protocol/jss.h>
9
#include <xrpl/server/NetworkOPs.h>
10
11
#include <
optional
>
12
#include <
string
>
13
14
namespace
xrpl
{
15
16
// {
17
// 'ident' : <indent>,
18
// }
19
json::Value
20
doOwnerInfo
(
rpc::JsonContext
& context)
21
{
22
if
(!context.
params
.
isMember
(jss::account) && !context.
params
.
isMember
(jss::ident))
23
{
24
return
rpc::missingFieldError
(jss::account);
25
}
26
27
std::string
const
strIdent = context.
params
.
isMember
(jss::account)
28
? context.
params
[jss::account].
asString
()
29
: context.
params
[jss::ident].
asString
();
30
json::Value
ret;
31
32
// Get info on account.
33
auto
const
& closedLedger = context.
ledgerMaster
.
getClosedLedger
();
34
std::optional<AccountID>
const
accountID =
parseBase58<AccountID>
(strIdent);
35
ret[jss::accepted] = accountID.
has_value
()
36
? context.
netOps
.
getOwnerInfo
(closedLedger, accountID.
value
())
37
:
rpcError
(
RpcActMalformed
);
38
39
auto
const
& currentLedger = context.
ledgerMaster
.
getCurrentLedger
();
40
ret[jss::current] = accountID.
has_value
()
41
? context.
netOps
.
getOwnerInfo
(currentLedger, *accountID)
42
:
rpcError
(
RpcActMalformed
);
43
return
ret;
44
}
45
46
}
// namespace xrpl
std::string
json::Value
Represents a JSON value.
Definition
json_value.h:117
json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition
json_value.cpp:494
json::Value::isMember
bool isMember(char const *key) const
Return true if the object has a member named key.
Definition
json_value.cpp:1049
xrpl::LedgerMaster::getClosedLedger
std::shared_ptr< Ledger const > getClosedLedger()
The finalized ledger is the last closed/accepted ledger.
Definition
LedgerMaster.h:193
xrpl::LedgerMaster::getCurrentLedger
std::shared_ptr< ReadView const > getCurrentLedger()
The current ledger is the ledger we believe new transactions should go in.
Definition
LedgerMaster.cpp:1594
xrpl::NetworkOPs::getOwnerInfo
virtual json::Value getOwnerInfo(std::shared_ptr< ReadView const > lpLedger, AccountID const &account)=0
xrpl::rpc::missingFieldError
json::Value missingFieldError(std::string const &name)
Definition
ErrorCodes.h:243
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::RpcActMalformed
@ RpcActMalformed
Definition
ErrorCodes.h:73
xrpl::parseBase58
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
Definition
AccountID.cpp:105
xrpl::doOwnerInfo
json::Value doOwnerInfo(rpc::JsonContext &context)
Definition
OwnerInfo.cpp:20
xrpl::rpcError
json::Value rpcError(ErrorCodeI iError)
Definition
RPCErr.cpp:13
std::optional::has_value
T has_value(T... args)
optional
string
xrpl::rpc::Context::netOps
NetworkOPs & netOps
Definition
Context.h:31
xrpl::rpc::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition
Context.h:32
xrpl::rpc::JsonContext
Definition
Context.h:41
xrpl::rpc::JsonContext::params
json::Value params
Definition
Context.h:51
std::optional::value
T value(T... args)
Generated by
1.17.0