Skip to content

Commit

Permalink
Remove inLedger from API version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronek committed Oct 25, 2023
1 parent aa7d8ca commit c4a83d3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/ripple/app/misc/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <ripple/protocol/STTx.h>
#include <ripple/protocol/TER.h>
#include <ripple/protocol/TxMeta.h>
#include <boost/optional.hpp>

#include <optional>
#include <variant>

Expand Down Expand Up @@ -310,6 +310,7 @@ class Transaction : public std::enable_shared_from_this<Transaction>,
getJson(
JsonOptions options,
bool binary = false,
bool showInLedger = false,
std::optional<std::reference_wrapper<std::string>> hash = {}) const;

// Information used to locate a transaction.
Expand Down
5 changes: 4 additions & 1 deletion src/ripple/app/misc/impl/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,16 @@ Json::Value
Transaction::getJson(
JsonOptions options,
bool binary,
bool showInLedger,
std::optional<std::reference_wrapper<std::string>> hash) const
{
Json::Value ret(mTransaction->getJson(JsonOptions::none, binary, hash));

if (mInLedger)
{
ret[jss::inLedger] = mInLedger; // Deprecated.
if (showInLedger)
ret[jss::inLedger] = mInLedger; // Deprecated.

ret[jss::ledger_index] = mInLedger;

if (options == JsonOptions::include_date)
Expand Down
9 changes: 6 additions & 3 deletions src/ripple/rpc/handlers/AccountTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,15 @@ populateJsonResponse(
{
std::string hash;
jvObj[json_tx] = txn->getJson(
JsonOptions::include_date, false, {std::ref(hash)});
JsonOptions::include_date,
false,
false,
{std::ref(hash)});
jvObj[jss::hash] = hash;
}
else
jvObj[json_tx] =
txn->getJson(JsonOptions::include_date);
jvObj[json_tx] = txn->getJson(
JsonOptions::include_date, false, true);

auto const& sttx = txn->getSTransaction();
RPC::insertDeliverMax(
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/rpc/handlers/Tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ populateJsonResponse(
std::string hash;
if (args.binary)
response[jss::tx_blob] = result.txn->getJson(
JsonOptions::include_date, true, {std::ref(hash)});
JsonOptions::include_date, true, false, {std::ref(hash)});
else
{
response[jss::tx_json] = result.txn->getJson(
JsonOptions::include_date, false, {std::ref(hash)});
JsonOptions::include_date, false, false, {std::ref(hash)});
RPC::insertDeliverMax(
response[jss::tx_json],
sttx->getTxnType(),
Expand All @@ -345,8 +345,8 @@ populateJsonResponse(
}
else
{
response =
result.txn->getJson(JsonOptions::include_date, args.binary);
response = result.txn->getJson(
JsonOptions::include_date, args.binary, true);
if (!args.binary)
RPC::insertDeliverMax(
response, sttx->getTxnType(), context.apiVersion);
Expand Down
7 changes: 4 additions & 3 deletions src/ripple/rpc/impl/TransactionSign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,13 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion)
if (apiVersion > 1)
{
std::string hash = {};
jvResult[jss::tx_json] =
tpTrans->getJson(JsonOptions::none, false, {std::ref(hash)});
jvResult[jss::tx_json] = tpTrans->getJson(
JsonOptions::none, false, false, {std::ref(hash)});
jvResult[jss::hash] = hash;
}
else
jvResult[jss::tx_json] = tpTrans->getJson(JsonOptions::none);
jvResult[jss::tx_json] =
tpTrans->getJson(JsonOptions::none, false, true);

jvResult[jss::tx_blob] =
strHex(tpTrans->getSTransaction()->getSerializer().peekData());
Expand Down

0 comments on commit c4a83d3

Please sign in to comment.