rippled
Loading...
Searching...
No Matches
xrpld
rpc
handlers
OwnerInfo.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012-2014 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#include <xrpld/app/ledger/LedgerMaster.h>
21
#include <xrpld/app/misc/NetworkOPs.h>
22
#include <xrpld/rpc/Context.h>
23
24
#include <xrpl/json/json_value.h>
25
#include <xrpl/protocol/ErrorCodes.h>
26
#include <xrpl/protocol/RPCErr.h>
27
#include <xrpl/protocol/jss.h>
28
29
namespace
ripple
{
30
31
// {
32
// 'ident' : <indent>,
33
// }
34
Json::Value
35
doOwnerInfo
(
RPC::JsonContext
& context)
36
{
37
if
(!context.
params
.
isMember
(jss::account) &&
38
!context.
params
.
isMember
(jss::ident))
39
{
40
return
RPC::missing_field_error
(jss::account);
41
}
42
43
std::string
strIdent = context.
params
.
isMember
(jss::account)
44
? context.
params
[jss::account].
asString
()
45
: context.
params
[jss::ident].
asString
();
46
Json::Value
ret;
47
48
// Get info on account.
49
auto
const
& closedLedger = context.
ledgerMaster
.
getClosedLedger
();
50
std::optional<AccountID>
const
accountID = parseBase58<AccountID>(strIdent);
51
ret[jss::accepted] = accountID.
has_value
()
52
? context.
netOps
.
getOwnerInfo
(closedLedger, accountID.
value
())
53
:
rpcError
(
rpcACT_MALFORMED
);
54
55
auto
const
& currentLedger = context.
ledgerMaster
.
getCurrentLedger
();
56
ret[jss::current] = accountID.
has_value
()
57
? context.
netOps
.
getOwnerInfo
(currentLedger, *accountID)
58
:
rpcError
(
rpcACT_MALFORMED
);
59
return
ret;
60
}
61
62
}
// namespace ripple
std::string
Json::Value
Represents a JSON value.
Definition
json_value.h:149
Json::Value::asString
std::string asString() const
Returns the unquoted string value.
Definition
json_value.cpp:493
Json::Value::isMember
bool isMember(char const *key) const
Return true if the object has a member named key.
Definition
json_value.cpp:989
ripple::LedgerMaster::getCurrentLedger
std::shared_ptr< ReadView const > getCurrentLedger()
Definition
LedgerMaster.cpp:1559
ripple::LedgerMaster::getClosedLedger
std::shared_ptr< Ledger const > getClosedLedger()
Definition
LedgerMaster.h:79
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:283
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:25
ripple::rpcACT_MALFORMED
@ rpcACT_MALFORMED
Definition
ErrorCodes.h:90
ripple::rpcError
Json::Value rpcError(int iError)
Definition
RPCErr.cpp:31
ripple::doOwnerInfo
Json::Value doOwnerInfo(RPC::JsonContext &)
Definition
OwnerInfo.cpp:35
std::optional::has_value
T has_value(T... args)
std::optional
ripple::RPC::Context::ledgerMaster
LedgerMaster & ledgerMaster
Definition
Context.h:44
ripple::RPC::Context::netOps
NetworkOPs & netOps
Definition
Context.h:43
ripple::RPC::JsonContext
Definition
Context.h:53
ripple::RPC::JsonContext::params
Json::Value params
Definition
Context.h:63
std::optional::value
T value(T... args)
Generated by
1.9.8