diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 734f695f..da31da22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -174,7 +174,7 @@ ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool) add_executable(simplewallet ${SIMPLEWALLET}) add_dependencies(simplewallet version) -target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} dl) +target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET) ENABLE_SHARED_PCH_EXECUTABLE(simplewallet) diff --git a/src/common/crypto_serialization.h b/src/common/crypto_serialization.h index 58beb857..ff244deb 100644 --- a/src/common/crypto_serialization.h +++ b/src/common/crypto_serialization.h @@ -86,6 +86,9 @@ BLOB_SERIALIZER(crypto::secret_key); BLOB_SERIALIZER(crypto::key_derivation); BLOB_SERIALIZER(crypto::key_image); BLOB_SERIALIZER(crypto::signature); +BLOB_SERIALIZER(crypto::scalar_t); +BLOB_SERIALIZER(crypto::point_t); + VARIANT_TAG(debug_archive, crypto::hash, "hash"); VARIANT_TAG(debug_archive, crypto::public_key, "public_key"); VARIANT_TAG(debug_archive, crypto::secret_key, "secret_key"); @@ -134,5 +137,15 @@ namespace boost { a & reinterpret_cast(x); } + template + inline void serialize(Archive &a, crypto::scalar_t &x, const boost::serialization::version_type ver) + { + a & reinterpret_cast(x); + } + template + inline void serialize(Archive &a, crypto::point_t &x, const boost::serialization::version_type ver) + { + a & reinterpret_cast(x); + } } // namespace serialization } // namespace boost diff --git a/src/crypto/crypto-sugar.h b/src/crypto/crypto-sugar.h index 2ad22217..96c4873a 100644 --- a/src/crypto/crypto-sugar.h +++ b/src/crypto/crypto-sugar.h @@ -132,7 +132,7 @@ namespace crypto // // scalar_t - holds a 256-bit scalar, normally in [0..L-1] // - struct alignas(32) scalar_t + struct /* TODO alignas(32) */ scalar_t { union { diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 2544a096..3489b306 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -746,6 +746,11 @@ bool blockchain_storage::purge_transaction_keyimages_from_blockchain(const trans { return this->operator()(static_cast(inp)); } + bool operator()(const txin_zarcanum_inputs& inp) const + { + // TODO: #@#@ + return false; + } }; for(const txin_v& in : tx.vin) @@ -1619,13 +1624,13 @@ bool blockchain_storage::purge_keyimage_from_big_heap(const crypto::key_image& k return true; } //------------------------------------------------------------------ -bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& id) +bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& block_id) { if (is_pos_block(b)) { CHECK_AND_ASSERT_MES(b.miner_tx.vin.size()>=2, false, "paranoid check failed"); CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(txin_to_key), false, "paranoid type check failed"); - purge_keyimage_from_big_heap(boost::get(b.miner_tx.vin[1]).k_image, id); + purge_keyimage_from_big_heap(boost::get(b.miner_tx.vin[1]).k_image, block_id); } for (auto tx_id : b.tx_hashes) { @@ -1639,7 +1644,14 @@ bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, { if (tx.vin[n].type() == typeid(txin_to_key) || tx.vin[n].type() == typeid(txin_htlc)) { - purge_keyimage_from_big_heap(get_to_key_input_from_txin_v(tx.vin[n]).k_image, id); + purge_keyimage_from_big_heap(get_to_key_input_from_txin_v(tx.vin[n]).k_image, block_id); + } + else if (tx.vin[n].type() == typeid(txin_zarcanum_inputs)) + { + // TODO @#@# consider refactoring + const txin_zarcanum_inputs& zins = boost::get(tx.vin[n]); + for(const auto& el : zins.elements) + purge_keyimage_from_big_heap(el.key_image, block_id); } } } @@ -2622,6 +2634,9 @@ bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, const //------------------------------------------------------------------ bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, uint64_t global_index, bool spent) { + if (amount == 0) + return true; // fallback for hidden amounts + CRITICAL_REGION_LOCAL(m_read_lock); uint64_t outs_count = m_db_outputs.get_item_size(amount); CHECK_AND_ASSERT_MES(outs_count, false, "Amount " << amount << " have not found during update_spent_tx_flags_for_input()"); @@ -3863,10 +3878,9 @@ namespace currency m_bl_height(bl_height), m_mixins_count(mixins_count) {} - bool operator()(const txin_to_key& in) const - { - const crypto::key_image& ki = in.k_image; + bool visit(uint64_t amount, const crypto::key_image& ki, const std::vector& key_offsets) const + { auto ki_ptr = m_db_spent_keys.get(ki); if (ki_ptr) { @@ -3876,20 +3890,25 @@ namespace currency } m_db_spent_keys.set(ki, m_bl_height); - if (in.key_offsets.size() == 1) + if (key_offsets.size() == 1) { //direct spend detected - if (!m_bcs.update_spent_tx_flags_for_input(in.amount, in.key_offsets[0], true)) + if (!m_bcs.update_spent_tx_flags_for_input(amount, key_offsets[0], true)) { //internal error LOG_PRINT_RED_L0("Failed to update_spent_tx_flags_for_input"); return false; } } - if (m_mixins_count < in.key_offsets.size()) - m_mixins_count = in.key_offsets.size(); + if (m_mixins_count < key_offsets.size()) + m_mixins_count = key_offsets.size(); return true; } + + bool operator()(const txin_to_key& in) const + { + return visit(in.amount, in.k_image, in.key_offsets); + } bool operator()(const txin_htlc& in) const { if (!m_bcs.is_hardfork_active(3)) @@ -3911,6 +3930,16 @@ namespace currency } return true; } + bool operator()(const txin_zarcanum_inputs& in) const + { + // TODO: @#@# should check for hardfork here? + for(auto& el : in.elements) + { + if (!visit(0, el.key_image, el.key_offsets)) + return false; + } + return true; + } }; } @@ -4260,6 +4289,15 @@ bool blockchain_storage::have_tx_keyimges_as_spent(const transaction &tx) const if (is_multisig_output_spent(boost::get(in).multisig_out_id)) return true; } + else if (in.type() == typeid(txin_zarcanum_inputs)) + { + const auto& zins = boost::get(in); + for(auto& el: zins.elements) + { + if (have_tx_keyimg_as_spent(el.key_image)) + return true; + } + } else if (in.type() == typeid(txin_gen)) { // skip txin_gen @@ -4863,12 +4901,29 @@ std::shared_ptr blockchain_storage::find_key_imag { if (get_to_key_input_from_txin_v(in).k_image == ki) { - id_result = get_transaction_hash(tx_chain_entry->tx); + id_result = get_transaction_hash(tx_chain_entry->tx); // ??? @#@# why not just use tx_id ? return tx_chain_entry; } } + else if (in.type() == typeid(txin_zarcanum_inputs)) + { + const auto& zins = boost::get(in); + for(auto& el: zins.elements) + { + if (el.key_image == ki) + { + id_result = tx_id; + return tx_chain_entry; + } + } + } } } + + // got here, but found nothing -- log such suspicious event + CHECK_AND_ASSERT_THROW_MES(block_entry != nullptr, "invalid block_entry"); + LOG_PRINT_YELLOW("find_key_image_and_related_tx: failed to find key image " << ki << " in block " << get_block_hash(block_entry->bl), LOG_LEVEL_1); + return std::shared_ptr(); } //------------------------------------------------------------------ @@ -5015,6 +5070,12 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti return true; }; + auto is_allowed_before_hardfork4 = [&](const payload_items_v& el) -> bool + { + CHECK_AND_ASSERT_MES(el.type() != typeid(zarcanum_tx_data_v1), false, "tx " << tx_id << " contains zarcanum_tx_data_v1 which is not allowed on height " << block_height); + return true; + }; + bool var_is_after_hardfork_1_zone = m_core_runtime_config.is_hardfork_active_for_height(1, block_height); bool var_is_after_hardfork_2_zone = m_core_runtime_config.is_hardfork_active_for_height(2, block_height); bool var_is_after_hardfork_3_zone = m_core_runtime_config.is_hardfork_active_for_height(3, block_height); @@ -5023,17 +5084,22 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti //inputs for (const auto in : tx.vin) { - if (in.type() == typeid(txin_htlc)) - { + VARIANT_SWITCH_BEGIN(in); + VARIANT_CASE_CONST(txin_htlc, in_htlc) if (!var_is_after_hardfork_3_zone) return false; - } + VARIANT_CASE_CONST(txin_zarcanum_inputs, in_zins) + if (!var_is_after_hardfork_4_zone) + return false; + VARIANT_SWITCH_END(); } //outputs for (const auto out : tx.vout) { VARIANT_SWITCH_BEGIN(out); VARIANT_CASE_CONST(tx_out_bare, o) + if (var_is_after_hardfork_4_zone) + return false; // bare outputs are not allowed after HF4 if (o.target.type() == typeid(txout_htlc)) { if (!var_is_after_hardfork_3_zone) @@ -5052,6 +5118,8 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti return false; if (!var_is_after_hardfork_2_zone && !is_allowed_before_hardfork2(el)) return false; + if (!var_is_after_hardfork_4_zone && !is_allowed_before_hardfork4(el)) + return false; } //attachments diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 39156314..6179aa98 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -588,7 +588,7 @@ namespace currency bool handle_alternative_block(const block& b, const crypto::hash& id, block_verification_context& bvc); bool is_reorganize_required(const block_extended_info& main_chain_bei, const alt_chain_type& alt_chain, const crypto::hash& proof_alt); wide_difficulty_type get_x_difficulty_after_height(uint64_t height, bool is_pos); - bool purge_keyimage_from_big_heap(const crypto::key_image& ki, const crypto::hash& id); + bool purge_keyimage_from_big_heap(const crypto::key_image& ki, const crypto::hash& block_id); bool purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& id); bool append_altblock_keyimages_to_big_heap(const crypto::hash& block_id, const std::unordered_set& alt_block_keyimages); bool validate_alt_block_input(const transaction& input_tx, diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index e0ff6f82..b7c1de14 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -219,7 +219,7 @@ namespace currency { uint64_t amount; crypto::key_image k_image; // double spending protection - std::vector etc_details; //this flag used when TX_FLAG_SIGNATURE_MODE_SEPARATE flag is set, point to which amount of outputs(starting from zero) used in signature + std::vector etc_details; // see also TX_FLAG_SIGNATURE_MODE_SEPARATE BEGIN_SERIALIZE_OBJECT() VARINT_FIELD(amount) @@ -253,35 +253,6 @@ namespace currency END_SERIALIZE() }; -#pragma pack(push, 1) - struct tx_in_zarcanum : public referring_input - { - tx_in_zarcanum() {} - - // Boost's Assignable concept - tx_in_zarcanum(const tx_in_zarcanum&) = default; - tx_in_zarcanum& operator=(const tx_in_zarcanum&)= default; - - crypto::key_image key_image; - crypto::public_key real_out_amount_commitment; - std::vector etc_details; - - BEGIN_SERIALIZE_OBJECT() - FIELD(key_image) - FIELD(real_out_amount_commitment) - FIELD(key_offsets) // referring_input - FIELD(etc_details) - END_SERIALIZE() - - BEGIN_BOOST_SERIALIZATION() - BOOST_SERIALIZE(key_image) - BOOST_SERIALIZE(real_out_amount_commitment) - BOOST_SERIALIZE(key_offsets) // referring_input - BOOST_SERIALIZE(etc_details) - END_BOOST_SERIALIZATION() - }; -#pragma pack(pop) - struct txout_multisig { @@ -313,8 +284,6 @@ namespace currency END_SERIALIZE() }; - typedef boost::variant txin_v; - typedef boost::variant txout_target_v; //typedef std::pair out_t; @@ -330,7 +299,53 @@ namespace currency }; -#pragma pack(push, 1) + ///////////////////////////////////////////////////////////////////////////// + // Zarcanum structures + // + //#pragma pack(push, 1) + struct zarcanum_input : public referring_input + { + zarcanum_input() {} + // Boost's Assignable concept + zarcanum_input(const zarcanum_input&) = default; + zarcanum_input& operator=(const zarcanum_input&)= default; + + crypto::key_image key_image; + + BEGIN_SERIALIZE_OBJECT() + FIELD(key_image) + FIELD(key_offsets) // referring_input + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(key_image) + BOOST_SERIALIZE(key_offsets) // referring_input + END_BOOST_SERIALIZATION() + }; + + // txin_zarcanum_inputs contains several zarcanum_input instances and corresponds to one zarcanum_sig + struct txin_zarcanum_inputs + { + txin_zarcanum_inputs() {} + + // Boost's Assignable concept + txin_zarcanum_inputs(const txin_zarcanum_inputs&) = default; + txin_zarcanum_inputs& operator=(const txin_zarcanum_inputs&) = default; + + std::vector elements; + std::vector etc_details; + + BEGIN_SERIALIZE_OBJECT() + FIELD(elements) + FIELD(etc_details) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(elements) + BOOST_SERIALIZE(etc_details) + END_BOOST_SERIALIZATION() + }; + struct tx_out_zarcanum { tx_out_zarcanum() {} @@ -340,28 +355,71 @@ namespace currency tx_out_zarcanum& operator=(const tx_out_zarcanum&) = default; crypto::public_key stealth_address; - crypto::public_key concealing_point; - crypto::public_key commitment; + crypto::public_key concealing_point; // group element Q, see also Zarcanum paper + crypto::public_key amount_commitment; uint64_t encrypted_amount; - uint64_t token_id = 0; + //crypto::public_key token_masked_generator; BEGIN_SERIALIZE_OBJECT() FIELD(stealth_address) FIELD(concealing_point) - FIELD(commitment) + FIELD(amount_commitment) FIELD(encrypted_amount) - FIELD(token_id) END_SERIALIZE() BEGIN_BOOST_SERIALIZATION() BOOST_SERIALIZE(stealth_address) BOOST_SERIALIZE(concealing_point) - BOOST_SERIALIZE(commitment) + BOOST_SERIALIZE(amount_commitment) BOOST_SERIALIZE(encrypted_amount) - BOOST_SERIALIZE(token_id) END_BOOST_SERIALIZATION() }; -#pragma pack(pop) + + struct zarcanum_tx_data_v1 + { + uint64_t fee; + + BEGIN_SERIALIZE_OBJECT() + FIELD(fee) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(fee) + END_BOOST_SERIALIZATION() + }; + + struct zarcanum_sig + { + struct input_proofs_t + { + crypto::public_key real_out_amount_commitment; + // crypto::public_key real_out_token_masked_generator; + + BEGIN_SERIALIZE_OBJECT() + FIELD(real_out_amount_commitment) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(real_out_amount_commitment) + END_BOOST_SERIALIZATION() + }; + + crypto::bpp_signature_serialized outputs_range_proof; // aggregated range proof for some or all outputs + std::vector input_proofs; // for each input + + BEGIN_SERIALIZE_OBJECT() + FIELD(outputs_range_proof) + FIELD(input_proofs) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(outputs_range_proof) + BOOST_SERIALIZE(input_proofs) + END_BOOST_SERIALIZATION() + }; +//#pragma pack(pop) + + typedef boost::variant txin_v; typedef boost::variant tx_out_v; @@ -628,10 +686,10 @@ namespace currency END_SERIALIZE() }; - typedef boost::mpl::vector21< + typedef boost::mpl::vector22< tx_service_attachment, tx_comment, tx_payer_old, tx_receiver_old, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time, etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry_old, extra_user_data, extra_padding, etc_tx_flags16_t, etc_tx_details_unlock_time2, - tx_payer, tx_receiver, extra_alias_entry + tx_payer, tx_receiver, extra_alias_entry, zarcanum_tx_data_v1 > all_payload_types; typedef boost::make_variant_over::type payload_items_v; @@ -639,21 +697,7 @@ namespace currency typedef payload_items_v attachment_v; - struct zarcanum_tx_data_v1 - { - uint64_t fee; - std::vector range_proofs_for_outputs; - BEGIN_SERIALIZE_OBJECT() - FIELD(fee) - FIELD(range_proofs_for_outputs) - END_SERIALIZE() - - BEGIN_BOOST_SERIALIZATION() - BOOST_SERIALIZE(fee) - BOOST_SERIALIZE(range_proofs_for_outputs) - END_BOOST_SERIALIZATION() - }; //classic CryptoNote signature by Nicolas Van Saberhagen struct NLSAG_sig @@ -669,16 +713,6 @@ namespace currency END_BOOST_SERIALIZATION() }; - struct zarcanum_sig - { - //TODO: - BEGIN_SERIALIZE_OBJECT() - END_SERIALIZE() - - BEGIN_BOOST_SERIALIZATION() - END_BOOST_SERIALIZATION() - }; - //TODO: @val, should we call it something like schnorr_sig ? struct simple_sig { @@ -963,7 +997,7 @@ SET_VARIANT_TAGS(currency::txout_htlc, 35, "txout_htlc"); SET_VARIANT_TAGS(currency::tx_out_bare, 36, "tx_out_bare"); // Zarcanum -SET_VARIANT_TAGS(currency::tx_in_zarcanum, 37, "tx_in_zarcanum"); +SET_VARIANT_TAGS(currency::txin_zarcanum_inputs, 37, "txin_zarcanum_inputs"); SET_VARIANT_TAGS(currency::tx_out_zarcanum, 38, "tx_out_zarcanum"); SET_VARIANT_TAGS(currency::zarcanum_tx_data_v1, 39, "zarcanum_tx_data_v1"); SET_VARIANT_TAGS(crypto::bpp_signature_serialized, 40, "bpp_signature_serialized"); diff --git a/src/currency_core/currency_boost_serialization.h b/src/currency_core/currency_boost_serialization.h index b25b1b10..5d52d2ff 100644 --- a/src/currency_core/currency_boost_serialization.h +++ b/src/currency_core/currency_boost_serialization.h @@ -115,7 +115,7 @@ namespace boost { a & x.stealth_address; a & x.concealing_point; - a & x.commitment; + a & x.amount_commitment; a & x.encrypted_amount; } diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 66bc4c8f..41716cfc 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2605,9 +2605,9 @@ namespace currency pfinalbuff = &deflated_buff; } if (ee.service_id == BC_PAYMENT_ID_SERVICE_ID || ee.service_id == BC_OFFERS_SERVICE_ID) - tv.datails_view = *pfinalbuff; + tv.details_view = *pfinalbuff; else - tv.datails_view = "BINARY DATA"; + tv.details_view = "BINARY DATA"; } return true; } @@ -2615,7 +2615,7 @@ namespace currency { tv.type = "crypto_checksum"; tv.short_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash); - tv.datails_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n" + tv.details_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n" + "encrypted_key_derivation: " + epee::string_tools::pod_to_hex(ee.encrypted_key_derivation); return true; @@ -2676,14 +2676,14 @@ namespace currency { tv.type = "attachment_info"; tv.short_view = std::to_string(ee.sz) + " bytes"; - tv.datails_view = currency::obj_to_json_str(ee); + tv.details_view = currency::obj_to_json_str(ee); return true; } bool operator()(const extra_alias_entry& ee) { tv.type = "alias_info"; tv.short_view = ee.m_alias + "-->" + get_account_address_as_str(ee.m_address); - tv.datails_view = currency::obj_to_json_str(ee); + tv.details_view = currency::obj_to_json_str(ee); return true; } @@ -2695,7 +2695,7 @@ namespace currency { tv.type = "user_data"; tv.short_view = std::to_string(ee.buff.size()) + " bytes"; - tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff); + tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff); return true; } @@ -2704,7 +2704,7 @@ namespace currency tv.type = "extra_padding"; tv.short_view = std::to_string(ee.buff.size()) + " bytes"; if (!ee.buff.empty()) - tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast(&ee.buff[0]), ee.buff.size())); + tv.details_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast(&ee.buff[0]), ee.buff.size())); return true; } @@ -2712,7 +2712,7 @@ namespace currency { tv.type = "comment"; tv.short_view = std::to_string(ee.comment.size()) + " bytes(encrypted)"; - tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment); + tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment); return true; } @@ -2750,7 +2750,7 @@ namespace currency { tv.type = "derivation_hint"; tv.short_view = std::to_string(ee.msg.size()) + " bytes"; - tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg); + tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg); return true; } @@ -2758,7 +2758,7 @@ namespace currency { tv.type = "string"; tv.short_view = std::to_string(ee.size()) + " bytes"; - tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee); + tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee); return true; } @@ -2766,10 +2766,17 @@ namespace currency { tv.type = "FLAGS16"; tv.short_view = epee::string_tools::pod_to_hex(dh); - tv.datails_view = epee::string_tools::pod_to_hex(dh); + tv.details_view = epee::string_tools::pod_to_hex(dh); return true; } + bool operator()(const zarcanum_tx_data_v1& ztxd) + { + tv.type = "zarcanum_tx_data_v1"; + tv.short_view = "fee = " + print_money_brief(ztxd.fee); + tv.details_view = tv.short_view; + return true; + } }; //------------------------------------------------------------------ template diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 701bd267..e09ea0fe 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -374,21 +374,21 @@ namespace currency std::string get_word_from_timstamp(uint64_t timestamp, bool use_password); uint64_t get_timstamp_from_word(std::string word, bool& password_used); std::string generate_origin_for_htlc(const txout_htlc& htlc, const account_keys& acc_keys); + template typename std::conditional::value, const std::vector, std::vector >::type& get_txin_etc_options(t_txin_v& in) { static typename std::conditional::value, const std::vector, std::vector >::type stub; - - //static stub; - if (in.type() == typeid(txin_to_key)) return boost::get(in).etc_details; - else if (in.type() == typeid(txin_htlc)) - return boost::get(in).etc_details; else if (in.type() == typeid(txin_multisig)) return boost::get(in).etc_details; - else + else if (in.type() == typeid(txin_htlc)) + return boost::get(in).etc_details; + else if (in.type() == typeid(txin_zarcanum_inputs)) + return boost::get(in).etc_details; + else return stub; } @@ -663,45 +663,42 @@ namespace currency { struct txin_signature_size_visitor : public boost::static_visitor { - size_t operator()(const txin_gen& /*txin*/) const { return 0; } - size_t operator()(const txin_to_key& txin) const { return txin.key_offsets.size(); } - size_t operator()(const txin_multisig& txin) const { return txin.sigs_count; } - size_t operator()(const txin_htlc& txin) const { return 1; } - size_t operator()(const tx_in_zarcanum& txin) const { throw std::runtime_error("Not implemented yet"); return 0; } //@#@ + size_t operator()(const txin_gen& /*txin*/) const { return 0; } + size_t operator()(const txin_to_key& txin) const { return txin.key_offsets.size(); } + size_t operator()(const txin_multisig& txin) const { return txin.sigs_count; } + size_t operator()(const txin_htlc& txin) const { return 1; } + size_t operator()(const txin_zarcanum_inputs& txin) const { throw std::runtime_error("Not implemented yet"); } }; return boost::apply_visitor(txin_signature_size_visitor(), tx_in); } //--------------------------------------------------------------- - inline const std::vector* get_input_etc_details(const txin_v& in) + template + typename std::conditional::value, const std::vector, std::vector >::type* + get_input_etc_details(txin_t& in) { - if (in.type().hash_code() == typeid(txin_to_key).hash_code()) + if (in.type() == typeid(txin_to_key)) return &boost::get(in).etc_details; - if (in.type().hash_code() == typeid(txin_htlc).hash_code()) - return &boost::get(in).etc_details; - if (in.type().hash_code() == typeid(txin_multisig).hash_code()) + if (in.type() == typeid(txin_multisig)) return &boost::get(in).etc_details; + if (in.type() == typeid(txin_htlc)) + return &boost::get(in).etc_details; + if (in.type() == typeid(txin_zarcanum_inputs)) + return &boost::get(in).etc_details; return nullptr; } //--------------------------------------------------------------- - inline std::vector* get_input_etc_details(txin_v& in) - { - if (in.type().hash_code() == typeid(txin_to_key).hash_code()) - return &boost::get(in).etc_details; - if (in.type().hash_code() == typeid(txin_htlc).hash_code()) - return &boost::get(in).etc_details; - if (in.type().hash_code() == typeid(txin_multisig).hash_code()) - return &boost::get(in).etc_details; - return nullptr; - } - //--------------------------------------------------------------- - struct input_amount_getter : public boost::static_visitor { template - uint64_t operator()(const t_input& i) const{return i.amount;} - uint64_t operator()(const txin_gen& i) const {return 0;} + uint64_t operator()(const t_input& i) const { return i.amount; } + uint64_t operator()(const txin_zarcanum_inputs&) const { return 0; } + uint64_t operator()(const txin_gen& i) const { return 0; } }; + inline uint64_t get_amount_from_variant(const txin_v& v) + { + return boost::apply_visitor(input_amount_getter(), v); + } //--------------------------------------------------------------- inline const tx_out_bare& get_tx_out_bare_from_out_v(const tx_out_v& o) { @@ -709,11 +706,6 @@ namespace currency return boost::get(o); } //--------------------------------------------------------------- - inline uint64_t get_amount_from_variant(const txin_v& v) - { - return boost::apply_visitor(input_amount_getter(), v); - } - //--------------------------------------------------------------- template void create_and_add_tx_payer_to_container_from_address(container_t& container, const account_public_address& addr, uint64_t top_block_height, const core_runtime_config& crc) { diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 3edc5c57..298d3ed9 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1217,11 +1217,11 @@ namespace currency { std::string type; std::string short_view; - std::string datails_view; + std::string details_view; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(type) KV_SERIALIZE(short_view) - KV_SERIALIZE(datails_view) + KV_SERIALIZE(details_view) END_KV_SERIALIZE_MAP() };