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>
43 if (txid.
size() != 64)
48 return !std::isxdigit(static_cast<unsigned char>(c));
51 return (ret == txid.
end());
108 constexpr uint16_t MAX_RANGE = 1000;
137 if (
auto e = std::get_if<TxSearched>(&v))
143 auto [txn, meta] = std::get<TxPair>(v);
156 if (txn->getLedger() == 0)
180 org::xrpl::rpc::v1::GetTransactionResponse response;
181 grpc::Status status = grpc::Status::OK;
191 grpc::StatusCode::NOT_FOUND,
192 "txn not found. searched_all = " +
200 status = {grpc::StatusCode::NOT_FOUND,
"txn not found"};
202 status = {grpc::StatusCode::INTERNAL, error.message()};
208 auto& txn = result.
txn;
214 response.set_transaction_binary(s.
data(), s.
size());
221 response.set_hash(context.
params.hash());
223 auto ledgerIndex = txn->getLedger();
224 response.set_ledger_index(ledgerIndex);
230 response.mutable_date()->set_value(
231 ct->time_since_epoch().count());
235 *response.mutable_meta()->mutable_transaction_result(),
237 response.mutable_meta()->mutable_transaction_result()->set_result(
241 if (
auto blob = std::get_if<Blob>(&result.
meta))
245 response.set_meta_binary(slice.
data(), slice.
size());
255 getDeliveredAmount(context, stTxn, *meta, txn->getLedger());
259 *response.mutable_meta()->mutable_delivered_amount(),
264 response.set_validated(result.
validated);
266 return {response, status};
285 response[jss::searched_all] =
287 error.inject(response);
291 error.inject(response);
300 if (
auto blob = std::get_if<Blob>(&result.
meta))
312 insertDeliveredAmount(
313 response[jss::meta], context, result.
txn, *meta);
316 response[jss::validated] = result.
validated;
334 args.
hash = from_hex_text<uint256>(txHash);
363 org::xrpl::rpc::v1::GetTransactionResponse response;
364 grpc::Status status = grpc::Status::OK;
367 org::xrpl::rpc::v1::GetTransactionRequest& request = context.
params;
375 grpc::Status errorStatus{
376 grpc::StatusCode::INVALID_ARGUMENT,
"ledger hash malformed"};
377 return {response, errorStatus};
380 args.
binary = request.binary();
382 if (request.ledger_range().ledger_index_min() != 0 &&
383 request.ledger_range().ledger_index_max() != 0)
386 request.ledger_range().ledger_index_min(),
387 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)
std::shared_ptr< SHAMapItem const > const & peekItem(uint256 const &id) const
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
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
bool getMetaHex(Ledger const &ledger, uint256 const &transID, std::string &hex)
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.
static bool isHexTxID(std::string const &txid)
Json::Value rpcError(int iError, Json::Value jvResult)
Status represents the results of an operation that might fail.
SHAMap const & txMap() const
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
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