xrpld
Loading...
Searching...
No Matches
TxHistory.cpp
1#include <xrpld/app/main/Application.h>
2#include <xrpld/app/misc/DeliverMax.h>
3#include <xrpld/app/misc/Transaction.h>
4#include <xrpld/rpc/Context.h>
5#include <xrpld/rpc/Role.h>
6
7#include <xrpl/protocol/ErrorCodes.h>
8#include <xrpl/protocol/RPCErr.h>
9#include <xrpl/protocol/jss.h>
10#include <xrpl/rdb/RelationalDatabase.h>
11#include <xrpl/resource/Fees.h>
12
13namespace xrpl {
14
15// {
16// start: <index>
17// }
18json::Value
20{
21 if (!context.app.config().useTxTables())
22 return rpcError(RpcNotEnabled);
23
25
26 if (!context.params.isMember(jss::start))
28
29 unsigned int const startIndex = context.params[jss::start].asUInt();
30
31 if ((startIndex > 10000) && (!isUnlimited(context.role)))
33
34 auto trans = context.app.getRelationalDatabase().getTxHistory(startIndex);
35
36 json::Value obj;
37 json::Value& txs = obj[jss::txs];
38 obj[jss::index] = startIndex;
39
40 for (auto const& t : trans)
41 {
42 json::Value txJson = t->getJson(JsonOptions::Values::None);
43 RPC::insertDeliverMax(txJson, t->getSTransaction()->getTxnType(), context.apiVersion);
44 txs.append(txJson);
45 }
46
47 return obj;
48}
49
50} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Value & append(Value const &value)
Append value to array at the end.
UInt asUInt() const
bool isMember(char const *key) const
Return true if the object has a member named key.
virtual Config & config()=0
bool useTxTables() const
Definition Config.h:322
virtual std::vector< std::shared_ptr< Transaction > > getTxHistory(LedgerIndex startIndex)=0
getTxHistory Returns the 20 most recent transactions starting from the given number.
virtual RelationalDatabase & getRelationalDatabase()=0
void insertDeliverMax(json::Value &txJson, TxType txnType, unsigned int apiVersion)
Copy Amount field to DeliverMax field in transaction output JSON.
Definition DeliverMax.cpp:9
Charge const kFeeMediumBurdenRpc
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ RpcNotEnabled
Definition ErrorCodes.h:41
@ RpcInvalidParams
Definition ErrorCodes.h:66
@ RpcNoPermission
Definition ErrorCodes.h:35
json::Value rpcError(ErrorCodeI iError)
Definition RPCErr.cpp:13
json::Value doTxHistory(RPC::JsonContext &)
Definition TxHistory.cpp:19
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Definition Role.cpp:115
Application & app
Definition Context.h:21
Resource::Charge & loadType
Definition Context.h:22
unsigned int apiVersion
Definition Context.h:29
json::Value params
Definition Context.h:43