From 973eefe5f931bf3e7db8d8d621320f6f2b0880b1 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Thu, 13 Jun 2024 05:39:45 +0400 Subject: [PATCH] Fix getmempooltxs --- src/rpc/misc.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 53b1c816c3..7212672a85 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1532,7 +1532,7 @@ UniValue getmempooltxs(const JSONRPCRequest& request) UniValue txids = find_value(request.params[0].get_obj(), "txids"); - UniValue result(UniValue::VARR); + UniValue result(UniValue::VOBJ); for(UniValue const & element : txids.getValues()){ uint256 txid; txid.SetHex(element.get_str()); @@ -1540,8 +1540,9 @@ UniValue getmempooltxs(const JSONRPCRequest& request) if (tx == nullptr || !tx->IsSparkTransaction()) continue; - UniValue data(UniValue::VARR); + UniValue data(UniValue::VOBJ); std::vector lTags_; + UniValue lTags_json(UniValue::VARR); if (tx->IsSparkSpend()) { try { @@ -1559,21 +1560,27 @@ UniValue getmempooltxs(const JSONRPCRequest& request) } else { lTags_.push_back("MintTX"); } - data.push_backV(lTags_); // Spend lTags for corresponding tx, + lTags_json.push_backV(lTags_); - std::vector serial_context = spark::getSerialContext(*tx); - data.push_back(EncodeBase64(serial_context.data(), serial_context.size())); // spark serial context + data.push_back(Pair("lTags ", lTags_json)); // Spend lTags for corresponding tx, + std::vector serial_context = spark::getSerialContext(*tx); + UniValue serial_context_json(UniValue::VARR); + serial_context_json.push_back(EncodeBase64(serial_context.data(), serial_context.size())); + data.push_back(Pair("Serial_context", serial_context_json)); // spark serial context std::vector coins = spark::GetSparkMintCoins(*tx); std::vector serialized_coins; + UniValue serialized_json(UniValue::VARR); for (auto& coin: coins) { CDataStream serializedCoin(SER_NETWORK, PROTOCOL_VERSION); serializedCoin << coin; std::vector vch(serializedCoin.begin(), serializedCoin.end()); serialized_coins.push_back(EncodeBase64(vch.data(), size_t(vch.size()))); // coi } - data.push_backV(serialized_coins); + serialized_json.push_backV(serialized_coins); + data.push_back(Pair("Coins", serialized_json)); + result.push_back(Pair(EncodeBase64(txid.begin(), txid.size()), data)); }