From fc1383324a80475a792ee0eaa425bb4123daee10 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 10 Aug 2023 13:09:04 +0200 Subject: [PATCH] minor improvement for fill_tx_rpc_inputs() --- src/currency_core/blockchain_storage.cpp | 25 ++++++++++++++++++++++-- src/currency_core/blockchain_storage.h | 1 - src/rpc/core_rpc_server_commands_defs.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 88cc16fb..f6c6ae81 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -5211,7 +5211,6 @@ bool blockchain_storage::fill_tx_rpc_inputs(tx_rpc_extended_info& tei, const tra { entry_to_fill.htlc_origin = epee::string_tools::buff_to_hex_nodelimer(boost::get(in).hltc_origin); } - //tk.etc_details -> visualize it may be later } else if (in.type() == typeid(txin_multisig)) { @@ -5223,8 +5222,30 @@ bool blockchain_storage::fill_tx_rpc_inputs(tx_rpc_extended_info& tei, const tra { entry_to_fill.multisig_count = boost::get(tx.signatures[tei.ins.size() - 1]).s.size(); } - } + + const std::vector& etc_options = get_txin_etc_options(in); + for (size_t i = 0; i < etc_options.size(); ++i) + { + std::stringstream ss; + if (etc_options[i].type() == typeid(signed_parts)) + { + const auto& sp = boost::get(etc_options[i]); + ss << "n_outs: " << sp.n_outs << ", n_extras: " << sp.n_extras; + entry_to_fill.etc_options.push_back(ss.str()); + } + else if (etc_options[i].type() == typeid(extra_attachment_info)) + { + const auto& eai = boost::get(etc_options[i]); + ss << "cnt: " << eai.cnt << ", sz: " << eai.sz << ", hsh: " << eai.hsh; + entry_to_fill.etc_options.push_back(ss.str()); + } + else + { + entry_to_fill.etc_options.push_back("unknown type"); + } + } + } return true; } diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 2e63a802..992ab6a9 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -636,7 +636,6 @@ namespace currency bool check_block_timestamp_main(const block& b)const; bool check_block_timestamp(std::vector timestamps, const block& b)const; std::vector get_last_n_blocks_timestamps(size_t n)const; - const std::vector& get_txin_etc_options(const txin_v& in)const; void on_block_added(const block_extended_info& bei, const crypto::hash& id, const std::list& bsk); void on_block_removed(const block_extended_info& bei); void update_targetdata_cache_on_block_added(const block_extended_info& bei); diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 59cd7cf8..885fa313 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1191,12 +1191,14 @@ namespace currency std::string htlc_origin; std::string kimage_or_ms_id; std::vector global_indexes; + std::vector etc_options; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amount) KV_SERIALIZE(htlc_origin) KV_SERIALIZE(kimage_or_ms_id) KV_SERIALIZE(global_indexes) KV_SERIALIZE(multisig_count) + KV_SERIALIZE(etc_options) END_KV_SERIALIZE_MAP() };