diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index 7a7a9a5..c64f170 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -233,7 +233,8 @@ namespace cryptonote END_SERIALIZE() }; - typedef boost::variant txin_v; + typedef boost::variant txin_v; + typedef boost::variant txin_zephyr_v; typedef boost::variant txout_target_v; typedef boost::variant txout_xhv_target_v; @@ -293,6 +294,7 @@ namespace cryptonote uint64_t unlock_time; //number of block (or time), used as a limitation like: spend this tx not early then block/time std::vector vin; + std::vector vin_zephyr; std::vector vout; std::vector vout_xhv; std::vector vout_zephyr; @@ -334,7 +336,10 @@ namespace cryptonote } if (blob_type != BLOB_TYPE_CRYPTONOTE_XHV || version < POU_TRANSACTION_VERSION) VARINT_FIELD(unlock_time) - FIELD(vin) + if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) + FIELD(vin_zephyr) + else + FIELD(vin) if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) FIELD(vout_zephyr) @@ -437,7 +442,13 @@ namespace cryptonote if (!vin.empty()) { ar.begin_object(); - bool r = rct_signatures.serialize_rctsig_base(ar, vin.size(), blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? vout_zephyr.size() : blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? vout.size() : vout_xhv.size()); + bool r; + if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) + r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout_xhv.size()); + else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) + r = rct_signatures.serialize_rctsig_base(ar, vin_zephyr.size(), vout_zephyr.size()); + else + r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout.size()); if (!r || !ar.stream().good()) return false; ar.end_object(); if (rct_signatures.type != rct::RCTTypeNull) @@ -445,8 +456,8 @@ namespace cryptonote ar.tag("rctsig_prunable"); ar.begin_object(); if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) { - r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout_zephyr.size(), - vin[0].type() == typeid(txin_zephyr_key) ? boost::get(vin[0]).key_offsets.size() - 1 : 0); + r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin_zephyr.size(), vout_zephyr.size(), + vin_zephyr[0].type() == typeid(txin_zephyr_key) ? boost::get(vin_zephyr[0]).key_offsets.size() - 1 : 0); } else if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) { r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout_xhv.size(), vin.size() > 0 && vin[0].type() == typeid(txin_to_key) ? boost::get(vin[0]).key_offsets.size() - 1 : @@ -486,6 +497,7 @@ namespace cryptonote version = 0; unlock_time = 0; vin.clear(); + vin_zephyr.clear(); vout.clear(); vout_xhv.clear(); vout_zephyr.clear(); diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 943727f..4e5497d 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -163,48 +163,6 @@ namespace cryptonote return true; } //--------------------------------------------------------------- - bool get_inputs_money_amount(const transaction& tx, uint64_t& money) - { - money = 0; - BOOST_FOREACH(const auto& in, tx.vin) - { - CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false); - money += tokey_in.amount; - } - return true; - } - //--------------------------------------------------------------- - uint64_t get_block_height(const block& b) - { - CHECK_AND_ASSERT_MES(b.miner_tx.vin.size() == 1, 0, "wrong miner tx in block: " << get_block_hash(b) << ", b.miner_tx.vin.size() != 1"); - CHECKED_GET_SPECIFIC_VARIANT(b.miner_tx.vin[0], const txin_gen, coinbase_in, 0); - return coinbase_in.height; - } - //--------------------------------------------------------------- - bool check_inputs_types_supported(const transaction& tx) - { - BOOST_FOREACH(const auto& in, tx.vin) - { - if (tx.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) { - CHECK_AND_ASSERT_MES(in.type() == typeid(txin_zephyr_key), false, "wrong variant type: " - << in.type().name() << ", expected " << typeid(txin_zephyr_key).name() - << ", in transaction id=" << get_transaction_hash(tx)); - } else if (tx.blob_type == BLOB_TYPE_CRYPTONOTE_XHV) { - CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key) || in.type() == typeid(txin_offshore) || in.type() == typeid(txin_onshore) || in.type() == typeid(txin_xasset), false, "wrong variant type: " - << in.type().name() << ", expected " << typeid(txin_to_key).name() - << "or " << typeid(txin_offshore).name() - << "or " << typeid(txin_onshore).name() - << "or " << typeid(txin_xasset).name() - << ", in transaction id=" << get_transaction_hash(tx)); - } else { - CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), false, "wrong variant type: " - << in.type().name() << ", expected " << typeid(txin_to_key).name() - << ", in transaction id=" << get_transaction_hash(tx)); - } - } - return true; - } - //--------------------------------------------------------------- std::string short_hash_str(const crypto::hash& h) { std::string res = string_tools::pod_to_hex(h); @@ -262,7 +220,7 @@ namespace cryptonote { std::stringstream ss; binary_archive ba(ss); - const size_t inputs = t.vin.size(); + const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size(); const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size(); bool r = tt.rct_signatures.serialize_rctsig_base(ba, inputs, outputs); CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures base"); @@ -278,11 +236,11 @@ namespace cryptonote { std::stringstream ss; binary_archive ba(ss); - const size_t inputs = t.vin.size(); + const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size(); const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size(); size_t mixin; if (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) { - mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_zephyr_key) ? boost::get(t.vin[0]).key_offsets.size() - 1 : 0; + mixin = t.vin_zephyr.empty() ? 0 : t.vin_zephyr[0].type() == typeid(txin_zephyr_key) ? boost::get(t.vin_zephyr[0]).key_offsets.size() - 1 : 0; } else if (t.blob_type == BLOB_TYPE_CRYPTONOTE_XHV) { mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get(t.vin[0]).key_offsets.size() - 1 : diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index fa86540..098025b 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -78,12 +78,9 @@ namespace cryptonote bool get_block_header_hash(const block& b, crypto::hash& res); bool get_bytecoin_block_longhash(const block& blk, crypto::hash& res); bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b); - bool get_inputs_money_amount(const transaction& tx, uint64_t& money); std::map get_outs_money_amount(const transaction& tx); - bool check_inputs_types_supported(const transaction& tx); bool check_outs_valid(const transaction& tx); - uint64_t get_block_height(const block& b); std::vector relative_output_offsets_to_absolute(const std::vector& off); std::vector absolute_output_offsets_to_relative(const std::vector& off); //---------------------------------------------------------------