From c4a83d335c7d0296f7713c52441a36e7d50043bb Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 24 Oct 2023 18:24:30 +0000 Subject: [PATCH] Remove inLedger from API version 2 --- src/ripple/app/misc/Transaction.h | 3 ++- src/ripple/app/misc/impl/Transaction.cpp | 5 ++++- src/ripple/rpc/handlers/AccountTx.cpp | 9 ++++++--- src/ripple/rpc/handlers/Tx.cpp | 8 ++++---- src/ripple/rpc/impl/TransactionSign.cpp | 7 ++++--- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/ripple/app/misc/Transaction.h b/src/ripple/app/misc/Transaction.h index 1da21f96011..24849994161 100644 --- a/src/ripple/app/misc/Transaction.h +++ b/src/ripple/app/misc/Transaction.h @@ -27,7 +27,7 @@ #include #include #include -#include + #include #include @@ -310,6 +310,7 @@ class Transaction : public std::enable_shared_from_this, getJson( JsonOptions options, bool binary = false, + bool showInLedger = false, std::optional> hash = {}) const; // Information used to locate a transaction. diff --git a/src/ripple/app/misc/impl/Transaction.cpp b/src/ripple/app/misc/impl/Transaction.cpp index a7667b8c886..c6cd01b7096 100644 --- a/src/ripple/app/misc/impl/Transaction.cpp +++ b/src/ripple/app/misc/impl/Transaction.cpp @@ -168,13 +168,16 @@ Json::Value Transaction::getJson( JsonOptions options, bool binary, + bool showInLedger, std::optional> 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) diff --git a/src/ripple/rpc/handlers/AccountTx.cpp b/src/ripple/rpc/handlers/AccountTx.cpp index 8f130daadf5..dc3e1e3936e 100644 --- a/src/ripple/rpc/handlers/AccountTx.cpp +++ b/src/ripple/rpc/handlers/AccountTx.cpp @@ -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( diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index 16fa7baa8ba..2827256bbd0 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -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(), @@ -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); diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index eb620a03d3e..c5ad5d43957 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -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());