20#include <xrpld/app/main/Application.h>
21#include <xrpld/app/misc/TxQ.h>
22#include <xrpld/ledger/ReadView.h>
23#include <xrpld/rpc/Context.h>
24#include <xrpld/rpc/GRPCHandlers.h>
25#include <xrpld/rpc/detail/RPCHelpers.h>
26#include <xrpl/json/json_value.h>
27#include <xrpl/protocol/ErrorCodes.h>
28#include <xrpl/protocol/Indexes.h>
29#include <xrpl/protocol/RPCErr.h>
30#include <xrpl/protocol/UintTypes.h>
31#include <xrpl/protocol/jss.h>
32#include <grpc/status.h>
53 auto& params = context.
params;
56 if (params.isMember(jss::account))
58 if (!params[jss::account].isString())
60 strIdent = params[jss::account].asString();
62 else if (params.isMember(jss::ident))
64 if (!params[jss::ident].isString())
66 strIdent = params[jss::ident].asString();
78 auto id = parseBase58<AccountID>(strIdent);
84 auto const accountID{std::move(
id.value())};
86 static constexpr std::
87 array<std::pair<std::string_view, LedgerSpecificFlags>, 9>
99 static constexpr std::
100 array<std::pair<std::string_view, LedgerSpecificFlags>, 4>
101 disallowIncomingFlags{
102 {{
"disallowIncomingNFTokenOffer",
109 allowTrustLineClawbackFlag{
116 params.isMember(jss::queue) && params[jss::queue].asBool();
118 if (queue && !ledger->open())
128 result[jss::account_data] = jvAccepted;
131 for (
auto const& lsf : lsFlags)
132 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
134 if (ledger->rules().enabled(featureDisallowIncoming))
136 for (
auto const& lsf : disallowIncomingFlags)
137 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
140 if (ledger->rules().enabled(featureClawback))
141 acctFlags[allowTrustLineClawbackFlag.first.data()] =
142 sleAccepted->isFlag(allowTrustLineClawbackFlag.second);
144 result[jss::account_flags] = std::move(acctFlags);
150 if (context.
apiVersion > 1u && params.isMember(jss::signer_lists) &&
151 !params[jss::signer_lists].isBool())
158 if (params.isMember(jss::signer_lists) &&
159 params[jss::signer_lists].asBool())
177 result[jss::account_data][jss::signer_lists] =
178 std::move(jvSignerList);
182 result[jss::signer_lists] = std::move(jvSignerList);
193 jvQueueData[jss::txn_count] =
196 auto& jvQueueTx = jvQueueData[jss::transactions];
205 bool anyAuthChanged =
false;
211 for (
auto const& tx : txs)
215 if (tx.seqProxy.isSeq())
218 prevSeqProxy < tx.seqProxy,
219 "rpple::doAccountInfo : first sorted proxy");
220 prevSeqProxy = tx.seqProxy;
221 jvTx[jss::seq] = tx.seqProxy.value();
224 lowestSeq = tx.seqProxy.
value();
225 highestSeq = tx.seqProxy.
value();
230 prevSeqProxy < tx.seqProxy,
231 "rpple::doAccountInfo : second sorted proxy");
232 prevSeqProxy = tx.seqProxy;
233 jvTx[jss::ticket] = tx.seqProxy.value();
236 lowestTicket = tx.seqProxy.
value();
237 highestTicket = tx.seqProxy.
value();
240 jvTx[jss::fee_level] =
to_string(tx.feeLevel);
242 jvTx[jss::LastLedgerSequence] = *tx.lastValid;
244 jvTx[jss::fee] =
to_string(tx.consequences.fee());
245 auto const spend = tx.consequences.potentialSpend() +
246 tx.consequences.fee();
247 jvTx[jss::max_spend_drops] =
to_string(spend);
249 bool const authChanged = tx.consequences.isBlocker();
251 anyAuthChanged = authChanged;
252 jvTx[jss::auth_change] = authChanged;
254 jvQueueTx.
append(std::move(jvTx));
258 jvQueueData[jss::sequence_count] = seqCount;
260 jvQueueData[jss::ticket_count] = ticketCount;
262 jvQueueData[jss::lowest_sequence] = *lowestSeq;
264 jvQueueData[jss::highest_sequence] = *highestSeq;
266 jvQueueData[jss::lowest_ticket] = *lowestTicket;
268 jvQueueData[jss::highest_ticket] = *highestTicket;
270 jvQueueData[jss::auth_change_queued] = anyAuthChanged;
271 jvQueueData[jss::max_spend_drops_total] =
to_string(totalSpend);
274 jvQueueData[jss::txn_count] = 0u;
276 result[jss::queue_data] = std::move(jvQueueData);
281 result[jss::account] =
toBase58(accountID);
Value & append(const Value &value)
Append value to array at the end.
A type that represents either a sequence value or a ticket value.
static constexpr SeqProxy sequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
std::vector< TxDetails > getAccountTxs(AccountID const &account) const
Returns information about the transactions currently in the queue for the account.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
Json::Value invalid_field_error(std::string const &name)
void injectSLE(Json::Value &jv, SLE const &sle)
Inject JSON describing ledger entry.
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Json::Value missing_field_error(std::string const &name)
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet signers(AccountID const &account) noexcept
A SignerList.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
@ lsfDisallowIncomingCheck
@ lsfAllowTrustLineClawback
@ lsfDisallowIncomingPayChan
@ lsfDisallowIncomingTrustline
@ lsfDisallowIncomingNFTokenOffer
std::string to_string(base_uint< Bits, Tag > const &a)
Json::Value doAccountInfo(RPC::JsonContext &context)