1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/misc/Transaction.h>
3#include <xrpld/rpc/Context.h>
4#include <xrpld/rpc/Role.h>
5#include <xrpld/rpc/detail/TransactionSign.h>
7#include <xrpl/basics/Slice.h>
8#include <xrpl/basics/StringUtilities.h>
9#include <xrpl/basics/safe_cast.h>
10#include <xrpl/basics/strHex.h>
11#include <xrpl/json/json_value.h>
12#include <xrpl/protocol/ErrorCodes.h>
13#include <xrpl/protocol/RPCErr.h>
14#include <xrpl/protocol/STTx.h>
15#include <xrpl/protocol/Serializer.h>
16#include <xrpl/protocol/TER.h>
17#include <xrpl/protocol/XRPAmount.h>
18#include <xrpl/protocol/jss.h>
19#include <xrpl/resource/Fees.h>
20#include <xrpl/tx/apply.h>
29static std::expected<NetworkOPs::FailHard, json::Value>
53 return failType.error();
67 ret[jss::deprecated] =
68 "Signing support in the 'submit' command has been "
69 "deprecated and will be removed in a future version "
70 "of the server. Please migrate to a standalone "
80 if (!ret || ret->empty())
93 jvResult[jss::error] =
"invalidTransaction";
94 jvResult[jss::error_exception] = e.
what();
109 jvResult[jss::error] =
"invalidTransaction";
110 jvResult[jss::error_exception] =
"fails local checks: " + reason;
120 jvResult[jss::error] =
"invalidTransaction";
121 jvResult[jss::error_exception] =
"fails local checks: " + reason;
130 return failType.error();
136 jvResult[jss::error] =
"internalSubmit";
137 jvResult[jss::error_exception] = e.
what();
145 jvResult[jss::tx_blob] =
strHex(transaction->getSTransaction()->getSerializer().peekData());
154 jvResult[jss::engine_result] = sToken;
155 jvResult[jss::engine_result_code] = transaction->getResult();
156 jvResult[jss::engine_result_message] = sHuman;
158 auto const submitResult = transaction->getSubmitResult();
160 jvResult[jss::accepted] = submitResult.any();
161 jvResult[jss::applied] = submitResult.applied;
162 jvResult[jss::broadcast] = submitResult.broadcast;
163 jvResult[jss::queued] = submitResult.queued;
164 jvResult[jss::kept] = submitResult.kept;
166 if (
auto currentLedgerState = transaction->getCurrentLedgerState())
168 jvResult[jss::account_sequence_next] =
170 jvResult[jss::account_sequence_available] =
172 jvResult[jss::open_ledger_cost] =
to_string(currentLedgerState->minFeeRequired);
173 jvResult[jss::validated_ledger_index] =
182 jvResult[jss::error] =
"internalJson";
183 jvResult[jss::error_exception] = e.
what();
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
virtual Config & config()=0
virtual bool checkSigs() const =0
std::chrono::seconds getValidatedLedgerAge()
std::shared_ptr< ReadView const > getCurrentLedger()
static FailHard doFailHard(bool noMeansDont)
virtual void processTransaction(std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, FailHard failType)=0
Process transactions as they arrive from the network or which are submitted by clients.
virtual HashRouter & getHashRouter()=0
json::Value makeError(ErrorCodeI code)
Returns a new json object that reflects the error code.
json::Value transactionSubmit(json::Value jvRequest, unsigned apiVersion, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app, ProcessTransactionFn const &processTransaction)
Returns a json::ValueType::Object.
ProcessTransactionFn getProcessTxnFn(NetworkOPs &netOPs)
json::Value expectedFieldError(std::string const &name, std::string const &type)
Charge const kFeeMediumBurdenRpc
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ Valid
Signature and local checks are good / passed.
@ SigGoodOnly
Signature is good, but local checks fail.
std::string strHex(FwdIt begin, FwdIt end)
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules)
Checks transaction signature and local checks.
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safeCast(Src s) noexcept
bool transResultInfo(TER code, std::string &token, std::string &text)
std::string to_string(BaseUInt< Bits, Tag > const &a)
json::Value rpcError(ErrorCodeI iError)
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
static std::expected< NetworkOPs::FailHard, json::Value > getFailHard(RPC::JsonContext const &context)
void forceValidity(HashRouter &router, uint256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
json::Value doSubmit(RPC::JsonContext &)
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)
Resource::Charge & loadType
LedgerMaster & ledgerMaster