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{
112 allowTrustLineLockingFlag{
119 params.isMember(jss::queue) && params[jss::queue].asBool();
121 if (queue && !ledger->open())
131 result[jss::account_data] = jvAccepted;
134 for (
auto const& lsf : lsFlags)
135 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
137 if (ledger->rules().enabled(featureDisallowIncoming))
139 for (
auto const& lsf : disallowIncomingFlags)
140 acctFlags[lsf.first.data()] = sleAccepted->isFlag(lsf.second);
143 if (ledger->rules().enabled(featureClawback))
144 acctFlags[allowTrustLineClawbackFlag.first.data()] =
145 sleAccepted->isFlag(allowTrustLineClawbackFlag.second);
147 if (ledger->rules().enabled(featureTokenEscrow))
148 acctFlags[allowTrustLineLockingFlag.first.data()] =
149 sleAccepted->isFlag(allowTrustLineLockingFlag.second);
151 result[jss::account_flags] = std::move(acctFlags);
157 if (context.
apiVersion > 1u && params.isMember(jss::signer_lists) &&
158 !params[jss::signer_lists].isBool())
165 if (params.isMember(jss::signer_lists) &&
166 params[jss::signer_lists].asBool())
184 result[jss::account_data][jss::signer_lists] =
185 std::move(jvSignerList);
189 result[jss::signer_lists] = std::move(jvSignerList);
200 jvQueueData[jss::txn_count] =
203 auto& jvQueueTx = jvQueueData[jss::transactions];
212 bool anyAuthChanged =
false;
218 for (
auto const& tx : txs)
222 if (tx.seqProxy.isSeq())
225 prevSeqProxy < tx.seqProxy,
226 "rpple::doAccountInfo : first sorted proxy");
227 prevSeqProxy = tx.seqProxy;
228 jvTx[jss::seq] = tx.seqProxy.value();
231 lowestSeq = tx.seqProxy.
value();
232 highestSeq = tx.seqProxy.
value();
237 prevSeqProxy < tx.seqProxy,
238 "rpple::doAccountInfo : second sorted proxy");
239 prevSeqProxy = tx.seqProxy;
240 jvTx[jss::ticket] = tx.seqProxy.value();
243 lowestTicket = tx.seqProxy.
value();
244 highestTicket = tx.seqProxy.
value();
247 jvTx[jss::fee_level] =
to_string(tx.feeLevel);
249 jvTx[jss::LastLedgerSequence] = *tx.lastValid;
251 jvTx[jss::fee] =
to_string(tx.consequences.fee());
252 auto const spend = tx.consequences.potentialSpend() +
253 tx.consequences.fee();
254 jvTx[jss::max_spend_drops] =
to_string(spend);
256 bool const authChanged = tx.consequences.isBlocker();
258 anyAuthChanged = authChanged;
259 jvTx[jss::auth_change] = authChanged;
261 jvQueueTx.
append(std::move(jvTx));
265 jvQueueData[jss::sequence_count] = seqCount;
267 jvQueueData[jss::ticket_count] = ticketCount;
269 jvQueueData[jss::lowest_sequence] = *lowestSeq;
271 jvQueueData[jss::highest_sequence] = *highestSeq;
273 jvQueueData[jss::lowest_ticket] = *lowestTicket;
275 jvQueueData[jss::highest_ticket] = *highestTicket;
277 jvQueueData[jss::auth_change_queued] = anyAuthChanged;
278 jvQueueData[jss::max_spend_drops_total] =
to_string(totalSpend);
281 jvQueueData[jss::txn_count] = 0u;
283 result[jss::queue_data] = std::move(jvQueueData);
288 result[jss::account] =
toBase58(accountID);
Value & append(Value const &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
@ lsfAllowTrustLineLocking
@ lsfDisallowIncomingNFTokenOffer
std::string to_string(base_uint< Bits, Tag > const &a)
Json::Value doAccountInfo(RPC::JsonContext &context)