From 5f6b079c688f29fe5758631393db623a93ae9539 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Wed, 18 Oct 2023 17:24:42 +0100 Subject: [PATCH] Output from tx --- src/ripple/rpc/handlers/Tx.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index 92d0e4dd673..3769f38a05d 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -311,17 +311,41 @@ populateJsonResponse( // no errors else if (result.txn) { - response = result.txn->getJson(JsonOptions::include_date, args.binary); auto const& sttx = result.txn->getSTransaction(); - if (!args.binary) - RPC::insertDeliverMax( - response, sttx->getTxnType(), context.apiVersion); + if (context.apiVersion > 1) + { + std::string hash; + if (args.binary) + response[jss::tx_blob] = result.txn->getJson( + JsonOptions::include_date, true, {std::ref(hash)}); + else + { + response[jss::tx_json] = result.txn->getJson( + JsonOptions::include_date, false, {std::ref(hash)}); + RPC::insertDeliverMax( + response[jss::tx_json], + sttx->getTxnType(), + context.apiVersion); + } + response[jss::hash] = hash; + // TODO set `response[jss::close_time_iso]` + } + else + { + response = + result.txn->getJson(JsonOptions::include_date, args.binary); + if (!args.binary) + RPC::insertDeliverMax( + response, sttx->getTxnType(), context.apiVersion); + } // populate binary metadata if (auto blob = std::get_if(&result.meta)) { assert(args.binary); - response[jss::meta] = strHex(makeSlice(*blob)); + auto json_meta = + (context.apiVersion > 1 ? jss::meta_blob : jss::meta); + response[json_meta] = strHex(makeSlice(*blob)); } // populate meta data else if (auto m = std::get_if>(&result.meta))