From 6ce24769f6adce8991eac5e32ceec7fec8e9741d Mon Sep 17 00:00:00 2001 From: WeebDataHoarder Date: Fri, 5 Dec 2025 17:56:57 +0100 Subject: [PATCH] remove deserialization and serialization code for txout_to_script, txout_to_scripthash, txin_to_script, txin_to_scripthash entirely as they have never been used removed gen_tx_output_is_not_txout_to_key test --- src/cryptonote_basic/cryptonote_basic.h | 65 +-------- .../cryptonote_boost_serialization.h | 31 ---- src/cryptonote_core/blockchain.cpp | 8 -- src/serialization/json_object.cpp | 134 ------------------ src/serialization/json_object.h | 12 -- tests/core_tests/tx_validation.cpp | 47 +----- 6 files changed, 5 insertions(+), 292 deletions(-) diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h index 127958796..3fef40cab 100644 --- a/src/cryptonote_basic/cryptonote_basic.h +++ b/src/cryptonote_basic/cryptonote_basic.h @@ -58,22 +58,6 @@ namespace cryptonote /* outputs */ - struct txout_to_script - { - std::vector keys; - std::vector script; - - BEGIN_SERIALIZE_OBJECT() - FIELD(keys) - FIELD(script) - END_SERIALIZE() - }; - - struct txout_to_scripthash - { - crypto::hash hash; - }; - // outputs <= HF_VERSION_VIEW_TAGS struct txout_to_key { @@ -107,34 +91,6 @@ namespace cryptonote END_SERIALIZE() }; - struct txin_to_script - { - crypto::hash prev; - size_t prevout; - std::vector sigset; - - BEGIN_SERIALIZE_OBJECT() - FIELD(prev) - VARINT_FIELD(prevout) - FIELD(sigset) - END_SERIALIZE() - }; - - struct txin_to_scripthash - { - crypto::hash prev; - size_t prevout; - txout_to_script script; - std::vector sigset; - - BEGIN_SERIALIZE_OBJECT() - FIELD(prev) - VARINT_FIELD(prevout) - FIELD(script) - FIELD(sigset) - END_SERIALIZE() - }; - struct txin_to_key { uint64_t amount; @@ -149,9 +105,9 @@ namespace cryptonote }; - typedef boost::variant txin_v; + typedef boost::variant txin_v; - typedef boost::variant txout_target_v; + typedef boost::variant txout_target_v; //typedef std::pair out_t; struct tx_out @@ -441,8 +397,6 @@ namespace cryptonote 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_script& txin) const{return 0;} - size_t operator()(const txin_to_scripthash& txin) const{return 0;} size_t operator()(const txin_to_key& txin) const {return txin.key_offsets.size();} }; @@ -567,36 +521,25 @@ namespace std { } BLOB_SERIALIZER(cryptonote::txout_to_key); -BLOB_SERIALIZER(cryptonote::txout_to_scripthash); VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff); -VARIANT_TAG(binary_archive, cryptonote::txin_to_script, 0x0); -VARIANT_TAG(binary_archive, cryptonote::txin_to_scripthash, 0x1); +// deprecated tags used to be here VARIANT_TAG(binary_archive, cryptonote::txin_to_key, 0x2); -VARIANT_TAG(binary_archive, cryptonote::txout_to_script, 0x0); -VARIANT_TAG(binary_archive, cryptonote::txout_to_scripthash, 0x1); +// deprecated tags used to be here VARIANT_TAG(binary_archive, cryptonote::txout_to_key, 0x2); VARIANT_TAG(binary_archive, cryptonote::txout_to_tagged_key, 0x3); VARIANT_TAG(binary_archive, cryptonote::transaction, 0xcc); VARIANT_TAG(binary_archive, cryptonote::block, 0xbb); VARIANT_TAG(json_archive, cryptonote::txin_gen, "gen"); -VARIANT_TAG(json_archive, cryptonote::txin_to_script, "script"); -VARIANT_TAG(json_archive, cryptonote::txin_to_scripthash, "scripthash"); VARIANT_TAG(json_archive, cryptonote::txin_to_key, "key"); -VARIANT_TAG(json_archive, cryptonote::txout_to_script, "script"); -VARIANT_TAG(json_archive, cryptonote::txout_to_scripthash, "scripthash"); VARIANT_TAG(json_archive, cryptonote::txout_to_key, "key"); VARIANT_TAG(json_archive, cryptonote::txout_to_tagged_key, "tagged_key"); VARIANT_TAG(json_archive, cryptonote::transaction, "tx"); VARIANT_TAG(json_archive, cryptonote::block, "block"); VARIANT_TAG(debug_archive, cryptonote::txin_gen, "gen"); -VARIANT_TAG(debug_archive, cryptonote::txin_to_script, "script"); -VARIANT_TAG(debug_archive, cryptonote::txin_to_scripthash, "scripthash"); VARIANT_TAG(debug_archive, cryptonote::txin_to_key, "key"); -VARIANT_TAG(debug_archive, cryptonote::txout_to_script, "script"); -VARIANT_TAG(debug_archive, cryptonote::txout_to_scripthash, "scripthash"); VARIANT_TAG(debug_archive, cryptonote::txout_to_key, "key"); VARIANT_TAG(debug_archive, cryptonote::txout_to_tagged_key, "tagged_key"); VARIANT_TAG(debug_archive, cryptonote::transaction, "tx"); diff --git a/src/cryptonote_basic/cryptonote_boost_serialization.h b/src/cryptonote_basic/cryptonote_boost_serialization.h index 493c9d91d..d49aa7fc1 100644 --- a/src/cryptonote_basic/cryptonote_boost_serialization.h +++ b/src/cryptonote_basic/cryptonote_boost_serialization.h @@ -92,14 +92,6 @@ namespace boost a & reinterpret_cast(x); } - template - inline void serialize(Archive &a, cryptonote::txout_to_script &x, const boost::serialization::version_type ver) - { - a & x.keys; - a & x.script; - } - - template inline void serialize(Archive &a, cryptonote::txout_to_key &x, const boost::serialization::version_type ver) { @@ -113,35 +105,12 @@ namespace boost a & x.view_tag; } - template - inline void serialize(Archive &a, cryptonote::txout_to_scripthash &x, const boost::serialization::version_type ver) - { - a & x.hash; - } - template inline void serialize(Archive &a, cryptonote::txin_gen &x, const boost::serialization::version_type ver) { a & x.height; } - template - inline void serialize(Archive &a, cryptonote::txin_to_script &x, const boost::serialization::version_type ver) - { - a & x.prev; - a & x.prevout; - a & x.sigset; - } - - template - inline void serialize(Archive &a, cryptonote::txin_to_scripthash &x, const boost::serialization::version_type ver) - { - a & x.prev; - a & x.prevout; - a & x.script; - a & x.sigset; - } - template inline void serialize(Archive &a, cryptonote::txin_to_key &x, const boost::serialization::version_type ver) { diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index d35f4ccfe..1684718cc 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2888,14 +2888,6 @@ bool Blockchain::check_for_double_spend(const transaction& tx, key_images_contai { return true; } - bool operator()(const txin_deprecated_0& tx) const - { - return false; - } - bool operator()(const txin_deprecated_1& tx) const - { - return false; - } }; for (const txin_v& in : tx.vin) diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp index 8580f93b8..4706b2641 100644 --- a/src/serialization/json_object.cpp +++ b/src/serialization/json_object.cpp @@ -356,14 +356,6 @@ void toJsonValue(rapidjson::Writer& dest, const cryptonote::t { INSERT_INTO_JSON_OBJECT(dest, gen, input); } - void operator()(cryptonote::txin_to_script const& input) const - { - INSERT_INTO_JSON_OBJECT(dest, to_script, input); - } - void operator()(cryptonote::txin_to_scripthash const& input) const - { - INSERT_INTO_JSON_OBJECT(dest, to_scripthash, input); - } }; boost::apply_visitor(add_input{dest}, txin); dest.EndObject(); @@ -396,18 +388,6 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_v& txin) fromJsonValue(elem.value, tmpVal); txin = std::move(tmpVal); } - else if (elem.name == "to_script") - { - cryptonote::txin_to_script tmpVal; - fromJsonValue(elem.value, tmpVal); - txin = std::move(tmpVal); - } - else if (elem.name == "to_scripthash") - { - cryptonote::txin_to_scripthash tmpVal; - fromJsonValue(elem.value, tmpVal); - txin = std::move(tmpVal); - } } } @@ -430,57 +410,6 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_gen& txin) GET_FROM_JSON_OBJECT(val, txin.height, height); } -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_script& txin) -{ - dest.StartObject(); - - INSERT_INTO_JSON_OBJECT(dest, prev, txin.prev); - INSERT_INTO_JSON_OBJECT(dest, prevout, txin.prevout); - INSERT_INTO_JSON_OBJECT(dest, sigset, txin.sigset); - - dest.EndObject(); -} - - -void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_script& txin) -{ - if (!val.IsObject()) - { - throw WRONG_TYPE("json object"); - } - - GET_FROM_JSON_OBJECT(val, txin.prev, prev); - GET_FROM_JSON_OBJECT(val, txin.prevout, prevout); - GET_FROM_JSON_OBJECT(val, txin.sigset, sigset); -} - - -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_scripthash& txin) -{ - dest.StartObject(); - - INSERT_INTO_JSON_OBJECT(dest, prev, txin.prev); - INSERT_INTO_JSON_OBJECT(dest, prevout, txin.prevout); - INSERT_INTO_JSON_OBJECT(dest, script, txin.script); - INSERT_INTO_JSON_OBJECT(dest, sigset, txin.sigset); - - dest.EndObject(); -} - - -void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_scripthash& txin) -{ - if (!val.IsObject()) - { - throw WRONG_TYPE("json object"); - } - - GET_FROM_JSON_OBJECT(val, txin.prev, prev); - GET_FROM_JSON_OBJECT(val, txin.prevout, prevout); - GET_FROM_JSON_OBJECT(val, txin.script, script); - GET_FROM_JSON_OBJECT(val, txin.sigset, sigset); -} - void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_key& txin) { dest.StartObject(); @@ -504,49 +433,6 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_key& txin) GET_FROM_JSON_OBJECT(val, txin.k_image, key_image); } - -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_script& txout) -{ - dest.StartObject(); - - INSERT_INTO_JSON_OBJECT(dest, keys, txout.keys); - INSERT_INTO_JSON_OBJECT(dest, script, txout.script); - - dest.EndObject(); -} - -void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_script& txout) -{ - if (!val.IsObject()) - { - throw WRONG_TYPE("json object"); - } - - GET_FROM_JSON_OBJECT(val, txout.keys, keys); - GET_FROM_JSON_OBJECT(val, txout.script, script); -} - - -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_scripthash& txout) -{ - dest.StartObject(); - - INSERT_INTO_JSON_OBJECT(dest, hash, txout.hash); - - dest.EndObject(); -} - -void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_scripthash& txout) -{ - if (!val.IsObject()) - { - throw WRONG_TYPE("json object"); - } - - GET_FROM_JSON_OBJECT(val, txout.hash, hash); -} - - void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_key& txout) { dest.StartObject(); @@ -606,14 +492,6 @@ void toJsonValue(rapidjson::Writer& dest, const cryptonote::t { INSERT_INTO_JSON_OBJECT(dest, to_tagged_key, output); } - void operator()(cryptonote::txout_to_script const& output) const - { - INSERT_INTO_JSON_OBJECT(dest, to_script, output); - } - void operator()(cryptonote::txout_to_scripthash const& output) const - { - INSERT_INTO_JSON_OBJECT(dest, to_scripthash, output); - } }; boost::apply_visitor(add_output{dest}, txout.target); dest.EndObject(); @@ -650,18 +528,6 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_out& txout) fromJsonValue(elem.value, tmpVal); txout.target = std::move(tmpVal); } - else if (elem.name == "to_script") - { - cryptonote::txout_to_script tmpVal; - fromJsonValue(elem.value, tmpVal); - txout.target = std::move(tmpVal); - } - else if (elem.name == "to_scripthash") - { - cryptonote::txout_to_scripthash tmpVal; - fromJsonValue(elem.value, tmpVal); - txout.target = std::move(tmpVal); - } } } diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h index bbcde9bf6..ae5581383 100644 --- a/src/serialization/json_object.h +++ b/src/serialization/json_object.h @@ -209,24 +209,12 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_v& txin); void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_gen& txin); void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_gen& txin); -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_script& txin); -void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_script& txin); - -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_scripthash& txin); -void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_scripthash& txin); - void toJsonValue(rapidjson::Writer& dest, const cryptonote::txin_to_key& txin); void fromJsonValue(const rapidjson::Value& val, cryptonote::txin_to_key& txin); void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_target_v& txout); void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_target_v& txout); -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_script& txout); -void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_script& txout); - -void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_scripthash& txout); -void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_scripthash& txout); - void toJsonValue(rapidjson::Writer& dest, const cryptonote::txout_to_key& txout); void fromJsonValue(const rapidjson::Value& val, cryptonote::txout_to_key& txout); diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp index 207a1d9da..5434cd2e7 100644 --- a/tests/core_tests/tx_validation.cpp +++ b/tests/core_tests/tx_validation.cpp @@ -301,10 +301,7 @@ bool gen_tx_input_is_not_txin_to_key::generate(std::vector& ev }; DO_CALLBACK(events, "mark_invalid_tx"); - events.push_back(make_tx_with_input(txin_to_script())); - - DO_CALLBACK(events, "mark_invalid_tx"); - events.push_back(make_tx_with_input(txin_to_scripthash())); + events.push_back(make_tx_with_input(txin_to_key())); return true; } @@ -715,48 +712,6 @@ bool gen_tx_output_with_zero_amount::generate(std::vector& eve return true; } -bool gen_tx_output_is_not_txout_to_key::generate(std::vector& events) const -{ - uint64_t ts_start = 1338224400; - - GENERATE_ACCOUNT(miner_account); - MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); - REWIND_BLOCKS(events, blk_0r, blk_0, miner_account); - - std::vector sources; - std::vector destinations; - fill_tx_sources_and_destinations(events, blk_0, miner_account, miner_account, MK_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations); - - tx_builder builder; - builder.step1_init(); - builder.step2_fill_inputs(miner_account.get_keys(), sources); - - builder.m_tx.vout.push_back(tx_out()); - builder.m_tx.vout.back().amount = 1; - builder.m_tx.vout.back().target = txout_to_script(); - - builder.step4_calc_hash(); - builder.step5_sign(sources); - - DO_CALLBACK(events, "mark_invalid_tx"); - events.push_back(builder.m_tx); - - builder.step1_init(); - builder.step2_fill_inputs(miner_account.get_keys(), sources); - - builder.m_tx.vout.push_back(tx_out()); - builder.m_tx.vout.back().amount = 1; - builder.m_tx.vout.back().target = txout_to_scripthash(); - - builder.step4_calc_hash(); - builder.step5_sign(sources); - - DO_CALLBACK(events, "mark_invalid_tx"); - events.push_back(builder.m_tx); - - return true; -} - bool gen_tx_signatures_are_invalid::generate(std::vector& events) const { uint64_t ts_start = 1338224400; -- 2.51.0