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>
27#include <xrpl/json/json_value.h>
28#include <xrpl/protocol/ErrorCodes.h>
29#include <xrpl/protocol/Indexes.h>
30#include <xrpl/protocol/UintTypes.h>
31#include <xrpl/protocol/jss.h>
52 auto& params = context.
params;
55 if (params.isMember(jss::account))
57 if (!params[jss::account].isString())
59 strIdent = params[jss::account].asString();
61 else if (params.isMember(jss::ident))
63 if (!params[jss::ident].isString())
65 strIdent = params[jss::ident].asString();
77 auto id = parseBase58<AccountID>(strIdent);
83 auto const accountID{std::move(
id.value())};
85 static constexpr std::
86 array<std::pair<std::string_view, LedgerSpecificFlags>, 9>
98 static constexpr std::
99 array<std::pair<std::string_view, LedgerSpecificFlags>, 4>
100 disallowIncomingFlags{
101 {{
"disallowIncomingNFTokenOffer",
108 allowTrustLineClawbackFlag{
115 params.isMember(jss::queue) && params[jss::queue].asBool();
117 if (queue && !ledger->open())
127 result[jss::account_data] = jvAccepted;
130 for (
auto const& lsf : lsFlags)
131 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
133 if (ledger->rules().enabled(featureDisallowIncoming))
135 for (
auto const& lsf : disallowIncomingFlags)
136 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
139 if (ledger->rules().enabled(featureClawback))
140 acctFlags[allowTrustLineClawbackFlag.first.data()] =
141 sleAccepted->isFlag(allowTrustLineClawbackFlag.second);
143 result[jss::account_flags] = std::move(acctFlags);
149 if (context.
apiVersion > 1u && params.isMember(jss::signer_lists) &&
150 !params[jss::signer_lists].isBool())
157 if (params.isMember(jss::signer_lists) &&
158 params[jss::signer_lists].asBool())
176 result[jss::account_data][jss::signer_lists] =
177 std::move(jvSignerList);
181 result[jss::signer_lists] = std::move(jvSignerList);
192 jvQueueData[jss::txn_count] =
195 auto& jvQueueTx = jvQueueData[jss::transactions];
204 bool anyAuthChanged =
false;
210 for (
auto const& tx : txs)
214 if (tx.seqProxy.isSeq())
217 prevSeqProxy < tx.seqProxy,
218 "rpple::doAccountInfo : first sorted proxy");
219 prevSeqProxy = tx.seqProxy;
220 jvTx[jss::seq] = tx.seqProxy.value();
223 lowestSeq = tx.seqProxy.
value();
224 highestSeq = tx.seqProxy.
value();
229 prevSeqProxy < tx.seqProxy,
230 "rpple::doAccountInfo : second sorted proxy");
231 prevSeqProxy = tx.seqProxy;
232 jvTx[jss::ticket] = tx.seqProxy.value();
235 lowestTicket = tx.seqProxy.
value();
236 highestTicket = tx.seqProxy.
value();
239 jvTx[jss::fee_level] =
to_string(tx.feeLevel);
241 jvTx[jss::LastLedgerSequence] = *tx.lastValid;
243 jvTx[jss::fee] =
to_string(tx.consequences.fee());
244 auto const spend = tx.consequences.potentialSpend() +
245 tx.consequences.fee();
246 jvTx[jss::max_spend_drops] =
to_string(spend);
248 bool const authChanged = tx.consequences.isBlocker();
250 anyAuthChanged = authChanged;
251 jvTx[jss::auth_change] = authChanged;
253 jvQueueTx.
append(std::move(jvTx));
257 jvQueueData[jss::sequence_count] = seqCount;
259 jvQueueData[jss::ticket_count] = ticketCount;
261 jvQueueData[jss::lowest_sequence] = *lowestSeq;
263 jvQueueData[jss::highest_sequence] = *highestSeq;
265 jvQueueData[jss::lowest_ticket] = *lowestTicket;
267 jvQueueData[jss::highest_ticket] = *highestTicket;
269 jvQueueData[jss::auth_change_queued] = anyAuthChanged;
270 jvQueueData[jss::max_spend_drops_total] =
to_string(totalSpend);
273 jvQueueData[jss::txn_count] = 0u;
275 result[jss::queue_data] = std::move(jvQueueData);
280 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)