20#include <xrpld/app/ledger/LedgerMaster.h>
21#include <xrpld/app/ledger/TransactionMaster.h>
22#include <xrpld/app/misc/DeliverMax.h>
23#include <xrpld/app/misc/NetworkOPs.h>
24#include <xrpld/app/misc/Transaction.h>
25#include <xrpld/app/rdb/RelationalDatabase.h>
26#include <xrpld/rpc/CTID.h>
27#include <xrpld/rpc/Context.h>
28#include <xrpld/rpc/DeliveredAmount.h>
29#include <xrpld/rpc/GRPCHandlers.h>
30#include <xrpld/rpc/MPTokenIssuanceID.h>
31#include <xrpld/rpc/detail/RPCHelpers.h>
33#include <xrpl/basics/ToString.h>
34#include <xrpl/protocol/ErrorCodes.h>
35#include <xrpl/protocol/NFTSyntheticSerializer.h>
36#include <xrpl/protocol/RPCErr.h>
37#include <xrpl/protocol/jss.h>
83 constexpr uint16_t MAX_RANGE = 1000;
106 args.
ctid->first, args.
ctid->second);
144 if (txn->getLedger() == 0)
152 if (ledger && !ledger->open())
159 result.
meta = meta->getAsObject().getSerializer().getData();
166 context.
ledgerMaster, ledger->info().seq, ledger->info().hash);
172 if (meta->getAsObject().isFieldPresent(sfTransactionIndex))
174 uint32_t lgrSeq = ledger->info().seq;
176 meta->getAsObject().getFieldU32(sfTransactionIndex);
179 if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL)
204 response[jss::searched_all] =
206 error.inject(response);
210 error.inject(response);
219 constexpr auto optionsJson =
222 response[jss::tx_blob] = result.
txn->
getJson(optionsJson,
true);
225 response[jss::tx_json] = result.
txn->
getJson(optionsJson);
227 response[jss::tx_json],
242 response[jss::close_time_iso] =
252 response, sttx->getTxnType(), context.
apiVersion);
259 args.
binary,
"ripple::populateJsonResponse : binary is set");
261 (context.
apiVersion > 1 ? jss::meta_blob : jss::meta);
271 insertDeliveredAmount(
272 response[jss::meta], context, result.
txn, *meta);
277 response[jss::validated] = result.
validated;
280 response[jss::ctid] = *(result.
ctid);
313 auto const [lgr_seq, txn_idx, net_id] = *ctid;
317 out <<
"Wrong network. You should submit this request to a node "
318 "running on NetworkID: "
322 args.
ctid = {lgr_seq, txn_idx};
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 LedgerMaster & getLedgerMaster()=0
virtual TransactionMaster & getMasterTransaction()=0
std::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
std::optional< uint256 > txnIdFromIndex(uint32_t ledgerSeq, uint32_t txnIndex)
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
std::variant< std::pair< std::shared_ptr< Transaction >, std::shared_ptr< TxMeta > >, TxSearched > fetch(uint256 const &, error_code_i &ec)
LedgerIndex getLedger() const
std::shared_ptr< STTx const > const & getSTransaction()
Json::Value getJson(JsonOptions options, bool binary=false) const
uint256 const & getID() const
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ objectValue
object value (collection of name/value pairs).
std::optional< std::string > encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID) noexcept
Encodes ledger sequence, transaction index, and network ID into a CTID string.
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
void insertNFTSyntheticInJson(Json::Value &, std::shared_ptr< STTx const > const &, TxMeta const &)
Adds common synthetic fields to transaction-related JSON responses.
void insertMPTokenIssuanceID(Json::Value &response, std::shared_ptr< STTx const > const &transaction, TxMeta const &transactionMeta)
void insertDeliverMax(Json::Value &tx_json, TxType txnType, unsigned int apiVersion)
Copy Amount field to DeliverMax field in transaction output JSON.
std::optional< std::tuple< uint32_t, uint16_t, uint16_t > > decodeCTID(T const ctid) noexcept
Decodes a CTID string or integer into its component parts.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::pair< TxResult, RPC::Status > doTxHelp(RPC::Context &context, TxArgs args)
Json::Value doTxJson(RPC::JsonContext &)
Json::Value rpcError(int iError)
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
std::string strHex(FwdIt begin, FwdIt end)
static bool isValidated(LedgerMaster &ledgerMaster, std::uint32_t seq, uint256 const &hash)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
std::string to_string_iso(date::sys_time< Duration > tp)
Json::Value populateJsonResponse(std::pair< AccountTxResult, RPC::Status > const &res, AccountTxArgs const &args, RPC::JsonContext const &context)
std::string to_string(base_uint< Bits, Tag > const &a)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
@ ledgerMaster
ledger master data for signing
The context of information needed to call an RPC.
LedgerMaster & ledgerMaster
Status represents the results of an operation that might fail.
std::optional< std::pair< uint32_t, uint16_t > > ctid
std::optional< uint256 > hash
std::optional< std::pair< uint32_t, uint32_t > > ledgerRange
std::variant< std::shared_ptr< TxMeta >, Blob > meta
std::optional< NetClock::time_point > closeTime
std::optional< std::string > ctid
std::optional< uint256 > ledgerHash