From 292437c05c12bcdfd983a2cee48e8e503ffaf827 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 24 Jul 2019 00:37:24 +0200 Subject: [PATCH] fixed compilation issues --- contrib/epee/include/misc_log_ex.h | 3 +- src/currency_core/basic_pow_helpers.cpp | 4 +- src/currency_core/blockchain_storage.cpp | 6 +++ src/currency_core/blockchain_storage.h | 3 +- src/currency_core/currency_basic.h | 4 +- src/currency_core/currency_config.h | 4 +- src/currency_core/currency_format_utils.cpp | 14 ++++++ src/currency_core/currency_format_utils.h | 50 +------------------ .../currency_format_utils_blocks.cpp | 1 + .../currency_format_utils_transactions.cpp | 2 +- .../currency_format_utils_transactions.h | 50 +++++++++++++++++++ 11 files changed, 82 insertions(+), 59 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 594f2519..c620daec 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -252,10 +252,9 @@ DISABLE_VS_WARNINGS(4100) } -#define CATCH_ENTRY_WITH_FORWARDING_EXCEPTION() \ +#define CATCH_ENTRY_WITH_FORWARDING_EXCEPTION() } \ catch(const std::exception& ex) \ { \ - (void)(ex); \ LOG_ERROR("Exception at [" << LOCATION_SS << "], what=" << ex.what()); \ throw std::runtime_error(std::string("[EXCEPTION FORWARDED]: ") + ex.what()); \ } \ diff --git a/src/currency_core/basic_pow_helpers.cpp b/src/currency_core/basic_pow_helpers.cpp index 6b3e53f1..7c2275cc 100644 --- a/src/currency_core/basic_pow_helpers.cpp +++ b/src/currency_core/basic_pow_helpers.cpp @@ -36,7 +36,7 @@ namespace currency //------------------------------------------------------------------ int ethash_height_to_epoch(uint64_t height) { - return height / ETHASH_EPOCH_LENGTH; + return static_cast(height / ETHASH_EPOCH_LENGTH); } //-------------------------------------------------------------- crypto::hash ethash_epoch_to_seed(int epoch) @@ -51,7 +51,7 @@ namespace currency { int epoch = ethash_height_to_epoch(height); const auto& context = progpow::get_global_epoch_context_full(static_cast(epoch)); - auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_header_hash, nonce); + auto res_eth = progpow::hash(context, static_cast(height), *(ethash::hash256*)&block_header_hash, nonce); crypto::hash result = currency::null_hash; memcpy(&result.data, &res_eth.final_hash, sizeof(res_eth.final_hash)); return result; diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 2b317682..15bca16d 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -3738,6 +3738,12 @@ bool blockchain_storage::have_tx_keyimges_as_spent(const transaction &tx) const return false; } //------------------------------------------------------------------ +bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash) const +{ + uint64_t stub = 0; + return check_tx_inputs(tx, tx_prefix_hash, stub); +} +//------------------------------------------------------------------ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash, uint64_t& max_used_block_height) const { size_t sig_index = 0; diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 50123e8d..662a8d4a 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -223,7 +223,7 @@ namespace currency std::shared_ptr get_tx(const crypto::hash &id) const; template - bool scan_outputkeys_for_indexes(const transaction &validated_tx, const txin_to_key& tx_in_to_key, visitor_t& vis, uint64_t& max_related_block_height = NULL) const ; + bool scan_outputkeys_for_indexes(const transaction &validated_tx, const txin_to_key& tx_in_to_key, visitor_t& vis, uint64_t& max_related_block_height) const ; uint64_t get_current_blockchain_size() const; uint64_t get_top_block_height() const; @@ -264,6 +264,7 @@ namespace currency bool check_tx_input(const transaction& tx, size_t in_index, const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector& sig, uint64_t& max_related_block_height, uint64_t& max_unlock_time)const; bool check_tx_input(const transaction& tx, size_t in_index, const txin_multisig& txin, const crypto::hash& tx_prefix_hash, const std::vector& sig, uint64_t& max_related_block_height)const; bool check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash, uint64_t& max_used_block_height)const; + bool check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash) const; bool check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash, uint64_t& max_used_block_height, crypto::hash& max_used_block_id)const; bool check_ms_input(const transaction& tx, size_t in_index, const txin_multisig& txin, const crypto::hash& tx_prefix_hash, const std::vector& sig, const transaction& source_tx, size_t out_n) const; bool get_output_keys_for_input_with_checks(const transaction& tx, const txin_to_key& txin, std::vector& output_keys, uint64_t& max_related_block_height, uint64_t& max_unlock_time) const; diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index c2d299db..4adbcdb1 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -351,7 +351,7 @@ namespace currency { std::vector unlock_time_array; BEGIN_SERIALIZE() - VARINT_FIELD(unlock_time_array) + FIELD(unlock_time_array) END_SERIALIZE() }; @@ -371,7 +371,7 @@ namespace currency uint64_t v; BEGIN_SERIALIZE() VARINT_FIELD(v) - END_SERIALIZE() + END_SERIALIZE() }; struct etc_tx_details_flags diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 6cd9e7f4..3000101a 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -210,9 +210,9 @@ //hard forks section #define BLOCK_MAJOR_VERSION_INITAL 1 #ifndef TESTNET -#define ZANO_HARDFORK_1_AFTER_HEIGHT ?? +#define ZANO_HARDFORK_1_AFTER_HEIGHT 120000 #else -#define ZANO_HARDFORK_1_AFTER_HEIGHT ?? +#define ZANO_HARDFORK_1_AFTER_HEIGHT ??? #endif diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index a3a28b03..1078d13c 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2072,6 +2072,20 @@ namespace currency return true; } + bool operator()(const etc_tx_details_unlock_time2& ee) + { + tv.type = "unlock_time"; + std::stringstream ss; + ss << "["; + for (auto v : ee.unlock_time_array) + { + ss << " " << v; + } + ss << "]"; + tv.short_view = ss.str(); + + return true; + } bool operator()(const etc_tx_details_expiration_time& ee) { tv.type = "expiration_time"; diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 0ebfe16a..4b1aa928 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -59,55 +59,7 @@ namespace currency typedef boost::multiprecision::uint128_t uint128_tl; - struct tx_source_entry - { - typedef serializable_pair output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key - - std::vector outputs; //index + key - uint64_t real_output; //index in outputs vector of real output_entry - crypto::public_key real_out_tx_key; //real output's transaction's public key - size_t real_output_in_tx_index; //index in transaction outputs vector - uint64_t amount; //money - uint64_t transfer_index; //money - crypto::hash multisig_id; //if txin_multisig: multisig output id - size_t ms_sigs_count; //if txin_multisig: must be equal to output's minimum_sigs - size_t ms_keys_count; //if txin_multisig: must be equal to size of output's keys container - bool separately_signed_tx_complete; //for separately signed tx only: denotes the last source entry in complete tx to explicitly mark the final step of tx creation - - bool is_multisig() const { return ms_sigs_count > 0; } - - BEGIN_SERIALIZE_OBJECT() - FIELD(outputs) - FIELD(real_output) - FIELD(real_out_tx_key) - FIELD(real_output_in_tx_index) - FIELD(amount) - FIELD(transfer_index) - FIELD(multisig_id) - FIELD(ms_sigs_count) - FIELD(ms_keys_count) - FIELD(separately_signed_tx_complete) - END_SERIALIZE() - }; - - struct tx_destination_entry - { - uint64_t amount; //money - std::list addr; //destination address, in case of 1 address - txout_to_key, in case of more - txout_multisig - size_t minimum_sigs; // if txout_multisig: minimum signatures that are required to spend this output (minimum_sigs <= addr.size()) IF txout_to_key - not used - uint64_t amount_to_provide; //amount money that provided by initial creator of tx, used with partially created transactions - - tx_destination_entry() : amount(0), minimum_sigs(0), amount_to_provide(0){} - tx_destination_entry(uint64_t a, const account_public_address& ad) : amount(a), addr(1, ad), minimum_sigs(0), amount_to_provide(0){} - tx_destination_entry(uint64_t a, const std::list& addr) : amount(a), addr(addr), minimum_sigs(addr.size()), amount_to_provide(0){} - - BEGIN_SERIALIZE_OBJECT() - FIELD(amount) - FIELD(addr) - FIELD(minimum_sigs) - FIELD(amount_to_provide) - END_SERIALIZE() - }; + struct tx_extra_info { diff --git a/src/currency_core/currency_format_utils_blocks.cpp b/src/currency_core/currency_format_utils_blocks.cpp index b1ec69b9..30d7f261 100644 --- a/src/currency_core/currency_format_utils_blocks.cpp +++ b/src/currency_core/currency_format_utils_blocks.cpp @@ -6,6 +6,7 @@ #include "currency_format_utils_blocks.h" #include "serialization/serialization.h" +#include "currency_format_utils.h" #include "currency_format_utils_abstract.h" #include "currency_format_utils_transactions.h" namespace currency diff --git a/src/currency_core/currency_format_utils_transactions.cpp b/src/currency_core/currency_format_utils_transactions.cpp index f65a9391..e8162a84 100644 --- a/src/currency_core/currency_format_utils_transactions.cpp +++ b/src/currency_core/currency_format_utils_transactions.cpp @@ -6,8 +6,8 @@ #include "currency_format_utils_transactions.h" #include "serialization/serialization.h" -#include "currency_format_utils_abstract.h" #include "currency_format_utils.h" +#include "currency_format_utils_abstract.h" namespace currency { diff --git a/src/currency_core/currency_format_utils_transactions.h b/src/currency_core/currency_format_utils_transactions.h index 480be8a2..7ba50b5e 100644 --- a/src/currency_core/currency_format_utils_transactions.h +++ b/src/currency_core/currency_format_utils_transactions.h @@ -9,10 +9,60 @@ #include "crypto/crypto.h" #include "currency_core/currency_basic.h" #include "currency_protocol/blobdatatype.h" +#include "currency_core/account.h" namespace currency { + struct tx_source_entry + { + typedef serializable_pair output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key + + std::vector outputs; //index + key + uint64_t real_output; //index in outputs vector of real output_entry + crypto::public_key real_out_tx_key; //real output's transaction's public key + size_t real_output_in_tx_index; //index in transaction outputs vector + uint64_t amount; //money + uint64_t transfer_index; //money + crypto::hash multisig_id; //if txin_multisig: multisig output id + size_t ms_sigs_count; //if txin_multisig: must be equal to output's minimum_sigs + size_t ms_keys_count; //if txin_multisig: must be equal to size of output's keys container + bool separately_signed_tx_complete; //for separately signed tx only: denotes the last source entry in complete tx to explicitly mark the final step of tx creation + + bool is_multisig() const { return ms_sigs_count > 0; } + + BEGIN_SERIALIZE_OBJECT() + FIELD(outputs) + FIELD(real_output) + FIELD(real_out_tx_key) + FIELD(real_output_in_tx_index) + FIELD(amount) + FIELD(transfer_index) + FIELD(multisig_id) + FIELD(ms_sigs_count) + FIELD(ms_keys_count) + FIELD(separately_signed_tx_complete) + END_SERIALIZE() + }; + + struct tx_destination_entry + { + uint64_t amount; //money + std::list addr; //destination address, in case of 1 address - txout_to_key, in case of more - txout_multisig + size_t minimum_sigs; // if txout_multisig: minimum signatures that are required to spend this output (minimum_sigs <= addr.size()) IF txout_to_key - not used + uint64_t amount_to_provide; //amount money that provided by initial creator of tx, used with partially created transactions + + tx_destination_entry() : amount(0), minimum_sigs(0), amount_to_provide(0) {} + tx_destination_entry(uint64_t a, const account_public_address& ad) : amount(a), addr(1, ad), minimum_sigs(0), amount_to_provide(0) {} + tx_destination_entry(uint64_t a, const std::list& addr) : amount(a), addr(addr), minimum_sigs(addr.size()), amount_to_provide(0) {} + + BEGIN_SERIALIZE_OBJECT() + FIELD(amount) + FIELD(addr) + FIELD(minimum_sigs) + FIELD(amount_to_provide) + END_SERIALIZE() + }; template uint64_t get_tx_x_detail(const transaction& tx)