20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/TransactionMaster.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/misc/Transaction.h>
24 #include <ripple/basics/ToString.h>
25 #include <ripple/net/RPCErr.h>
26 #include <ripple/protocol/ErrorCodes.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/DeliveredAmount.h>
30 #include <ripple/rpc/GRPCHandlers.h>
31 #include <ripple/rpc/impl/GRPCHelpers.h>
32 #include <ripple/rpc/impl/RPCHelpers.h>
76 constexpr uint16_t MAX_RANGE = 1000;
105 if (
auto e = std::get_if<TxSearched>(&v))
111 auto [txn, meta] = std::get<TxPair>(v);
124 if (txn->getLedger() == 0)
148 org::xrpl::rpc::v1::GetTransactionResponse response;
149 grpc::Status status = grpc::Status::OK;
159 grpc::StatusCode::NOT_FOUND,
160 "txn not found. searched_all = " +
168 status = {grpc::StatusCode::NOT_FOUND,
"txn not found"};
170 status = {grpc::StatusCode::INTERNAL, error.message()};
176 auto& txn = result.
txn;
182 response.set_transaction_binary(s.
data(), s.
size());
189 response.set_hash(context.
params.hash());
191 auto ledgerIndex = txn->getLedger();
192 response.set_ledger_index(ledgerIndex);
198 response.mutable_date()->set_value(
199 ct->time_since_epoch().count());
203 *response.mutable_meta()->mutable_transaction_result(),
205 response.mutable_meta()->mutable_transaction_result()->set_result(
209 if (
auto blob = std::get_if<Blob>(&result.
meta))
213 response.set_meta_binary(slice.
data(), slice.
size());
223 getDeliveredAmount(context, stTxn, *meta, txn->getLedger());
227 *response.mutable_meta()->mutable_delivered_amount(),
232 response.set_validated(result.
validated);
234 return {response, status};
253 response[jss::searched_all] =
255 error.inject(response);
259 error.inject(response);
268 if (
auto blob = std::get_if<Blob>(&result.
meta))
280 insertDeliveredAmount(
281 response[jss::meta], context, result.
txn, *meta);
284 response[jss::validated] = result.
validated;
329 org::xrpl::rpc::v1::GetTransactionResponse response;
330 grpc::Status status = grpc::Status::OK;
333 org::xrpl::rpc::v1::GetTransactionRequest& request = context.
params;
341 grpc::Status errorStatus{
342 grpc::StatusCode::INVALID_ARGUMENT,
"ledger hash malformed"};
343 return {response, errorStatus};
346 args.
binary = request.binary();
348 if (request.ledger_range().ledger_index_min() != 0 &&
349 request.ledger_range().ledger_index_max() != 0)
352 request.ledger_range().ledger_index_min(),
353 request.ledger_range().ledger_index_max());
std::size_t size() const noexcept
Returns the number of bytes in the storage.
@ ledgerMaster
ledger master data for signing
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)
Json::Value getJson(JsonOptions options, bool binary=false) const
An immutable linear range of bytes.
std::pair< org::xrpl::rpc::v1::GetAccountTransactionHistoryResponse, grpc::Status > populateProtoResponse(std::pair< AccountTxResult, RPC::Status > const &res, AccountTxArgs const &args, RPC::GRPCContext< org::xrpl::rpc::v1::GetAccountTransactionHistoryRequest > const &context)
LedgerMaster & ledgerMaster
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Serializer getSerializer() const
std::string transToken(TER code)
std::string to_string(ListDisposition disposition)
constexpr static std::size_t size()
void const * data() const noexcept
Integers of any length that is a multiple of 32-bits.
LedgerInfo const & info() const override
Returns information about the ledger.
void convert(org::xrpl::rpc::v1::TransactionResult &to, TER from)
@ objectValue
object value (collection of name/value pairs).
virtual LedgerMaster & getLedgerMaster()=0
std::optional< std::pair< uint32_t, uint32_t > > ledgerRange
std::pair< org::xrpl::rpc::v1::GetTransactionResponse, grpc::Status > doTxGrpc(RPC::GRPCContext< org::xrpl::rpc::v1::GetTransactionRequest > &context)
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
bool isMember(const char *key) const
Return true if the object has a member named key.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Json::Value rpcError(int iError, Json::Value jvResult)
Status represents the results of an operation that might fail.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value populateJsonResponse(std::pair< AccountTxResult, RPC::Status > const &res, AccountTxArgs const &args, RPC::JsonContext const &context)
std::size_t size() const noexcept
bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
std::pair< TxResult, RPC::Status > doTxHelp(RPC::Context &context, TxArgs const &args)
boost::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
static base_uint fromVoid(void const *data)
Json::Value doTxJson(RPC::JsonContext &)
std::variant< std::shared_ptr< TxMeta >, Blob > meta
std::variant< std::pair< std::shared_ptr< Transaction >, std::shared_ptr< TxMeta > >, TxSearched > fetch(uint256 const &, error_code_i &ec)
std::string strHex(FwdIt begin, FwdIt end)
boost::icl::closed_interval< T > ClosedInterval
A closed interval over the domain T.
static bool isValidated(LedgerMaster &ledgerMaster, std::uint32_t seq, uint256 const &hash)
The context of information needed to call an RPC.
std::string asString() const
Returns the unquoted string value.
virtual TransactionMaster & getMasterTransaction()=0