From 592fe81a47f92edf153ef0e3e6fa1b50b3039b79 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 6 Aug 2024 15:51:05 +0400 Subject: [PATCH 01/23] fix for emmit api --- src/wallet/wallet2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index a59b72cc..d70ebb57 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5408,8 +5408,7 @@ void wallet2::emit_asset(const crypto::public_key asset_id, std::vector Date: Wed, 7 Aug 2024 19:18:44 +0400 Subject: [PATCH 02/23] seed doctor implemented --- src/common/mnemonic-encoding.cpp | 4 + src/common/mnemonic-encoding.h | 1 + src/simplewallet/simplewallet.cpp | 219 ++++++++++++++++++++- src/simplewallet/simplewallet.h | 1 + src/wallet/wallet2.cpp | 4 + src/wallet/wallet_rpc_server_error_codes.h | 15 +- 6 files changed, 235 insertions(+), 9 deletions(-) diff --git a/src/common/mnemonic-encoding.cpp b/src/common/mnemonic-encoding.cpp index c2e3e307..f52ece6b 100644 --- a/src/common/mnemonic-encoding.cpp +++ b/src/common/mnemonic-encoding.cpp @@ -3391,5 +3391,9 @@ namespace tools CHECK_AND_ASSERT_THROW_MES(it!= wordsMap.end(), "unable to find word \"" << w << "\" in mnemonic dictionary"); return it->second; } + const map& get_words_map() + { + return wordsMap; + } } } diff --git a/src/common/mnemonic-encoding.h b/src/common/mnemonic-encoding.h index 4ce6b9bb..5e235399 100644 --- a/src/common/mnemonic-encoding.h +++ b/src/common/mnemonic-encoding.h @@ -47,5 +47,6 @@ namespace tools std::string word_by_num(uint32_t n); uint64_t num_by_word(const std::string& w); bool valid_word(const std::string& w); + const std::map& get_words_map(); } } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index cebf832e..9d842fdf 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "include_base_utils.h" #include "common/command_line.h" #include "common/util.h" @@ -26,7 +27,7 @@ #include "string_coding.h" #include "wallet/wrap_service.h" #include "common/general_purpose_commands_defs.h" - +#include "common/mnemonic-encoding.h" #include "wallet/wallet_helpers.h" @@ -142,6 +143,7 @@ namespace const command_line::arg_descriptor arg_set_timeout("set-timeout", "Set timeout for the wallet"); const command_line::arg_descriptor arg_voting_config_file("voting-config-file", "Set voting config instead of getting if from daemon", ""); const command_line::arg_descriptor arg_no_password_confirmations("no-password-confirmation", "Enable/Disable password confirmation for transactions", false); + const command_line::arg_descriptor arg_seed_doctor("seed-doctor", "Experimental: if your seed is not working for recovery this is likely because you've made a mistake whene you were doing back up(typo, wrong words order, missing word). This experimental code will attempt to recover seed phrase from with few approaches."); const command_line::arg_descriptor< std::vector > arg_command ("command", ""); @@ -2870,6 +2872,210 @@ bool search_for_wallet_file(const std::wstring &search_here/*, const std::string return false; } + + +int seed_doctor() +{ + success_msg_writer() << + "**********************************************************************\n" << + "This is experimental tool that might help you to recover your wallet's corrupted seed phrase. \n" << + "It might help to sort out only trivial situations where one word was written wrong or \n" << + "two word was written in wrong order\n" << + "**********************************************************************"; + + + success_msg_writer() << "Please enter problematic seed phrase:"; + std::string seed; + std::getline(std::cin, seed); + + success_msg_writer() << "Please enter wallet address if you have it(press enter if you don't know it):"; + std::string address; + std::getline(std::cin, address); + address = epee::string_tools::trim(address); + + std::string passphrase; + bool check_summ_available = false; + + //cut the last timestamp word from restore_dats + std::vector words; + boost::split(words, seed, boost::is_space()); + + std::set failed_words; + size_t i = 0; + //let's validate each word + for (const auto& w : words) + { + if (!tools::mnemonic_encoding::valid_word(w)) + { + success_msg_writer() << "Word " << i << " '" << w << "' is invalid, attempting to restore it"; + failed_words.insert(i); + } + i++; + } + + if (words.size() == SEED_PHRASE_V1_WORDS_COUNT) + { + // 24 seed words + one timestamp word = 25 total + success_msg_writer() << "SEED_PHRASE_V1_WORDS_COUNT, checksum is unavailable"; + if (address.empty()) + { + success_msg_writer() << "With SEED_PHRASE_V1_WORDS_COUNT and address unknown it's not enough information to recover it, sorry"; + return EXIT_FAILURE; + } + } + else if (words.size() == SEED_PHRASE_V2_WORDS_COUNT) + { + // 24 seed words + one timestamp word + one flags & checksum = 26 total + + success_msg_writer() << "SEED_PHRASE_V2_WORDS_COUNT, checksum is available"; + check_summ_available = true; + } + else if (words.size() == 24) + { + //seed only with no date, add date to it + std::string zero_word = tools::mnemonic_encoding::word_by_num(0); //zero_word is likely to be "like" + words.push_back(zero_word); // + } + else + { + success_msg_writer() << "Impossible to recover something with " << words.size() << " words only"; + return EXIT_FAILURE; + } + + bool pass_protected = false; + bool success = account_base::is_seed_password_protected(seed, pass_protected); + success_msg_writer() << "SECURED_SEED: " << (pass_protected ? "true" : "false"); + + if (pass_protected) + { + success_msg_writer() << "Please enter seed passphrase(if passphrase is wrong then chances to correct seed recovery is nearly zero):"; + std::getline(std::cin, passphrase); + } + + size_t global_candidates_count = 0; + + auto brute_force_func = [&](size_t word_index) -> bool { + const map& all_words = tools::mnemonic_encoding::get_words_map(); + success_msg_writer() << "Brute forcing word " << word_index << " ...."; + size_t candidates_count = 0; + std::vector words_local = words; + + for (auto it = all_words.begin(); it != all_words.end(); it++) + { + words_local[word_index] = it->first; + + std::string result = boost::algorithm::join(words_local, " "); + account_base acc; + bool r = acc.restore_from_seed_phrase(result, passphrase); + if (r) + { + if (!address.empty()) + { + //check against address + if (acc.get_public_address_str() == address) + { + success_msg_writer(true) << "!!!SUCCESS!!!"; + success_msg_writer() << "Seed recovered, please write down recovered seed and use it to restore the wallet:\n" << result; + return true; + } + } + else + { + success_msg_writer() << "Potential seed candidate:\n" << result << "\nAddress: " << acc.get_public_address_str(); + candidates_count++; + } + } + } + global_candidates_count += candidates_count; + return false; + }; + + + auto swap_func = [&](size_t word_index) -> bool { + size_t candidates_count = 0; + std::vector words_local = words; + + std::string tmp = words_local[word_index]; + words_local[word_index] = words_local[word_index + 1]; + words_local[word_index + 1] = tmp; + std::string result = boost::algorithm::join(words_local, " "); + account_base acc; + bool r = acc.restore_from_seed_phrase(result, passphrase); + if (r) + { + if (!address.empty()) + { + //check against address + if (acc.get_public_address_str() == address) + { + success_msg_writer(true) << "!!!SUCCESS!!!"; + success_msg_writer() << "Seed recovered, please write down recovered seed and use it to restore the wallet:\n" << result; + return true; + } + } + else + { + success_msg_writer() << "Potential seed candidate:\n" << result << "\nAddress: " << acc.get_public_address_str(); + candidates_count++; + } + } + global_candidates_count += candidates_count; + return false; + }; + + + if (failed_words.size()) + { + if (failed_words.size() > 1) + { + success_msg_writer() << "Restoring more then 1 broken words not implemented yet, sorry"; + return EXIT_FAILURE; + } + if (!check_summ_available && address.empty()) + { + success_msg_writer() << "No address and no checksum, recovery is impossible, sorry"; + return EXIT_FAILURE; + } + + size_t broken_word_index = *failed_words.begin(); + bool r = brute_force_func(broken_word_index); + success_msg_writer() << "Brute forcing finished, " << global_candidates_count << " potential candidates found"; + return r ? EXIT_SUCCESS : EXIT_FAILURE; + } + else + { + if (!check_summ_available && address.empty()) + { + success_msg_writer() << "No address and no checksum, recovery is limited only to date reset"; + std::string result = boost::algorithm::join(words, " "); + account_base acc; + bool r = acc.restore_from_seed_phrase(result, passphrase); + success_msg_writer() << "Potential seed candidate:\n" << result << "\nAddress: " << acc.get_public_address_str(); + return EXIT_FAILURE; + } + success_msg_writer() << "Brute forcing all each word"; + for (size_t i = 0; i != words.size() && i != 24; i++) + { + bool r = brute_force_func(i); + if(r) + return EXIT_SUCCESS; + } + } + + success_msg_writer() << "Brute forcing finished, " << global_candidates_count << " potential candidates found"; + + success_msg_writer() << "Swap check..."; + + for (size_t i = 0; i != words.size() && i != 23; i++) + { + bool r = swap_func(i); + if (r) + return EXIT_SUCCESS; + } + + return EXIT_FAILURE; +} + //---------------------------------------------------------------------------------------------------- #ifdef WIN32 int wmain( int argc, wchar_t* argv_w[ ], wchar_t* envp[ ] ) @@ -2934,7 +3140,8 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_params, arg_set_timeout); command_line::add_arg(desc_params, arg_voting_config_file); command_line::add_arg(desc_params, arg_no_password_confirmations); - command_line::add_arg(desc_params, command_line::arg_generate_rpc_autodoc); + command_line::add_arg(desc_params, command_line::arg_generate_rpc_autodoc); + command_line::add_arg(desc_params, arg_seed_doctor); tools::wallet_rpc_server::init_options(desc_params); @@ -3012,6 +3219,13 @@ int main(int argc, char* argv[]) bool offline_mode = command_line::get_arg(vm, arg_offline_mode); + + if (command_line::has_arg(vm, arg_seed_doctor)) + { + return seed_doctor(); + } + + if (command_line::has_arg(vm, tools::wallet_rpc_server::arg_rpc_bind_port)) { // runs wallet as RPC server @@ -3222,3 +3436,4 @@ int main(int argc, char* argv[]) CATCH_ENTRY_L0(__func__, EXIT_FAILURE); return EXIT_SUCCESS; } + diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 5f260433..c2024a4b 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -194,6 +194,7 @@ namespace currency std::string m_restore_wallet; std::string m_voting_config_file; bool m_no_password_confirmations = false; + crypto::hash m_password_hash; uint64_t m_password_salt; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d70ebb57..da73a1f1 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -7598,6 +7598,10 @@ bool wallet2::prepare_transaction(construct_tx_param& ctp, currency::finalize_tx const currency::transaction& tx_for_mode_separate = msc.tx_for_mode_separate; assets_selection_context needed_money_map = get_needed_money(ctp.fee, ctp.dsts); + if (this->is_auditable() && ctp.fake_outputs_count > 0) + { + WLT_THROW_IF_FALSE_WITH_CODE(false, "WALLET_RPC_ERROR_CODE_WRONG_MIXINS_FOR_AUDITABLE_WALLET", "WALLET_RPC_ERROR_CODE_WRONG_MIXINS_FOR_AUDITABLE_WALLET"); + } ftp.ado_current_asset_owner = ctp.ado_current_asset_owner; ftp.pthirdparty_sign_handler = ctp.pthirdparty_sign_handler; // diff --git a/src/wallet/wallet_rpc_server_error_codes.h b/src/wallet/wallet_rpc_server_error_codes.h index d24302e0..676b64ea 100644 --- a/src/wallet/wallet_rpc_server_error_codes.h +++ b/src/wallet/wallet_rpc_server_error_codes.h @@ -7,10 +7,11 @@ #pragma once -#define WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR -1 -#define WALLET_RPC_ERROR_CODE_WRONG_ADDRESS -2 -#define WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY -3 -#define WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR -4 -#define WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID -5 -#define WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT -6 -#define WALLET_RPC_ERROR_CODE_NOT_ENOUGH_MONEY -7 +#define WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR -1 +#define WALLET_RPC_ERROR_CODE_WRONG_ADDRESS -2 +#define WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY -3 +#define WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR -4 +#define WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID -5 +#define WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT -6 +#define WALLET_RPC_ERROR_CODE_NOT_ENOUGH_MONEY -7 +#define WALLET_RPC_ERROR_CODE_WRONG_MIXINS_FOR_AUDITABLE_WALLET -8 From 79fdecce32c605a1a180f7ee64d4a07046ff2302 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Wed, 7 Aug 2024 18:26:53 +0300 Subject: [PATCH 03/23] === build number: 336 -> 337 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index 72619ace..2beb8256 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 336 +#define PROJECT_VERSION_BUILD_NO 337 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From f48811ff44955730e1e61fb58c837fe4e941a263 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 8 Aug 2024 10:00:39 +0400 Subject: [PATCH 04/23] attempt to fix filesystem crosscompiling --- contrib/epee/include/file_io_utils.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index 9d5118cb..746b6420 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -35,7 +35,19 @@ #include #include #include + +#if __has_include() #include +namespace fs = std::filesystem; +#elif __has_include() +#include +namespace fs = std::experimental::filesystem; +#else + #error "Neither nor are available." +#endif + + +//#include #ifndef MAKE64 #define MAKE64(low,high) ((__int64)(((DWORD)(low)) | ((__int64)((DWORD)(high))) << 32)) @@ -562,10 +574,10 @@ namespace file_io_utils try { - std::filesystem::directory_iterator end_itr; // default construction yields past-the-end - for ( std::filesystem::directory_iterator itr( epee::string_encoding::utf8_to_wstring(path) ); itr != end_itr; ++itr ) + fs::directory_iterator end_itr; // default construction yields past-the-end + for ( fs::directory_iterator itr( epee::string_encoding::utf8_to_wstring(path) ); itr != end_itr; ++itr ) { - if ( only_files && std::filesystem::is_directory(itr->status()) ) + if ( only_files && fs::is_directory(itr->status()) ) { continue; } From 44d3317dd2d0fc63e196328c2e00f88ed223c3bc Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 8 Aug 2024 11:22:21 +0400 Subject: [PATCH 05/23] replacing conflicting namespace --- contrib/epee/include/file_io_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index 746b6420..b6fedbc1 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -38,10 +38,10 @@ #if __has_include() #include -namespace fs = std::filesystem; +namespace stdfs = std::filesystem; #elif __has_include() #include -namespace fs = std::experimental::filesystem; +namespace stdfs = std::experimental::filesystem; #else #error "Neither nor are available." #endif @@ -574,10 +574,10 @@ namespace file_io_utils try { - fs::directory_iterator end_itr; // default construction yields past-the-end - for ( fs::directory_iterator itr( epee::string_encoding::utf8_to_wstring(path) ); itr != end_itr; ++itr ) + stdfs::directory_iterator end_itr; // default construction yields past-the-end + for (stdfs::directory_iterator itr( epee::string_encoding::utf8_to_wstring(path) ); itr != end_itr; ++itr ) { - if ( only_files && fs::is_directory(itr->status()) ) + if ( only_files && stdfs::is_directory(itr->status()) ) { continue; } From 08e2f0fbf10d5dc1830332eb3746bfd4e22da605 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 8 Aug 2024 15:55:50 +0400 Subject: [PATCH 06/23] fixed space-failing of the seed phrase --- src/currency_core/account.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index def20255..675d2f1e 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -127,11 +127,12 @@ namespace currency return true; } //----------------------------------------------------------------- - bool account_base::restore_from_seed_phrase(const std::string& seed_phrase, const std::string& seed_password) + bool account_base::restore_from_seed_phrase(const std::string& seed_phrase_, const std::string& seed_password) { //cut the last timestamp word from restore_dats std::list words; - boost::split(words, seed_phrase, boost::is_space()); + std::string seed_phrase = epee::string_tools::trim(seed_phrase_); + boost::split(words, seed_phrase, boost::is_space(), boost::token_compress_on); std::string keys_seed_text, timestamp_word, auditable_flag_and_checksum_word; if (words.size() == SEED_PHRASE_V1_WORDS_COUNT) @@ -230,11 +231,13 @@ namespace currency return seed_phrase.find(':') != std::string::npos; } //----------------------------------------------------------------- - bool account_base::is_seed_password_protected(const std::string& seed_phrase, bool& is_password_protected) + bool account_base::is_seed_password_protected(const std::string& seed_phrase_, bool& is_password_protected) { //cut the last timestamp word from restore_dats std::list words; - boost::split(words, seed_phrase, boost::is_space()); + + std::string seed_phrase = epee::string_tools::trim(seed_phrase_); + boost::split(words, seed_phrase, boost::is_space(), boost::token_compress_on); //let's validate each word for (const auto& w: words) From 820d5a88ac30962a29b891e408595e18644aa404 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 8 Aug 2024 21:04:52 +0400 Subject: [PATCH 07/23] test data for new forkchoice rule generated(fork_choice_rule_test.fork_choice_rule_test_hf4) --- tests/unit_tests/fork_choice_rule.cpp | 1807 ++++++++++++++++++++++++- 1 file changed, 1782 insertions(+), 25 deletions(-) diff --git a/tests/unit_tests/fork_choice_rule.cpp b/tests/unit_tests/fork_choice_rule.cpp index 33014781..1f15eced 100644 --- a/tests/unit_tests/fork_choice_rule.cpp +++ b/tests/unit_tests/fork_choice_rule.cpp @@ -88,62 +88,1819 @@ bool if_alt_chain_stronger_hf4(const currency::wide_difficulty_type& pos, const return true; return false; } + + +bool less_or_equal(const currency::wide_difficulty_type& pos, const currency::wide_difficulty_type& pow) { + // Example predicate: less or equal to a certain target + return !if_alt_chain_stronger_hf4(pos, pow);//mid <= target; +} + +currency::wide_difficulty_type binary_search_custom(currency::wide_difficulty_type low, currency::wide_difficulty_type high, std::function less_or_equal) { + while (low < high) + { + currency::wide_difficulty_type mid = low + (high - low) / 2; + + if (less_or_equal(mid)) { + low = mid + 1; + LOG_PRINT_L0("mid: less_or_eq_true: " << mid); + } + else { + high = mid; + LOG_PRINT_L0("mid: less_or_eq_false: " << mid); + } + } + LOG_PRINT_L0("ret_low: " << low); + return low; +} + +currency::wide_difficulty_type find_break_point(const currency::wide_difficulty_type& pos, const currency::wide_difficulty_type& pow) +{ + currency::wide_difficulty_type last_takeover_pow = binary_search_custom(0, pow, [&](const currency::wide_difficulty_type& pow_mid) { + return less_or_equal(pos, pow_mid); + }); + + return last_takeover_pow; + /*for (currency::wide_difficulty_type pow_now = pow; pow_now != 0; pow_now--) + { + if(!if_alt_chain_stronger_hf4(pos, pow)) + { + if (pow == pow_now) + return 0; + return last_takeover_pow; + } + }*/ +} + TEST(fork_choice_rule_test, fork_choice_rule_test_hf4) { std::stringstream ss; currency::wide_difficulty_type pos_start, pos_end, pos_step, pos_diveder; - pos_start.assign("16059734679876525341203446"); - pos_end.assign ("16059734679876525341203446400"); - pos_step.assign ("50000000000000000000000000"); + pos_start.assign ("500000000000000000000000000");//pos_start.assign("16059734679876525341203446"); + // 1605973467987652534120344647 <- split point + pos_end.assign ("2500000000000000000000000000");//pos_end.assign ("16059734679876525341203446400"); + pos_step.assign ("5000000000000000000000000"); pos_diveder.assign("100000000000000000000000"); currency::wide_difficulty_type pow_start, pow_end, pow_step, pow_diveder; - pow_start.assign("301126455400284498"); - pow_end.assign ("30112645540028449810"); - pow_step.assign ("500000000000000000"); + pow_start.assign("30112645540028449"); //pow_start.assign("301126455400284498"); + // 3011264554002844981 <- split point + pow_end.assign ("301126455400284498100");// pow_end.assign ("30112645540028449810"); + pow_step.assign ("5000000000000000"); pow_diveder.assign("1000000000000000"); + /************************************************************************ for (currency::wide_difficulty_type pos = pos_start; pos < pos_end; pos += pos_step) { for (currency::wide_difficulty_type pow = pow_start; pow < pow_end; pow += pow_step) { bool r = if_alt_chain_stronger_hf4(pos, pow); - if(r) - ss << pos/ pos_diveder << "\t" << pow / pow_diveder << std::endl; - //ss << pos << "\t" << pow << "\t" << (r ? "1" : "0") << std::endl; + if (r) + { + ss << pos / pos_diveder << "\t" << pow / pow_diveder << std::endl; + break; + } + //ss << pos << "\t" << pow << "\t" << (r ? "1" : "0") << std::endl; } } bool r = epee::file_io_utils::save_string_to_file("stat_hf4.txt", ss.str()); + + latest results: + https://docs.google.com/spreadsheets/d/e/2PACX-1vSan0_LNlMTzFXTUPc1CxAqeV4RPh-19YLicpNIjPxBcW2BLMjQK06A_tL4GdckXrYotRDD-FlCONvr/pubhtml + + + ************************************************************************/ + + /* + std::vector> break_points_init = { + {8100, 173895}, + {8150, 102145}, +{8200, 72570}, +{8250, 56430}, +{8300, 46265}, +{8350, 39275}, +{8400, 34170}, +{8450, 30285}, +{8500, 27225}, +{8550, 24750}, +{8600, 22715}, +{8650, 21005}, +{8700, 19550}, +{8750, 18295}, +{8800, 17205}, +{8850, 16250}, +{8900, 15400}, +{8950, 14645}, +{9000, 13970}, +{9050, 13360}, +{9100, 12805}, +{9150, 12300}, +{9200, 11840}, +{9250, 11415}, +{9300, 11025}, +{9350, 10665}, +{9400, 10330}, +{9450, 10020}, +{9500, 9730}, +{9550, 9460}, +{9600, 9210}, +{9650, 8970}, +{9700, 8745}, +{9750, 8535}, +{9800, 8340}, +{9850, 8150}, +{9900, 7975}, +{9950, 7805}, +{10000, 7645}, +{10050, 7495}, +{10100, 7350}, +{10150, 7210}, +{10200, 7080}, +{10250, 6955}, +{10300, 6835}, +{10350, 6720}, +{10400, 6610}, +{10450, 6505}, +{10500, 6405}, +{10550, 6305}, +{10600, 6210}, +{10650, 6120}, +{10700, 6035}, +{10750, 5955}, +{10800, 5870}, +{10850, 5795}, +{10900, 5720}, +{10950, 5650}, +{11000, 5580}, +{11050, 5510}, +{11100, 5445}, +{11150, 5385}, +{11200, 5320}, +{11250, 5265}, +{11300, 5205}, +{11350, 5150}, +{11400, 5095}, +{11450, 5045}, +{11500, 4990}, +{11550, 4945}, +{11600, 4895}, +{11650, 4850}, +{11700, 4800}, +{11750, 4760}, +{11800, 4715}, +{11850, 4675}, +{11900, 4630}, +{11950, 4590}, +{12000, 4555}, +{12050, 4515}, +{12100, 4480}, +{12150, 4440}, +{12200, 4405}, +{12250, 4375}, +{12300, 4340}, +{12350, 4305}, +{12400, 4275}, +{12450, 4245}, +{12500, 4215}, +{12550, 4185}, +{12600, 4155}, +{12650, 4125}, +{12700, 4095}, +{12750, 4070}, +{12800, 4045}, +{12850, 4015}, +{12900, 3990}, +{12950, 3965}, +{13000, 3940}, +{13050, 3915}, +{13100, 3895}, +{13150, 3870}, +{13200, 3845}, +{13250, 3825}, +{13300, 3800}, +{13350, 3780}, +{13400, 3760}, +{13450, 3740}, +{13500, 3720}, +{13550, 3700}, +{13600, 3680}, +{13650, 3660}, +{13700, 3640}, +{13750, 3620}, +{13800, 3605}, +{13850, 3585}, +{13900, 3570}, +{13950, 3550}, +{14000, 3535}, +{14050, 3515}, +{14100, 3500}, +{14150, 3485}, +{14200, 3465}, +{14250, 3450}, +{14300, 3435}, +{14350, 3420}, +{14400, 3405}, +{14450, 3390}, +{14500, 3375}, +{14550, 3360}, +{14600, 3350}, +{14650, 3335}, +{14700, 3320}, +{14750, 3305}, +{14800, 3295}, +{14850, 3280}, +{14900, 3270}, +{14950, 3255}, +{15000, 3245}, +{15050, 3230}, +{15100, 3220}, +{15150, 3205}, +{15200, 3195}, +{15250, 3185}, +{15300, 3170}, +{15350, 3160}, +{15400, 3150}, +{15450, 3135}, +{15500, 3125}, +{15550, 3115}, +{15600, 3105}, +{15650, 3095}, +{15700, 3085}, +{15750, 3075}, +{15800, 3065}, +{15850, 3055}, +{15900, 3045}, +{15950, 3035}, +{16000, 3025}, +{16050, 3015}, +{16100, 3005}, +{16150, 2995}, +{16200, 2990}, +{16250, 2980}, +{16300, 2970}, +{16350, 2960}, +{16400, 2950}, +{16450, 2945}, +{16500, 2935}, +{16550, 2925}, +{16600, 2920}, +{16650, 2910}, +{16700, 2900}, +{16750, 2895}, +{16800, 2885}, +{16850, 2880}, +{16900, 2870}, +{16950, 2865}, +{17000, 2855}, +{17050, 2850}, +{17100, 2840}, +{17150, 2835}, +{17200, 2825}, +{17250, 2820}, +{17300, 2810}, +{17350, 2805}, +{17400, 2800}, +{17450, 2790}, +{17500, 2785}, +{17550, 2780}, +{17600, 2770}, +{17650, 2765}, +{17700, 2760}, +{17750, 2750}, +{17800, 2745}, +{17850, 2740}, +{17900, 2735}, +{17950, 2725}, +{18000, 2720}, +{18050, 2715}, +{18100, 2710}, +{18150, 2705}, +{18200, 2695}, +{18250, 2690}, +{18300, 2685}, +{18350, 2680}, +{18400, 2675}, +{18450, 2670}, +{18500, 2665}, +{18550, 2655}, +{18600, 2650}, +{18650, 2645}, +{18700, 2640}, +{18750, 2635}, +{18800, 2630}, +{18850, 2625}, +{18900, 2620}, +{18950, 2615}, +{19000, 2610}, +{19050, 2605}, +{19100, 2600}, +{19150, 2595}, +{19200, 2590}, +{19250, 2585}, +{19300, 2580}, +{19350, 2575}, +{19400, 2570}, +{19450, 2565}, +{19500, 2560}, +{19550, 2555}, +{19600, 2555}, +{19650, 2550}, +{19700, 2545}, +{19750, 2540}, +{19800, 2535}, +{19850, 2530}, +{19900, 2525}, +{19950, 2520}, +{20000, 2520}, +{20050, 2515}, +{20100, 2510}, +{20150, 2505}, +{20200, 2500}, +{20250, 2495}, +{20300, 2495}, +{20350, 2490}, +{20400, 2485}, +{20450, 2480}, +{20500, 2480}, +{20550, 2475}, +{20600, 2470}, +{20650, 2465}, +{20700, 2460}, +{20750, 2460}, +{20800, 2455}, +{20850, 2450}, +{20900, 2445}, +{20950, 2445}, +{21000, 2440}, +{21050, 2435}, +{21100, 2435}, +{21150, 2430}, +{21200, 2425}, +{21250, 2425}, +{21300, 2420}, +{21350, 2415}, +{21400, 2410}, +{21450, 2410}, +{21500, 2405}, +{21550, 2400}, +{21600, 2400}, +{21650, 2395}, +{21700, 2390}, +{21750, 2390}, +{21800, 2385}, +{21850, 2385}, +{21900, 2380}, +{21950, 2375}, +{22000, 2375}, +{22050, 2370}, +{22100, 2365}, +{22150, 2365}, +{22200, 2360}, +{22250, 2360}, +{22300, 2355}, +{22350, 2350}, +{22400, 2350}, +{22450, 2345}, +{22500, 2345}, +{22550, 2340}, +{22600, 2340}, +{22650, 2335}, +{22700, 2330}, +{22750, 2330}, +{22800, 2325}, +{22850, 2325}, +{22900, 2320}, +{22950, 2320}, +{23000, 2315}, +{23050, 2315}, +{23100, 2310}, +{23150, 2310}, +{23200, 2305}, +{23250, 2300}, +{23300, 2300}, +{23350, 2295}, +{23400, 2295}, +{23450, 2290}, +{23500, 2290}, +{23550, 2285}, +{23600, 2285}, +{23650, 2280}, +{23700, 2280}, +{23750, 2275}, +{23800, 2275}, +{23850, 2270}, +{23900, 2270}, +{23950, 2265}, +{24000, 2265}, +{24050, 2265}, +{24100, 2260}, +{24150, 2260}, +{24200, 2255}, +{24250, 2255}, +{24300, 2250}, +{24350, 2250}, +{24400, 2245}, +{24450, 2245}, +{24500, 2240}, +{24550, 2240}, +{24600, 2240}, +{24650, 2235}, +{24700, 2235}, +{24750, 2230}, +{24800, 2230}, +{24850, 2225}, +{24900, 2225}, +{24950, 2225} + };*/ + /* + //std::stringstream ss; + for (auto bp : break_points_init) + { + currency::wide_difficulty_type pow_takeover_point = find_break_point(pos_diveder * bp.first, (pow_diveder * bp.second) + pow_step); + + if (pow_takeover_point == 0) + { + LOG_ERROR("Failed"); + } + else + { + //self check + if (if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point - 1) == if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point)) + { + bool rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point+1); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point+2); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point+3); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point-1); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point-2); + rfrf = if_alt_chain_stronger_hf4(pos_diveder * bp.first, pow_takeover_point - 3); + + LOG_ERROR("ERROR"); + return; + } + ss << + "res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type(\"" << pos_diveder * bp.first << "\"), currency::wide_difficulty_type(\"" << pow_takeover_point << "\"));" << ENDL << + "ASSERT_TRUE(res);" << ENDL << + "res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type(\"" << pos_diveder * bp.first << "\"), currency::wide_difficulty_type(\"" << pow_takeover_point - 1 << "\"));" << ENDL << + "ASSERT_FALSE(res);" << ENDL; + } + } + bool r = epee::file_io_utils::save_string_to_file("script.txt", ss.str()); + */ bool res = false; - res = if_alt_chain_stronger_hf4(1000000, 1000); - ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(1000000, 1500); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("810000000000000000000000000"), currency::wide_difficulty_type("173893610095151033482")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(800000, 1700); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("810000000000000000000000000"), currency::wide_difficulty_type("173893610095151033481")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(800000, 2000); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("815000000000000000000000000"), currency::wide_difficulty_type("102144604566780242768")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(600000, 2200); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("815000000000000000000000000"), currency::wide_difficulty_type("102144604566780242767")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(600000, 2800); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("820000000000000000000000000"), currency::wide_difficulty_type("72567987045706043158")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(400000, 3999); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("820000000000000000000000000"), currency::wide_difficulty_type("72567987045706043157")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(400000, 4001); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("825000000000000000000000000"), currency::wide_difficulty_type("56427184779296592563")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(200000, 7000); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("825000000000000000000000000"), currency::wide_difficulty_type("56427184779296592562")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(200000, 7700); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("830000000000000000000000000"), currency::wide_difficulty_type("46261521639981421968")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(200000, 7000); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("830000000000000000000000000"), currency::wide_difficulty_type("46261521639981421967")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(200000, 7700); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("835000000000000000000000000"), currency::wide_difficulty_type("39271311807228203073")); ASSERT_TRUE(res); - res = if_alt_chain_stronger_hf4(100000, 10000); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("835000000000000000000000000"), currency::wide_difficulty_type("39271311807228203072")); ASSERT_FALSE(res); - res = if_alt_chain_stronger_hf4(200000, 14000); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("840000000000000000000000000"), currency::wide_difficulty_type("34169670746435628497")); ASSERT_TRUE(res); -} + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("840000000000000000000000000"), currency::wide_difficulty_type("34169670746435628496")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("845000000000000000000000000"), currency::wide_difficulty_type("30282322585424495014")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("845000000000000000000000000"), currency::wide_difficulty_type("30282322585424495013")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("850000000000000000000000000"), currency::wide_difficulty_type("27221836391522953727")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("850000000000000000000000000"), currency::wide_difficulty_type("27221836391522953726")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("855000000000000000000000000"), currency::wide_difficulty_type("24749755123691287729")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("855000000000000000000000000"), currency::wide_difficulty_type("24749755123691287728")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("860000000000000000000000000"), currency::wide_difficulty_type("22711271409727869596")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("860000000000000000000000000"), currency::wide_difficulty_type("22711271409727869595")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("865000000000000000000000000"), currency::wide_difficulty_type("21001505056620832872")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("865000000000000000000000000"), currency::wide_difficulty_type("21001505056620832871")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("870000000000000000000000000"), currency::wide_difficulty_type("19546877193995594351")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("870000000000000000000000000"), currency::wide_difficulty_type("19546877193995594350")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("875000000000000000000000000"), currency::wide_difficulty_type("18294243761466129083")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("875000000000000000000000000"), currency::wide_difficulty_type("18294243761466129082")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("880000000000000000000000000"), currency::wide_difficulty_type("17204261972931225543")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("880000000000000000000000000"), currency::wide_difficulty_type("17204261972931225542")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("885000000000000000000000000"), currency::wide_difficulty_type("16247183291614714294")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("885000000000000000000000000"), currency::wide_difficulty_type("16247183291614714293")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("890000000000000000000000000"), currency::wide_difficulty_type("15400096882194836021")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("890000000000000000000000000"), currency::wide_difficulty_type("15400096882194836020")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("895000000000000000000000000"), currency::wide_difficulty_type("14645071807644110435")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("895000000000000000000000000"), currency::wide_difficulty_type("14645071807644110434")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("900000000000000000000000000"), currency::wide_difficulty_type("13967873725795875372")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("900000000000000000000000000"), currency::wide_difficulty_type("13967873725795875371")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("905000000000000000000000000"), currency::wide_difficulty_type("13357058979013812170")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("905000000000000000000000000"), currency::wide_difficulty_type("13357058979013812169")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("910000000000000000000000000"), currency::wide_difficulty_type("12803322645925507695")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("910000000000000000000000000"), currency::wide_difficulty_type("12803322645925507694")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("915000000000000000000000000"), currency::wide_difficulty_type("12299021201474213830")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("915000000000000000000000000"), currency::wide_difficulty_type("12299021201474213829")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("920000000000000000000000000"), currency::wide_difficulty_type("11837817557953003092")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("920000000000000000000000000"), currency::wide_difficulty_type("11837817557953003091")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("925000000000000000000000000"), currency::wide_difficulty_type("11414413381540383189")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("925000000000000000000000000"), currency::wide_difficulty_type("11414413381540383188")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("930000000000000000000000000"), currency::wide_difficulty_type("11024344634545981648")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("930000000000000000000000000"), currency::wide_difficulty_type("11024344634545981647")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("935000000000000000000000000"), currency::wide_difficulty_type("10663823580658131959")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("935000000000000000000000000"), currency::wide_difficulty_type("10663823580658131958")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("940000000000000000000000000"), currency::wide_difficulty_type("10329615384232683380")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("940000000000000000000000000"), currency::wide_difficulty_type("10329615384232683379")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("945000000000000000000000000"), currency::wide_difficulty_type("10018940777719244821")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("945000000000000000000000000"), currency::wide_difficulty_type("10018940777719244820")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("950000000000000000000000000"), currency::wide_difficulty_type("9729398591085546371")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("950000000000000000000000000"), currency::wide_difficulty_type("9729398591085546370")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("955000000000000000000000000"), currency::wide_difficulty_type("9458903570152632164")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("955000000000000000000000000"), currency::wide_difficulty_type("9458903570152632163")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("960000000000000000000000000"), currency::wide_difficulty_type("9205636075772937886")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("960000000000000000000000000"), currency::wide_difficulty_type("9205636075772937885")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("965000000000000000000000000"), currency::wide_difficulty_type("8968001097212660715")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("965000000000000000000000000"), currency::wide_difficulty_type("8968001097212660714")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("970000000000000000000000000"), currency::wide_difficulty_type("8744594627814733132")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("970000000000000000000000000"), currency::wide_difficulty_type("8744594627814733131")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("975000000000000000000000000"), currency::wide_difficulty_type("8534175904919445023")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("975000000000000000000000000"), currency::wide_difficulty_type("8534175904919445022")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("980000000000000000000000000"), currency::wide_difficulty_type("8335644354530648558")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("980000000000000000000000000"), currency::wide_difficulty_type("8335644354530648557")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("985000000000000000000000000"), currency::wide_difficulty_type("8148020336034723158")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("985000000000000000000000000"), currency::wide_difficulty_type("8148020336034723157")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("990000000000000000000000000"), currency::wide_difficulty_type("7970428975782931705")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("990000000000000000000000000"), currency::wide_difficulty_type("7970428975782931704")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("995000000000000000000000000"), currency::wide_difficulty_type("7802086526502014600")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("995000000000000000000000000"), currency::wide_difficulty_type("7802086526502014599")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1000000000000000000000000000"), currency::wide_difficulty_type("7642288803812028782")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1000000000000000000000000000"), currency::wide_difficulty_type("7642288803812028781")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1005000000000000000000000000"), currency::wide_difficulty_type("7490401339980245977")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1005000000000000000000000000"), currency::wide_difficulty_type("7490401339980245976")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1010000000000000000000000000"), currency::wide_difficulty_type("7345850964575793868")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1010000000000000000000000000"), currency::wide_difficulty_type("7345850964575793867")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1015000000000000000000000000"), currency::wide_difficulty_type("7208118576466544449")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1015000000000000000000000000"), currency::wide_difficulty_type("7208118576466544448")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1020000000000000000000000000"), currency::wide_difficulty_type("7076732915018020514")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1020000000000000000000000000"), currency::wide_difficulty_type("7076732915018020513")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1025000000000000000000000000"), currency::wide_difficulty_type("6951265172971883569")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1025000000000000000000000000"), currency::wide_difficulty_type("6951265172971883568")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1030000000000000000000000000"), currency::wide_difficulty_type("6831324321237202029")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1030000000000000000000000000"), currency::wide_difficulty_type("6831324321237202028")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1035000000000000000000000000"), currency::wide_difficulty_type("6716553038200005653")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1035000000000000000000000000"), currency::wide_difficulty_type("6716553038200005652")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1040000000000000000000000000"), currency::wide_difficulty_type("6606624154281270723")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1040000000000000000000000000"), currency::wide_difficulty_type("6606624154281270722")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1045000000000000000000000000"), currency::wide_difficulty_type("6501237537228019549")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1045000000000000000000000000"), currency::wide_difficulty_type("6501237537228019548")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1050000000000000000000000000"), currency::wide_difficulty_type("6400117355688827656")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1050000000000000000000000000"), currency::wide_difficulty_type("6400117355688827655")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1055000000000000000000000000"), currency::wide_difficulty_type("6303009668537003243")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1055000000000000000000000000"), currency::wide_difficulty_type("6303009668537003242")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1060000000000000000000000000"), currency::wide_difficulty_type("6209680295581205260")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1060000000000000000000000000"), currency::wide_difficulty_type("6209680295581205259")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1065000000000000000000000000"), currency::wide_difficulty_type("6119912932075478362")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1065000000000000000000000000"), currency::wide_difficulty_type("6119912932075478361")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1070000000000000000000000000"), currency::wide_difficulty_type("6033507475071567420")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1070000000000000000000000000"), currency::wide_difficulty_type("6033507475071567419")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1075000000000000000000000000"), currency::wide_difficulty_type("5950278534355724202")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1075000000000000000000000000"), currency::wide_difficulty_type("5950278534355724201")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1080000000000000000000000000"), currency::wide_difficulty_type("5870054104648172855")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1080000000000000000000000000"), currency::wide_difficulty_type("5870054104648172854")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1085000000000000000000000000"), currency::wide_difficulty_type("5792674379051306677")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1085000000000000000000000000"), currency::wide_difficulty_type("5792674379051306676")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1090000000000000000000000000"), currency::wide_difficulty_type("5717990686521957375")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1090000000000000000000000000"), currency::wide_difficulty_type("5717990686521957374")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1095000000000000000000000000"), currency::wide_difficulty_type("5645864538502512988")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1095000000000000000000000000"), currency::wide_difficulty_type("5645864538502512987")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1100000000000000000000000000"), currency::wide_difficulty_type("5576166771847621697")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1100000000000000000000000000"), currency::wide_difficulty_type("5576166771847621696")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1105000000000000000000000000"), currency::wide_difficulty_type("5508776776886887265")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1105000000000000000000000000"), currency::wide_difficulty_type("5508776776886887264")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1110000000000000000000000000"), currency::wide_difficulty_type("5443581800917917808")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1110000000000000000000000000"), currency::wide_difficulty_type("5443581800917917807")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1115000000000000000000000000"), currency::wide_difficulty_type("5380476318668349354")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1115000000000000000000000000"), currency::wide_difficulty_type("5380476318668349353")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1120000000000000000000000000"), currency::wide_difficulty_type("5319361462333102716")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1120000000000000000000000000"), currency::wide_difficulty_type("5319361462333102715")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1125000000000000000000000000"), currency::wide_difficulty_type("5260144504711571647")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1125000000000000000000000000"), currency::wide_difficulty_type("5260144504711571646")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1130000000000000000000000000"), currency::wide_difficulty_type("5202738389761493946")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1130000000000000000000000000"), currency::wide_difficulty_type("5202738389761493945")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1135000000000000000000000000"), currency::wide_difficulty_type("5147061305570958556")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1135000000000000000000000000"), currency::wide_difficulty_type("5147061305570958555")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1140000000000000000000000000"), currency::wide_difficulty_type("5093036295343277653")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1140000000000000000000000000"), currency::wide_difficulty_type("5093036295343277652")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1145000000000000000000000000"), currency::wide_difficulty_type("5040590902504669188")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1145000000000000000000000000"), currency::wide_difficulty_type("5040590902504669187")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1150000000000000000000000000"), currency::wide_difficulty_type("4989656846493099358")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1150000000000000000000000000"), currency::wide_difficulty_type("4989656846493099357")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1155000000000000000000000000"), currency::wide_difficulty_type("4940169726177716516")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1155000000000000000000000000"), currency::wide_difficulty_type("4940169726177716515")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1160000000000000000000000000"), currency::wide_difficulty_type("4892068748200095632")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1160000000000000000000000000"), currency::wide_difficulty_type("4892068748200095631")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1165000000000000000000000000"), currency::wide_difficulty_type("4845296477827814285")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1165000000000000000000000000"), currency::wide_difficulty_type("4845296477827814284")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1170000000000000000000000000"), currency::wide_difficulty_type("4799798610173485225")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1170000000000000000000000000"), currency::wide_difficulty_type("4799798610173485224")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1175000000000000000000000000"), currency::wide_difficulty_type("4755523759863208997")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1175000000000000000000000000"), currency::wide_difficulty_type("4755523759863208996")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1180000000000000000000000000"), currency::wide_difficulty_type("4712423267441696058")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1180000000000000000000000000"), currency::wide_difficulty_type("4712423267441696057")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1185000000000000000000000000"), currency::wide_difficulty_type("4670451020980647133")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1185000000000000000000000000"), currency::wide_difficulty_type("4670451020980647132")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1190000000000000000000000000"), currency::wide_difficulty_type("4629563291515467266")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1190000000000000000000000000"), currency::wide_difficulty_type("4629563291515467265")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1195000000000000000000000000"), currency::wide_difficulty_type("4589718581075682727")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1195000000000000000000000000"), currency::wide_difficulty_type("4589718581075682726")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1200000000000000000000000000"), currency::wide_difficulty_type("4550877482198821754")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1200000000000000000000000000"), currency::wide_difficulty_type("4550877482198821753")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1205000000000000000000000000"), currency::wide_difficulty_type("4513002547927988098")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1205000000000000000000000000"), currency::wide_difficulty_type("4513002547927988097")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1210000000000000000000000000"), currency::wide_difficulty_type("4476058171391610675")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1210000000000000000000000000"), currency::wide_difficulty_type("4476058171391610674")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1215000000000000000000000000"), currency::wide_difficulty_type("4440010474151375716")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1215000000000000000000000000"), currency::wide_difficulty_type("4440010474151375715")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1220000000000000000000000000"), currency::wide_difficulty_type("4404827202582426266")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1220000000000000000000000000"), currency::wide_difficulty_type("4404827202582426265")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1225000000000000000000000000"), currency::wide_difficulty_type("4370477631619666641")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1225000000000000000000000000"), currency::wide_difficulty_type("4370477631619666640")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1230000000000000000000000000"), currency::wide_difficulty_type("4336932475266411512")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1230000000000000000000000000"), currency::wide_difficulty_type("4336932475266411511")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1235000000000000000000000000"), currency::wide_difficulty_type("4304163803317521313")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1235000000000000000000000000"), currency::wide_difficulty_type("4304163803317521312")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1240000000000000000000000000"), currency::wide_difficulty_type("4272144963799311315")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1240000000000000000000000000"), currency::wide_difficulty_type("4272144963799311314")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1245000000000000000000000000"), currency::wide_difficulty_type("4240850510673562277")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1245000000000000000000000000"), currency::wide_difficulty_type("4240850510673562276")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1250000000000000000000000000"), currency::wide_difficulty_type("4210256136393466936")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1250000000000000000000000000"), currency::wide_difficulty_type("4210256136393466935")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1255000000000000000000000000"), currency::wide_difficulty_type("4180338608935820328")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1255000000000000000000000000"), currency::wide_difficulty_type("4180338608935820327")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1260000000000000000000000000"), currency::wide_difficulty_type("4151075712966644396")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1260000000000000000000000000"), currency::wide_difficulty_type("4151075712966644395")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1265000000000000000000000000"), currency::wide_difficulty_type("4122446194827116866")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1265000000000000000000000000"), currency::wide_difficulty_type("4122446194827116865")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1270000000000000000000000000"), currency::wide_difficulty_type("4094429711053494243")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1270000000000000000000000000"), currency::wide_difficulty_type("4094429711053494242")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1275000000000000000000000000"), currency::wide_difficulty_type("4067006780168981652")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1275000000000000000000000000"), currency::wide_difficulty_type("4067006780168981651")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1280000000000000000000000000"), currency::wide_difficulty_type("4040158737507476210")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1280000000000000000000000000"), currency::wide_difficulty_type("4040158737507476209")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1285000000000000000000000000"), currency::wide_difficulty_type("4013867692849033231")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1285000000000000000000000000"), currency::wide_difficulty_type("4013867692849033230")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1290000000000000000000000000"), currency::wide_difficulty_type("3988116490664986212")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1290000000000000000000000000"), currency::wide_difficulty_type("3988116490664986211")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1295000000000000000000000000"), currency::wide_difficulty_type("3962888672787079503")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1295000000000000000000000000"), currency::wide_difficulty_type("3962888672787079502")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1300000000000000000000000000"), currency::wide_difficulty_type("3938168443329913124")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1300000000000000000000000000"), currency::wide_difficulty_type("3938168443329913123")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1305000000000000000000000000"), currency::wide_difficulty_type("3913940635709600402")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1305000000000000000000000000"), currency::wide_difficulty_type("3913940635709600401")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1310000000000000000000000000"), currency::wide_difficulty_type("3890190681613933281")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1310000000000000000000000000"), currency::wide_difficulty_type("3890190681613933280")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1315000000000000000000000000"), currency::wide_difficulty_type("3866904581790654891")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1315000000000000000000000000"), currency::wide_difficulty_type("3866904581790654890")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1320000000000000000000000000"), currency::wide_difficulty_type("3844068878530759853")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1320000000000000000000000000"), currency::wide_difficulty_type("3844068878530759852")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1325000000000000000000000000"), currency::wide_difficulty_type("3821670629733173919")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1325000000000000000000000000"), currency::wide_difficulty_type("3821670629733173918")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1330000000000000000000000000"), currency::wide_difficulty_type("3799697384445790394")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1330000000000000000000000000"), currency::wide_difficulty_type("3799697384445790393")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1335000000000000000000000000"), currency::wide_difficulty_type("3778137159785737024")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1335000000000000000000000000"), currency::wide_difficulty_type("3778137159785737023")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1340000000000000000000000000"), currency::wide_difficulty_type("3756978419148981611")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1340000000000000000000000000"), currency::wide_difficulty_type("3756978419148981610")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1345000000000000000000000000"), currency::wide_difficulty_type("3736210051626018480")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1345000000000000000000000000"), currency::wide_difficulty_type("3736210051626018479")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1350000000000000000000000000"), currency::wide_difficulty_type("3715821352546466165")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1350000000000000000000000000"), currency::wide_difficulty_type("3715821352546466164")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1355000000000000000000000000"), currency::wide_difficulty_type("3695802005080998506")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1355000000000000000000000000"), currency::wide_difficulty_type("3695802005080998505")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1360000000000000000000000000"), currency::wide_difficulty_type("3676142062834171471")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1360000000000000000000000000"), currency::wide_difficulty_type("3676142062834171470")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1365000000000000000000000000"), currency::wide_difficulty_type("3656831933366436577")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1365000000000000000000000000"), currency::wide_difficulty_type("3656831933366436576")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1370000000000000000000000000"), currency::wide_difficulty_type("3637862362587985060")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1370000000000000000000000000"), currency::wide_difficulty_type("3637862362587985059")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1375000000000000000000000000"), currency::wide_difficulty_type("3619224419971077733")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1375000000000000000000000000"), currency::wide_difficulty_type("3619224419971077732")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1380000000000000000000000000"), currency::wide_difficulty_type("3600909484531213505")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1380000000000000000000000000"), currency::wide_difficulty_type("3600909484531213504")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1385000000000000000000000000"), currency::wide_difficulty_type("3582909231530901607")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1385000000000000000000000000"), currency::wide_difficulty_type("3582909231530901606")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1390000000000000000000000000"), currency::wide_difficulty_type("3565215619862953101")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1390000000000000000000000000"), currency::wide_difficulty_type("3565215619862953100")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1395000000000000000000000000"), currency::wide_difficulty_type("3547820880073118287")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1395000000000000000000000000"), currency::wide_difficulty_type("3547820880073118286")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1400000000000000000000000000"), currency::wide_difficulty_type("3530717502984588252")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1400000000000000000000000000"), currency::wide_difficulty_type("3530717502984588251")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1405000000000000000000000000"), currency::wide_difficulty_type("3513898228889369242")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1405000000000000000000000000"), currency::wide_difficulty_type("3513898228889369241")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1410000000000000000000000000"), currency::wide_difficulty_type("3497356037273844307")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1410000000000000000000000000"), currency::wide_difficulty_type("3497356037273844306")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1415000000000000000000000000"), currency::wide_difficulty_type("3481084137047972976")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1415000000000000000000000000"), currency::wide_difficulty_type("3481084137047972975")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1420000000000000000000000000"), currency::wide_difficulty_type("3465075957249560147")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1420000000000000000000000000"), currency::wide_difficulty_type("3465075957249560146")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1425000000000000000000000000"), currency::wide_difficulty_type("3449325138196862568")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1425000000000000000000000000"), currency::wide_difficulty_type("3449325138196862567")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1430000000000000000000000000"), currency::wide_difficulty_type("3433825523064506644")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1430000000000000000000000000"), currency::wide_difficulty_type("3433825523064506643")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1435000000000000000000000000"), currency::wide_difficulty_type("3418571149859275151")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1435000000000000000000000000"), currency::wide_difficulty_type("3418571149859275150")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1440000000000000000000000000"), currency::wide_difficulty_type("3403556243773792521")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1440000000000000000000000000"), currency::wide_difficulty_type("3403556243773792520")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1445000000000000000000000000"), currency::wide_difficulty_type("3388775209897507173")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1445000000000000000000000000"), currency::wide_difficulty_type("3388775209897507172")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1450000000000000000000000000"), currency::wide_difficulty_type("3374222626265643002")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1450000000000000000000000000"), currency::wide_difficulty_type("3374222626265643001")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1455000000000000000000000000"), currency::wide_difficulty_type("3359893237227977874")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1455000000000000000000000000"), currency::wide_difficulty_type("3359893237227977873")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1460000000000000000000000000"), currency::wide_difficulty_type("3345781947120411526")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1460000000000000000000000000"), currency::wide_difficulty_type("3345781947120411525")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1465000000000000000000000000"), currency::wide_difficulty_type("3331883814223314654")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1465000000000000000000000000"), currency::wide_difficulty_type("3331883814223314653")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1470000000000000000000000000"), currency::wide_difficulty_type("3318194044991611032")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1470000000000000000000000000"), currency::wide_difficulty_type("3318194044991611031")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1475000000000000000000000000"), currency::wide_difficulty_type("3304707988542440156")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1475000000000000000000000000"), currency::wide_difficulty_type("3304707988542440155")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1480000000000000000000000000"), currency::wide_difficulty_type("3291421131387084121")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1480000000000000000000000000"), currency::wide_difficulty_type("3291421131387084120")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1485000000000000000000000000"), currency::wide_difficulty_type("3278329092394623406")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1485000000000000000000000000"), currency::wide_difficulty_type("3278329092394623405")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1490000000000000000000000000"), currency::wide_difficulty_type("3265427617975516113")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1490000000000000000000000000"), currency::wide_difficulty_type("3265427617975516112")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1495000000000000000000000000"), currency::wide_difficulty_type("3252712577473977564")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1495000000000000000000000000"), currency::wide_difficulty_type("3252712577473977563")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1500000000000000000000000000"), currency::wide_difficulty_type("3240179958758675520")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1500000000000000000000000000"), currency::wide_difficulty_type("3240179958758675519")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1505000000000000000000000000"), currency::wide_difficulty_type("3227825864001853654")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1505000000000000000000000000"), currency::wide_difficulty_type("3227825864001853653")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1510000000000000000000000000"), currency::wide_difficulty_type("3215646505637555347")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1510000000000000000000000000"), currency::wide_difficulty_type("3215646505637555346")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1515000000000000000000000000"), currency::wide_difficulty_type("3203638202490143865")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1515000000000000000000000000"), currency::wide_difficulty_type("3203638202490143864")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1520000000000000000000000000"), currency::wide_difficulty_type("3191797376064806144")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1520000000000000000000000000"), currency::wide_difficulty_type("3191797376064806143")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1525000000000000000000000000"), currency::wide_difficulty_type("3180120546992187929")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1525000000000000000000000000"), currency::wide_difficulty_type("3180120546992187928")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1530000000000000000000000000"), currency::wide_difficulty_type("3168604331619740064")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1530000000000000000000000000"), currency::wide_difficulty_type("3168604331619740063")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1535000000000000000000000000"), currency::wide_difficulty_type("3157245438742761163")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1535000000000000000000000000"), currency::wide_difficulty_type("3157245438742761162")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1540000000000000000000000000"), currency::wide_difficulty_type("3146040666468502645")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1540000000000000000000000000"), currency::wide_difficulty_type("3146040666468502644")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1545000000000000000000000000"), currency::wide_difficulty_type("3134986899207059697")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1545000000000000000000000000"), currency::wide_difficulty_type("3134986899207059696")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1550000000000000000000000000"), currency::wide_difficulty_type("3124081104783107851")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1550000000000000000000000000"), currency::wide_difficulty_type("3124081104783107850")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1555000000000000000000000000"), currency::wide_difficulty_type("3113320331662860805")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1555000000000000000000000000"), currency::wide_difficulty_type("3113320331662860804")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1560000000000000000000000000"), currency::wide_difficulty_type("3102701706290922296")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1560000000000000000000000000"), currency::wide_difficulty_type("3102701706290922295")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1565000000000000000000000000"), currency::wide_difficulty_type("3092222430531984521")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1565000000000000000000000000"), currency::wide_difficulty_type("3092222430531984520")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1570000000000000000000000000"), currency::wide_difficulty_type("3081879779212588752")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1570000000000000000000000000"), currency::wide_difficulty_type("3081879779212588751")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1575000000000000000000000000"), currency::wide_difficulty_type("3071671097758411764")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1575000000000000000000000000"), currency::wide_difficulty_type("3071671097758411763")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1580000000000000000000000000"), currency::wide_difficulty_type("3061593799922775157")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1580000000000000000000000000"), currency::wide_difficulty_type("3061593799922775156")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1585000000000000000000000000"), currency::wide_difficulty_type("3051645365602294788")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1585000000000000000000000000"), currency::wide_difficulty_type("3051645365602294787")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1590000000000000000000000000"), currency::wide_difficulty_type("3041823338735795027")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1590000000000000000000000000"), currency::wide_difficulty_type("3041823338735795026")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1595000000000000000000000000"), currency::wide_difficulty_type("3032125325282808256")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1595000000000000000000000000"), currency::wide_difficulty_type("3032125325282808255")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1600000000000000000000000000"), currency::wide_difficulty_type("3022548991278164715")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1600000000000000000000000000"), currency::wide_difficulty_type("3022548991278164714")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1605000000000000000000000000"), currency::wide_difficulty_type("3013092060959352101")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1605000000000000000000000000"), currency::wide_difficulty_type("3013092060959352100")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1610000000000000000000000000"), currency::wide_difficulty_type("3003752314963488897")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1610000000000000000000000000"), currency::wide_difficulty_type("3003752314963488896")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1615000000000000000000000000"), currency::wide_difficulty_type("2994527588590910913")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1615000000000000000000000000"), currency::wide_difficulty_type("2994527588590910912")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1620000000000000000000000000"), currency::wide_difficulty_type("2985415770132517377")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1620000000000000000000000000"), currency::wide_difficulty_type("2985415770132517376")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1625000000000000000000000000"), currency::wide_difficulty_type("2976414799258161798")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1625000000000000000000000000"), currency::wide_difficulty_type("2976414799258161797")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1630000000000000000000000000"), currency::wide_difficulty_type("2967522665463504146")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1630000000000000000000000000"), currency::wide_difficulty_type("2967522665463504145")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1635000000000000000000000000"), currency::wide_difficulty_type("2958737406572865050")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1635000000000000000000000000"), currency::wide_difficulty_type("2958737406572865049")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1640000000000000000000000000"), currency::wide_difficulty_type("2950057107295740304")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1640000000000000000000000000"), currency::wide_difficulty_type("2950057107295740303")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1645000000000000000000000000"), currency::wide_difficulty_type("2941479897834745142")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1645000000000000000000000000"), currency::wide_difficulty_type("2941479897834745141")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1650000000000000000000000000"), currency::wide_difficulty_type("2933003952542863155")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1650000000000000000000000000"), currency::wide_difficulty_type("2933003952542863154")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1655000000000000000000000000"), currency::wide_difficulty_type("2924627488627974429")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1655000000000000000000000000"), currency::wide_difficulty_type("2924627488627974428")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1660000000000000000000000000"), currency::wide_difficulty_type("2916348764902732061")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1660000000000000000000000000"), currency::wide_difficulty_type("2916348764902732060")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1665000000000000000000000000"), currency::wide_difficulty_type("2908166080577945776")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1665000000000000000000000000"), currency::wide_difficulty_type("2908166080577945775")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1670000000000000000000000000"), currency::wide_difficulty_type("2900077774097716347")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1670000000000000000000000000"), currency::wide_difficulty_type("2900077774097716346")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1675000000000000000000000000"), currency::wide_difficulty_type("2892082222014645048")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1675000000000000000000000000"), currency::wide_difficulty_type("2892082222014645047")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1680000000000000000000000000"), currency::wide_difficulty_type("2884177837903518828")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1680000000000000000000000000"), currency::wide_difficulty_type("2884177837903518827")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1685000000000000000000000000"), currency::wide_difficulty_type("2876363071311944416")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1685000000000000000000000000"), currency::wide_difficulty_type("2876363071311944415")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1690000000000000000000000000"), currency::wide_difficulty_type("2868636406746473411")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1690000000000000000000000000"), currency::wide_difficulty_type("2868636406746473410")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1695000000000000000000000000"), currency::wide_difficulty_type("2860996362692825797")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1695000000000000000000000000"), currency::wide_difficulty_type("2860996362692825796")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1700000000000000000000000000"), currency::wide_difficulty_type("2853441490668881421")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1700000000000000000000000000"), currency::wide_difficulty_type("2853441490668881420")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1705000000000000000000000000"), currency::wide_difficulty_type("2845970374309167960")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1705000000000000000000000000"), currency::wide_difficulty_type("2845970374309167959")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1710000000000000000000000000"), currency::wide_difficulty_type("2838581628479629993")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1710000000000000000000000000"), currency::wide_difficulty_type("2838581628479629992")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1715000000000000000000000000"), currency::wide_difficulty_type("2831273898421517086")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1715000000000000000000000000"), currency::wide_difficulty_type("2831273898421517085")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1720000000000000000000000000"), currency::wide_difficulty_type("2824045858923279501")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1720000000000000000000000000"), currency::wide_difficulty_type("2824045858923279500")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1725000000000000000000000000"), currency::wide_difficulty_type("2816896213519408333")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1725000000000000000000000000"), currency::wide_difficulty_type("2816896213519408332")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1730000000000000000000000000"), currency::wide_difficulty_type("2809823693715202785")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1730000000000000000000000000"), currency::wide_difficulty_type("2809823693715202784")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1735000000000000000000000000"), currency::wide_difficulty_type("2802827058236490934")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1735000000000000000000000000"), currency::wide_difficulty_type("2802827058236490933")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1740000000000000000000000000"), currency::wide_difficulty_type("2795905092303371895")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1740000000000000000000000000"), currency::wide_difficulty_type("2795905092303371894")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1745000000000000000000000000"), currency::wide_difficulty_type("2789056606927086901")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1745000000000000000000000000"), currency::wide_difficulty_type("2789056606927086900")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1750000000000000000000000000"), currency::wide_difficulty_type("2782280438229164471")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1750000000000000000000000000"), currency::wide_difficulty_type("2782280438229164470")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1755000000000000000000000000"), currency::wide_difficulty_type("2775575446782020797")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1755000000000000000000000000"), currency::wide_difficulty_type("2775575446782020796")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1760000000000000000000000000"), currency::wide_difficulty_type("2768940516970230676")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1760000000000000000000000000"), currency::wide_difficulty_type("2768940516970230675")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1765000000000000000000000000"), currency::wide_difficulty_type("2762374556371716950")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1765000000000000000000000000"), currency::wide_difficulty_type("2762374556371716949")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1770000000000000000000000000"), currency::wide_difficulty_type("2755876495158137534")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1770000000000000000000000000"), currency::wide_difficulty_type("2755876495158137533")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1775000000000000000000000000"), currency::wide_difficulty_type("2749445285513778759")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1775000000000000000000000000"), currency::wide_difficulty_type("2749445285513778758")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1780000000000000000000000000"), currency::wide_difficulty_type("2743079901072292083")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1780000000000000000000000000"), currency::wide_difficulty_type("2743079901072292082")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1785000000000000000000000000"), currency::wide_difficulty_type("2736779336370638195")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1785000000000000000000000000"), currency::wide_difficulty_type("2736779336370638194")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1790000000000000000000000000"), currency::wide_difficulty_type("2730542606319628350")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1790000000000000000000000000"), currency::wide_difficulty_type("2730542606319628349")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1795000000000000000000000000"), currency::wide_difficulty_type("2724368745690477334")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1795000000000000000000000000"), currency::wide_difficulty_type("2724368745690477333")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1800000000000000000000000000"), currency::wide_difficulty_type("2718256808616805999")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1800000000000000000000000000"), currency::wide_difficulty_type("2718256808616805998")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1805000000000000000000000000"), currency::wide_difficulty_type("2712205868111553685")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1805000000000000000000000000"), currency::wide_difficulty_type("2712205868111553684")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1810000000000000000000000000"), currency::wide_difficulty_type("2706215015598282356")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1810000000000000000000000000"), currency::wide_difficulty_type("2706215015598282355")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1815000000000000000000000000"), currency::wide_difficulty_type("2700283360456374682")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1815000000000000000000000000"), currency::wide_difficulty_type("2700283360456374681")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1820000000000000000000000000"), currency::wide_difficulty_type("2694410029579647946")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1820000000000000000000000000"), currency::wide_difficulty_type("2694410029579647945")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1825000000000000000000000000"), currency::wide_difficulty_type("2688594166947924317")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1825000000000000000000000000"), currency::wide_difficulty_type("2688594166947924316")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1830000000000000000000000000"), currency::wide_difficulty_type("2682834933211115942")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1830000000000000000000000000"), currency::wide_difficulty_type("2682834933211115941")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1835000000000000000000000000"), currency::wide_difficulty_type("2677131505285400445")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1835000000000000000000000000"), currency::wide_difficulty_type("2677131505285400444")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1840000000000000000000000000"), currency::wide_difficulty_type("2671483075961078746")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1840000000000000000000000000"), currency::wide_difficulty_type("2671483075961078745")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1845000000000000000000000000"), currency::wide_difficulty_type("2665888853521722831")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1845000000000000000000000000"), currency::wide_difficulty_type("2665888853521722830")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1850000000000000000000000000"), currency::wide_difficulty_type("2660348061374236044")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1850000000000000000000000000"), currency::wide_difficulty_type("2660348061374236043")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1855000000000000000000000000"), currency::wide_difficulty_type("2654859937689462866")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1855000000000000000000000000"), currency::wide_difficulty_type("2654859937689462865")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1860000000000000000000000000"), currency::wide_difficulty_type("2649423735052998850")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1860000000000000000000000000"), currency::wide_difficulty_type("2649423735052998849")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1865000000000000000000000000"), currency::wide_difficulty_type("2644038720125864563")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1865000000000000000000000000"), currency::wide_difficulty_type("2644038720125864562")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1870000000000000000000000000"), currency::wide_difficulty_type("2638704173314719972")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1870000000000000000000000000"), currency::wide_difficulty_type("2638704173314719971")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1875000000000000000000000000"), currency::wide_difficulty_type("2633419388451307786")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1875000000000000000000000000"), currency::wide_difficulty_type("2633419388451307785")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1880000000000000000000000000"), currency::wide_difficulty_type("2628183672480825857")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1880000000000000000000000000"), currency::wide_difficulty_type("2628183672480825856")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1885000000000000000000000000"), currency::wide_difficulty_type("2622996345158939776")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1885000000000000000000000000"), currency::wide_difficulty_type("2622996345158939775")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1890000000000000000000000000"), currency::wide_difficulty_type("2617856738757157503")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1890000000000000000000000000"), currency::wide_difficulty_type("2617856738757157502")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1895000000000000000000000000"), currency::wide_difficulty_type("2612764197776297996")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1895000000000000000000000000"), currency::wide_difficulty_type("2612764197776297995")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1900000000000000000000000000"), currency::wide_difficulty_type("2607718078667795597")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1900000000000000000000000000"), currency::wide_difficulty_type("2607718078667795596")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1905000000000000000000000000"), currency::wide_difficulty_type("2602717749562591346")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1905000000000000000000000000"), currency::wide_difficulty_type("2602717749562591345")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1910000000000000000000000000"), currency::wide_difficulty_type("2597762590007371298")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1910000000000000000000000000"), currency::wide_difficulty_type("2597762590007371297")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1915000000000000000000000000"), currency::wide_difficulty_type("2592851990707920649")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1915000000000000000000000000"), currency::wide_difficulty_type("2592851990707920648")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1920000000000000000000000000"), currency::wide_difficulty_type("2587985353279370678")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1920000000000000000000000000"), currency::wide_difficulty_type("2587985353279370677")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1925000000000000000000000000"), currency::wide_difficulty_type("2583162090003123494")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1925000000000000000000000000"), currency::wide_difficulty_type("2583162090003123493")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1930000000000000000000000000"), currency::wide_difficulty_type("2578381623590247222")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1930000000000000000000000000"), currency::wide_difficulty_type("2578381623590247221")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1935000000000000000000000000"), currency::wide_difficulty_type("2573643386951141553")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1935000000000000000000000000"), currency::wide_difficulty_type("2573643386951141552")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1940000000000000000000000000"), currency::wide_difficulty_type("2568946822971280653")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1940000000000000000000000000"), currency::wide_difficulty_type("2568946822971280652")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1945000000000000000000000000"), currency::wide_difficulty_type("2564291384292847167")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1945000000000000000000000000"), currency::wide_difficulty_type("2564291384292847166")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1950000000000000000000000000"), currency::wide_difficulty_type("2559676533102077564")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1950000000000000000000000000"), currency::wide_difficulty_type("2559676533102077563")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1955000000000000000000000000"), currency::wide_difficulty_type("2555101740922145295")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1955000000000000000000000000"), currency::wide_difficulty_type("2555101740922145294")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1960000000000000000000000000"), currency::wide_difficulty_type("2550566488411414260")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1960000000000000000000000000"), currency::wide_difficulty_type("2550566488411414259")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1965000000000000000000000000"), currency::wide_difficulty_type("2546070265166900802")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1965000000000000000000000000"), currency::wide_difficulty_type("2546070265166900801")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1970000000000000000000000000"), currency::wide_difficulty_type("2541612569532788044")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1970000000000000000000000000"), currency::wide_difficulty_type("2541612569532788043")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1975000000000000000000000000"), currency::wide_difficulty_type("2537192908413841681")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1975000000000000000000000000"), currency::wide_difficulty_type("2537192908413841680")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1980000000000000000000000000"), currency::wide_difficulty_type("2532810797093581470")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1980000000000000000000000000"), currency::wide_difficulty_type("2532810797093581469")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1985000000000000000000000000"), currency::wide_difficulty_type("2528465759057067615")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1985000000000000000000000000"), currency::wide_difficulty_type("2528465759057067614")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1990000000000000000000000000"), currency::wide_difficulty_type("2524157325818165947")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1990000000000000000000000000"), currency::wide_difficulty_type("2524157325818165946")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1995000000000000000000000000"), currency::wide_difficulty_type("2519885036751160428")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("1995000000000000000000000000"), currency::wide_difficulty_type("2519885036751160427")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2000000000000000000000000000"), currency::wide_difficulty_type("2515648438926585831")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2000000000000000000000000000"), currency::wide_difficulty_type("2515648438926585830")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2005000000000000000000000000"), currency::wide_difficulty_type("2511447086951157734")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2005000000000000000000000000"), currency::wide_difficulty_type("2511447086951157733")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2010000000000000000000000000"), currency::wide_difficulty_type("2507280542811681016")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2010000000000000000000000000"), currency::wide_difficulty_type("2507280542811681015")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2015000000000000000000000000"), currency::wide_difficulty_type("2503148375722821955")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2015000000000000000000000000"), currency::wide_difficulty_type("2503148375722821954")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2020000000000000000000000000"), currency::wide_difficulty_type("2499050161978632830")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2020000000000000000000000000"), currency::wide_difficulty_type("2499050161978632829")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2025000000000000000000000000"), currency::wide_difficulty_type("2494985484807721531")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2025000000000000000000000000"), currency::wide_difficulty_type("2494985484807721530")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2030000000000000000000000000"), currency::wide_difficulty_type("2490953934231962225")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2030000000000000000000000000"), currency::wide_difficulty_type("2490953934231962224")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2035000000000000000000000000"), currency::wide_difficulty_type("2486955106928646474")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2035000000000000000000000000"), currency::wide_difficulty_type("2486955106928646473")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2040000000000000000000000000"), currency::wide_difficulty_type("2482988606095977448")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2040000000000000000000000000"), currency::wide_difficulty_type("2482988606095977447")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2045000000000000000000000000"), currency::wide_difficulty_type("2479054041321813044")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2045000000000000000000000000"), currency::wide_difficulty_type("2479054041321813043")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2050000000000000000000000000"), currency::wide_difficulty_type("2475151028455566714")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2050000000000000000000000000"), currency::wide_difficulty_type("2475151028455566713")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2055000000000000000000000000"), currency::wide_difficulty_type("2471279189483177729")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2055000000000000000000000000"), currency::wide_difficulty_type("2471279189483177728")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2060000000000000000000000000"), currency::wide_difficulty_type("2467438152405065410")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2060000000000000000000000000"), currency::wide_difficulty_type("2467438152405065409")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2065000000000000000000000000"), currency::wide_difficulty_type("2463627551116984585")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2065000000000000000000000000"), currency::wide_difficulty_type("2463627551116984584")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2070000000000000000000000000"), currency::wide_difficulty_type("2459847025293702108")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2070000000000000000000000000"), currency::wide_difficulty_type("2459847025293702107")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2075000000000000000000000000"), currency::wide_difficulty_type("2456096220275416833")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2075000000000000000000000000"), currency::wide_difficulty_type("2456096220275416832")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2080000000000000000000000000"), currency::wide_difficulty_type("2452374786956847850")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2080000000000000000000000000"), currency::wide_difficulty_type("2452374786956847849")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2085000000000000000000000000"), currency::wide_difficulty_type("2448682381678918120")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2085000000000000000000000000"), currency::wide_difficulty_type("2448682381678918119")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2090000000000000000000000000"), currency::wide_difficulty_type("2445018666122962957")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2090000000000000000000000000"), currency::wide_difficulty_type("2445018666122962956")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2095000000000000000000000000"), currency::wide_difficulty_type("2441383307207394935")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2095000000000000000000000000"), currency::wide_difficulty_type("2441383307207394934")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2100000000000000000000000000"), currency::wide_difficulty_type("2437775976986758940")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2100000000000000000000000000"), currency::wide_difficulty_type("2437775976986758939")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2105000000000000000000000000"), currency::wide_difficulty_type("2434196352553113130")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2105000000000000000000000000"), currency::wide_difficulty_type("2434196352553113129")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2110000000000000000000000000"), currency::wide_difficulty_type("2430644115939673490")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2110000000000000000000000000"), currency::wide_difficulty_type("2430644115939673489")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2115000000000000000000000000"), currency::wide_difficulty_type("2427118954026661635")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2115000000000000000000000000"), currency::wide_difficulty_type("2427118954026661634")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2120000000000000000000000000"), currency::wide_difficulty_type("2423620558449297271")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2120000000000000000000000000"), currency::wide_difficulty_type("2423620558449297270")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2125000000000000000000000000"), currency::wide_difficulty_type("2420148625507878558")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2125000000000000000000000000"), currency::wide_difficulty_type("2420148625507878557")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2130000000000000000000000000"), currency::wide_difficulty_type("2416702856079895306")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2130000000000000000000000000"), currency::wide_difficulty_type("2416702856079895305")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2135000000000000000000000000"), currency::wide_difficulty_type("2413282955534121575")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2135000000000000000000000000"), currency::wide_difficulty_type("2413282955534121574")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2140000000000000000000000000"), currency::wide_difficulty_type("2409888633646635875")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2140000000000000000000000000"), currency::wide_difficulty_type("2409888633646635874")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2145000000000000000000000000"), currency::wide_difficulty_type("2406519604518718694")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2145000000000000000000000000"), currency::wide_difficulty_type("2406519604518718693")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2150000000000000000000000000"), currency::wide_difficulty_type("2403175586496578565")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2150000000000000000000000000"), currency::wide_difficulty_type("2403175586496578564")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2155000000000000000000000000"), currency::wide_difficulty_type("2399856302092859343")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2155000000000000000000000000"), currency::wide_difficulty_type("2399856302092859342")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2160000000000000000000000000"), currency::wide_difficulty_type("2396561477909882754")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2160000000000000000000000000"), currency::wide_difficulty_type("2396561477909882753")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2165000000000000000000000000"), currency::wide_difficulty_type("2393290844564581615")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2165000000000000000000000000"), currency::wide_difficulty_type("2393290844564581614")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2170000000000000000000000000"), currency::wide_difficulty_type("2390044136615080450")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2170000000000000000000000000"), currency::wide_difficulty_type("2390044136615080449")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2175000000000000000000000000"), currency::wide_difficulty_type("2386821092488881460")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2175000000000000000000000000"), currency::wide_difficulty_type("2386821092488881459")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2180000000000000000000000000"), currency::wide_difficulty_type("2383621454412615068")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2180000000000000000000000000"), currency::wide_difficulty_type("2383621454412615067")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2185000000000000000000000000"), currency::wide_difficulty_type("2380444968343315390")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2185000000000000000000000000"), currency::wide_difficulty_type("2380444968343315389")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2190000000000000000000000000"), currency::wide_difficulty_type("2377291383901182163")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2190000000000000000000000000"), currency::wide_difficulty_type("2377291383901182162")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2195000000000000000000000000"), currency::wide_difficulty_type("2374160454303791767")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2195000000000000000000000000"), currency::wide_difficulty_type("2374160454303791766")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2200000000000000000000000000"), currency::wide_difficulty_type("2371051936301721016")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2200000000000000000000000000"), currency::wide_difficulty_type("2371051936301721015")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2205000000000000000000000000"), currency::wide_difficulty_type("2367965590115548453")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2205000000000000000000000000"), currency::wide_difficulty_type("2367965590115548452")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2210000000000000000000000000"), currency::wide_difficulty_type("2364901179374198904")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2210000000000000000000000000"), currency::wide_difficulty_type("2364901179374198903")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2215000000000000000000000000"), currency::wide_difficulty_type("2361858471054597963")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2215000000000000000000000000"), currency::wide_difficulty_type("2361858471054597962")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2220000000000000000000000000"), currency::wide_difficulty_type("2358837235422604080")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2220000000000000000000000000"), currency::wide_difficulty_type("2358837235422604079")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2225000000000000000000000000"), currency::wide_difficulty_type("2355837245975186797")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2225000000000000000000000000"), currency::wide_difficulty_type("2355837245975186796")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2230000000000000000000000000"), currency::wide_difficulty_type("2352858279383820553")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2230000000000000000000000000"), currency::wide_difficulty_type("2352858279383820552")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2235000000000000000000000000"), currency::wide_difficulty_type("2349900115439064383")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2235000000000000000000000000"), currency::wide_difficulty_type("2349900115439064382")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2240000000000000000000000000"), currency::wide_difficulty_type("2346962536996298585")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2240000000000000000000000000"), currency::wide_difficulty_type("2346962536996298584")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2245000000000000000000000000"), currency::wide_difficulty_type("2344045329922590311")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2245000000000000000000000000"), currency::wide_difficulty_type("2344045329922590310")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2250000000000000000000000000"), currency::wide_difficulty_type("2341148283044660753")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2250000000000000000000000000"), currency::wide_difficulty_type("2341148283044660752")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2255000000000000000000000000"), currency::wide_difficulty_type("2338271188097927374")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2255000000000000000000000000"), currency::wide_difficulty_type("2338271188097927373")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2260000000000000000000000000"), currency::wide_difficulty_type("2335413839676595372")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2260000000000000000000000000"), currency::wide_difficulty_type("2335413839676595371")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2265000000000000000000000000"), currency::wide_difficulty_type("2332576035184773241")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2265000000000000000000000000"), currency::wide_difficulty_type("2332576035184773240")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2270000000000000000000000000"), currency::wide_difficulty_type("2329757574788588008")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2270000000000000000000000000"), currency::wide_difficulty_type("2329757574788588007")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2275000000000000000000000000"), currency::wide_difficulty_type("2326958261369276374")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2275000000000000000000000000"), currency::wide_difficulty_type("2326958261369276373")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2280000000000000000000000000"), currency::wide_difficulty_type("2324177900477228635")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2280000000000000000000000000"), currency::wide_difficulty_type("2324177900477228634")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2285000000000000000000000000"), currency::wide_difficulty_type("2321416300286962874")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2285000000000000000000000000"), currency::wide_difficulty_type("2321416300286962873")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2290000000000000000000000000"), currency::wide_difficulty_type("2318673271553007540")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2290000000000000000000000000"), currency::wide_difficulty_type("2318673271553007539")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2295000000000000000000000000"), currency::wide_difficulty_type("2315948627566671091")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2295000000000000000000000000"), currency::wide_difficulty_type("2315948627566671090")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2300000000000000000000000000"), currency::wide_difficulty_type("2313242184113677981")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2300000000000000000000000000"), currency::wide_difficulty_type("2313242184113677980")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2305000000000000000000000000"), currency::wide_difficulty_type("2310553759432650776")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2305000000000000000000000000"), currency::wide_difficulty_type("2310553759432650775")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2310000000000000000000000000"), currency::wide_difficulty_type("2307883174174418780")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2310000000000000000000000000"), currency::wide_difficulty_type("2307883174174418779")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2315000000000000000000000000"), currency::wide_difficulty_type("2305230251362134008")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2315000000000000000000000000"), currency::wide_difficulty_type("2305230251362134007")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2320000000000000000000000000"), currency::wide_difficulty_type("2302594816352175903")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2320000000000000000000000000"), currency::wide_difficulty_type("2302594816352175902")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2325000000000000000000000000"), currency::wide_difficulty_type("2299976696795826646")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2325000000000000000000000000"), currency::wide_difficulty_type("2299976696795826645")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2330000000000000000000000000"), currency::wide_difficulty_type("2297375722601699401")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2330000000000000000000000000"), currency::wide_difficulty_type("2297375722601699400")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2335000000000000000000000000"), currency::wide_difficulty_type("2294791725898902291")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2335000000000000000000000000"), currency::wide_difficulty_type("2294791725898902290")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2340000000000000000000000000"), currency::wide_difficulty_type("2292224541000921359")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2340000000000000000000000000"), currency::wide_difficulty_type("2292224541000921358")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2345000000000000000000000000"), currency::wide_difficulty_type("2289674004370206180")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2345000000000000000000000000"), currency::wide_difficulty_type("2289674004370206179")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2350000000000000000000000000"), currency::wide_difficulty_type("2287139954583442248")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2350000000000000000000000000"), currency::wide_difficulty_type("2287139954583442247")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2355000000000000000000000000"), currency::wide_difficulty_type("2284622232297494626")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2355000000000000000000000000"), currency::wide_difficulty_type("2284622232297494625")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2360000000000000000000000000"), currency::wide_difficulty_type("2282120680216007790")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2360000000000000000000000000"), currency::wide_difficulty_type("2282120680216007789")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2365000000000000000000000000"), currency::wide_difficulty_type("2279635143056646954")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2365000000000000000000000000"), currency::wide_difficulty_type("2279635143056646953")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2370000000000000000000000000"), currency::wide_difficulty_type("2277165467518966551")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2370000000000000000000000000"), currency::wide_difficulty_type("2277165467518966550")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2375000000000000000000000000"), currency::wide_difficulty_type("2274711502252891900")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2375000000000000000000000000"), currency::wide_difficulty_type("2274711502252891899")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2380000000000000000000000000"), currency::wide_difficulty_type("2272273097827800467")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2380000000000000000000000000"), currency::wide_difficulty_type("2272273097827800466")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2385000000000000000000000000"), currency::wide_difficulty_type("2269850106702189431")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2385000000000000000000000000"), currency::wide_difficulty_type("2269850106702189430")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2390000000000000000000000000"), currency::wide_difficulty_type("2267442383193916647")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2390000000000000000000000000"), currency::wide_difficulty_type("2267442383193916646")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2395000000000000000000000000"), currency::wide_difficulty_type("2265049783451002382")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2395000000000000000000000000"), currency::wide_difficulty_type("2265049783451002381")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2400000000000000000000000000"), currency::wide_difficulty_type("2262672165422979551")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2400000000000000000000000000"), currency::wide_difficulty_type("2262672165422979550")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2405000000000000000000000000"), currency::wide_difficulty_type("2260309388832780454")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2405000000000000000000000000"), currency::wide_difficulty_type("2260309388832780453")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2410000000000000000000000000"), currency::wide_difficulty_type("2257961315149148341")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2410000000000000000000000000"), currency::wide_difficulty_type("2257961315149148340")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2415000000000000000000000000"), currency::wide_difficulty_type("2255627807559562398")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2415000000000000000000000000"), currency::wide_difficulty_type("2255627807559562397")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2420000000000000000000000000"), currency::wide_difficulty_type("2253308730943665060")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2420000000000000000000000000"), currency::wide_difficulty_type("2253308730943665059")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2425000000000000000000000000"), currency::wide_difficulty_type("2251003951847180788")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2425000000000000000000000000"), currency::wide_difficulty_type("2251003951847180787")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2430000000000000000000000000"), currency::wide_difficulty_type("2248713338456315756")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2430000000000000000000000000"), currency::wide_difficulty_type("2248713338456315755")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2435000000000000000000000000"), currency::wide_difficulty_type("2246436760572628130")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2435000000000000000000000000"), currency::wide_difficulty_type("2246436760572628129")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2440000000000000000000000000"), currency::wide_difficulty_type("2244174089588358868")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2440000000000000000000000000"), currency::wide_difficulty_type("2244174089588358867")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2445000000000000000000000000"), currency::wide_difficulty_type("2241925198462213242")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2445000000000000000000000000"), currency::wide_difficulty_type("2241925198462213241")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2450000000000000000000000000"), currency::wide_difficulty_type("2239689961695583486")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2450000000000000000000000000"), currency::wide_difficulty_type("2239689961695583485")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2455000000000000000000000000"), currency::wide_difficulty_type("2237468255309203239")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2455000000000000000000000000"), currency::wide_difficulty_type("2237468255309203238")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2460000000000000000000000000"), currency::wide_difficulty_type("2235259956820224654")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2460000000000000000000000000"), currency::wide_difficulty_type("2235259956820224653")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2465000000000000000000000000"), currency::wide_difficulty_type("2233064945219709271")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2465000000000000000000000000"), currency::wide_difficulty_type("2233064945219709270")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2470000000000000000000000000"), currency::wide_difficulty_type("2230883100950523974")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2470000000000000000000000000"), currency::wide_difficulty_type("2230883100950523973")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2475000000000000000000000000"), currency::wide_difficulty_type("2228714305885633552")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2475000000000000000000000000"), currency::wide_difficulty_type("2228714305885633551")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2480000000000000000000000000"), currency::wide_difficulty_type("2226558443306781569")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2480000000000000000000000000"), currency::wide_difficulty_type("2226558443306781568")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2485000000000000000000000000"), currency::wide_difficulty_type("2224415397883551498")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2485000000000000000000000000"), currency::wide_difficulty_type("2224415397883551497")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2490000000000000000000000000"), currency::wide_difficulty_type("2222285055652800188")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2490000000000000000000000000"), currency::wide_difficulty_type("2222285055652800187")); + ASSERT_FALSE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2495000000000000000000000000"), currency::wide_difficulty_type("2220167303998455999")); + ASSERT_TRUE(res); + res = if_alt_chain_stronger_hf4(currency::wide_difficulty_type("2495000000000000000000000000"), currency::wide_difficulty_type("2220167303998455998")); + ASSERT_FALSE(res); + + } From e5f0fe6e76adac57b4621aece3a810c27b4277e5 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 9 Aug 2024 19:20:09 +0400 Subject: [PATCH 08/23] attempt to fix broken compilation for android(and keep ios healthy with std::filesystrem) --- contrib/epee/include/file_io_utils.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h index b6fedbc1..bb21ae99 100644 --- a/contrib/epee/include/file_io_utils.h +++ b/contrib/epee/include/file_io_utils.h @@ -36,16 +36,16 @@ #include #include -#if __has_include() -#include -namespace stdfs = std::filesystem; -#elif __has_include() -#include -namespace stdfs = std::experimental::filesystem; -#else - #error "Neither nor are available." -#endif +#if __has_include() + #include + namespace stdfs = std::filesystem; +#else + #if TARGET_OS_IOS + #error "This should never happen on ios." + #endif + namespace stdfs = boost::filesystem; +#endif //#include From bc552ff6350a144a247344030b5125a1e891eda8 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 01:04:14 +0200 Subject: [PATCH 09/23] kv serialization for asset_descriptor_operation --- src/currency_core/currency_basic.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 0d3e5891..d189c2cd 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -793,6 +793,13 @@ namespace currency BOOST_END_VERSION_UNDER(1) BOOST_SERIALIZE(opt_asset_id) END_BOOST_SERIALIZATION() + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(operation_type) DOC_DSCR("Asset operation type identifier") DOC_EXMP(1) DOC_END + KV_SERIALIZE(descriptor) DOC_DSCR("Asset descriptor") DOC_EXMP_AUTO() DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(amount_commitment) DOC_DSCR("Amount commitment") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(opt_asset_id) DOC_DSCR("ID of an asset.") DOC_EXMP("cc4e69455e63f4a581257382191de6856c2156630b3fba0db4bdd73ffcfb36b6") DOC_END + END_KV_SERIALIZE_MAP() }; struct asset_operation_proof From 2c06293f24830b903f0a60ef8061314542f8163a Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 01:10:22 +0200 Subject: [PATCH 10/23] added additional check for incorrect asset operation type to get_or_calculate_asset_id() --- src/currency_core/currency_format_utils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 2e068644..d706bc3d 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2182,8 +2182,10 @@ namespace currency return true; } - // otherwise, calculate asset id + // otherwise, it must be a register operation + CHECK_AND_ASSERT_MES(ado.operation_type == ASSET_DESCRIPTOR_OPERATION_REGISTER, false, "unexpected asset operation type: " << (int)ado.operation_type << ", " << get_asset_operation_type_string(ado.operation_type)); + // calculate asset id crypto::hash_helper_t::hs_t hsc; hsc.add_32_chars(CRYPTO_HDS_ASSET_ID); hsc.add_hash(crypto::hash_helper_t::h(ado.descriptor.ticker)); From 88a1e9682046ac56f183d4eb4f443b32e59d7b87 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 02:07:25 +0200 Subject: [PATCH 11/23] wallet rpc: split destinations by default (for users convenience) --- src/wallet/wallet_public_structs_defs.h | 12 +++-- src/wallet/wallet_rpc_server.cpp | 59 +++++++++++++++++-------- src/wallet/wallet_rpc_server.h | 3 +- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 3c6eb174..03109c4a 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -1987,10 +1987,12 @@ namespace wallet_public { std::list destinations; currency::asset_descriptor_base asset_descriptor; + bool use_destinations_as_is = false; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END - KV_SERIALIZE(asset_descriptor) DOC_DSCR("Descriptor that holds all information about asset - ticker, emission, description etc") DOC_END + KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(asset_descriptor) DOC_DSCR("Descriptor that holds all information about asset - ticker, emission, description etc") DOC_END + KV_SERIALIZE(use_destinations_as_is) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; @@ -2015,10 +2017,12 @@ namespace wallet_public { crypto::public_key asset_id; std::list destinations; + bool use_destinations_as_is = false; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Id of the asset to emit more coins") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END - KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Id of the asset to emit more coins") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END + KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(use_destinations_as_is) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 39c75e27..c038d874 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1260,13 +1260,46 @@ namespace tools WALLET_RPC_CATCH_TRY_ENTRY(); } //------------------------------------------------------------------------------------------------------------------------------ - void wallet_rpc_server::rpc_destinations_to_currency_destination(const std::list& rpc_destinations, std::vector& currency_destinations) + #define DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT 10 + static_assert(DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT >= CURRENCY_TX_MIN_ALLOWED_OUTS, "DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT must be >= min allowed tx outs"); + void wallet_rpc_server::rpc_destinations_to_currency_destinations(const std::list& rpc_destinations, bool nullify_asset_id, bool try_to_split, std::vector& result_destinations) { GET_WALLET(); - std::vector& dsts = currency_destinations; - for (auto it = rpc_destinations.begin(); it != rpc_destinations.end(); it++) + + WLT_THROW_IF_FALSE_WITH_CODE(!rpc_destinations.empty(), "WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT", "WALLET_RPC_ERROR_CODE_WRONG_ARGUMENT"); + + std::list local_destinations; + if (nullify_asset_id && try_to_split) { - currency::tx_destination_entry de; + bool do_split = true; + uint64_t total_amount = rpc_destinations.front().amount; + std::string first_address = rpc_destinations.front().address; + for(auto it = std::next(rpc_destinations.begin()); it != rpc_destinations.end(); ++it) + { + total_amount += it->amount; + if (first_address != it->address) + { + do_split = false; + break; + } + } + if (do_split) + { + const uint64_t el_amount = total_amount / DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT; // approximation, see below + wallet_public::transfer_destination td{}; + td.address = first_address; + td.amount = el_amount; + for(size_t i = 0; i < DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT - 1; ++i) + local_destinations.push_back(td); + td.amount = total_amount - (DESTINATIONS_COUNT_FOR_DEPLOY_OR_EMIT - 1) * el_amount; // the last element must account for division error + local_destinations.push_back(td); + } + } + const std::list& destinations = local_destinations.size() != 0 ? local_destinations : rpc_destinations; + + for (auto it = destinations.begin(); it != destinations.end(); ++it) + { + currency::tx_destination_entry de{}; de.addr.resize(1); std::string embedded_payment_id; //check if address looks like wrapped address @@ -1274,8 +1307,8 @@ namespace tools WLT_THROW_IF_FALSE_WITH_CODE(w.get_wallet()->get_transfer_address(it->address, de.addr.back(), embedded_payment_id), "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); WLT_THROW_IF_FALSE_WITH_CODE(embedded_payment_id.size() == 0, "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS", "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS"); de.amount = it->amount; - de.asset_id = it->asset_id; - dsts.push_back(de); + de.asset_id = nullify_asset_id ? currency::null_pkey : it->asset_id; + result_destinations.push_back(de); } } //------------------------------------------------------------------------------------------------------------------------------ @@ -1285,12 +1318,7 @@ namespace tools currency::transaction result_tx; std::vector currency_destinations; - rpc_destinations_to_currency_destination(req.destinations, currency_destinations); - //fix for default asset_id - for (auto& d : currency_destinations) - { - d.asset_id = currency::null_pkey; - } + rpc_destinations_to_currency_destinations(req.destinations, true, !req.use_destinations_as_is, currency_destinations); w.get_wallet()->deploy_new_asset(req.asset_descriptor, currency_destinations, result_tx, res.new_asset_id); res.result_tx = currency::get_transaction_hash(result_tx); @@ -1303,12 +1331,7 @@ namespace tools WALLET_RPC_BEGIN_TRY_ENTRY(); currency::transaction result_tx; std::vector currency_destinations; - rpc_destinations_to_currency_destination(req.destinations, currency_destinations); - //fix for default asset_id - for (auto& d : currency_destinations) - { - d.asset_id = currency::null_pkey; - } + rpc_destinations_to_currency_destinations(req.destinations, true, !req.use_destinations_as_is, currency_destinations); w.get_wallet()->emit_asset(req.asset_id, currency_destinations, result_tx); res.result_tx = currency::get_transaction_hash(result_tx); diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 4eac9211..77b393a5 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -238,7 +238,8 @@ namespace tools //bool reset_active_wallet(std::shared_ptr w); bool handle_command_line(const boost::program_options::variables_map& vm); - void rpc_destinations_to_currency_destination(const std::list& rpc_destinations, std::vector& currency_destinations); + void rpc_destinations_to_currency_destinations(const std::list& rpc_destinations, bool nullify_asset_id, bool try_to_split, std::vector& currency_destinations); + private: std::shared_ptr m_pwallet_provider_sh_ptr; From 9f0fa8a390e10fc0525a01a9409e52765fb93e07 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 19:22:48 +0200 Subject: [PATCH 12/23] wallet rpc: parameter renamed --- src/wallet/wallet_public_structs_defs.h | 8 ++++---- src/wallet/wallet_rpc_server.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 03109c4a..66723b22 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -1987,12 +1987,12 @@ namespace wallet_public { std::list destinations; currency::asset_descriptor_base asset_descriptor; - bool use_destinations_as_is = false; + bool do_not_split_destinations = false; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END KV_SERIALIZE(asset_descriptor) DOC_DSCR("Descriptor that holds all information about asset - ticker, emission, description etc") DOC_END - KV_SERIALIZE(use_destinations_as_is) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END + KV_SERIALIZE(do_not_split_destinations) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; @@ -2017,12 +2017,12 @@ namespace wallet_public { crypto::public_key asset_id; std::list destinations; - bool use_destinations_as_is = false; + bool do_not_split_destinations = false; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Id of the asset to emit more coins") DOC_EXMP("40fa6db923728b38962718c61b4dc3af1acaa1967479c73703e260dc3609c58d") DOC_END KV_SERIALIZE(destinations) DOC_DSCR("Addresses where to receive emitted coins. Asset id in the destinations is irreleant and can be omitted.") DOC_EXMP_AUTO(1) DOC_END - KV_SERIALIZE(use_destinations_as_is) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END + KV_SERIALIZE(do_not_split_destinations) DOC_DSCR("If true, the provided destinations will be used as-is and won't be splitted (or altered) to avoid common issues. Default is false.") DOC_EXMP(false) DOC_END END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index c038d874..f6deeca6 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1318,7 +1318,7 @@ namespace tools currency::transaction result_tx; std::vector currency_destinations; - rpc_destinations_to_currency_destinations(req.destinations, true, !req.use_destinations_as_is, currency_destinations); + rpc_destinations_to_currency_destinations(req.destinations, true, !req.do_not_split_destinations, currency_destinations); w.get_wallet()->deploy_new_asset(req.asset_descriptor, currency_destinations, result_tx, res.new_asset_id); res.result_tx = currency::get_transaction_hash(result_tx); @@ -1331,7 +1331,7 @@ namespace tools WALLET_RPC_BEGIN_TRY_ENTRY(); currency::transaction result_tx; std::vector currency_destinations; - rpc_destinations_to_currency_destinations(req.destinations, true, !req.use_destinations_as_is, currency_destinations); + rpc_destinations_to_currency_destinations(req.destinations, true, !req.do_not_split_destinations, currency_destinations); w.get_wallet()->emit_asset(req.asset_id, currency_destinations, result_tx); res.result_tx = currency::get_transaction_hash(result_tx); From f0c7d57c4161774b68a86d1bd98138fbbf5c43ae Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 21:04:51 +0200 Subject: [PATCH 13/23] LMDB: implemented experimental conversion from 4k pages to 16k pages (untested) --- src/common/db_backend_lmdb.cpp | 59 ++++++++++++++++++++++++++++- src/common/db_backend_lmdb.h | 5 ++- src/connectivity_tool/conn_tool.cpp | 36 +++++++++++++++++- 3 files changed, 97 insertions(+), 3 deletions(-) diff --git a/src/common/db_backend_lmdb.cpp b/src/common/db_backend_lmdb.cpp index 75e60ce4..d23fff80 100644 --- a/src/common/db_backend_lmdb.cpp +++ b/src/common/db_backend_lmdb.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2019 Zano Project +// Copyright (c) 2014-2024 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -394,10 +394,67 @@ namespace tools } return true; } + const char* lmdb_db_backend::name() { return "lmdb"; } + + bool lmdb_db_backend::convert_db_4kb_page_to_16kb_page(const std::string& source_path, const std::string& destination_path) + { + #define MDB_CHECK(x, msg) {int rc = x; CHECK_AND_ASSERT_MES(rc == MDB_SUCCESS, false, "LMDB 4k->16k error: " << msg << ": " << mdb_strerror(rc));} + + MDB_env *env_src = nullptr, *env_dst = nullptr; + + // source + MDB_CHECK(mdb_env_create(&env_src), "failed to create LMDB environment"); + MDB_CHECK(mdb_env_set_mapsize(env_src, 4 * 1024 * 1024), "failed to set mapsize"); // mapsize ? + MDB_CHECK(mdb_env_open(env_src, source_path.c_str(), 0, 0664), "failed to open source LMDB"); + + // destination (16k page size) + MDB_CHECK(mdb_env_create(&env_dst), "failed to create LMDB environment"); + MDB_CHECK(mdb_env_set_mapsize(env_dst, 16 * 1024 * 1024), "failed to set mapsize"); // mapsize ? + + // TODO uncomment after mdb_env_set_pagesize is supported + // MDB_CHECK(mdb_env_set_pagesize(env_dst, 16 * 1024), "failed to set page size to 16K"); + + MDB_CHECK(mdb_env_open(env_dst, destination_path.c_str(), 0, 0664), "failed to open destination LMDB"); + + // begin transactions + MDB_txn *txn_src = nullptr, *txn_dst = nullptr; + MDB_dbi dbi_src, dbi_dst; + MDB_CHECK(mdb_txn_begin(env_src, nullptr, MDB_RDONLY, &txn_src), "failed to begin source transaction"); + MDB_CHECK(mdb_dbi_open(txn_src, nullptr, 0, &dbi_src), "failed to open source database"); + MDB_CHECK(mdb_txn_begin(env_dst, nullptr, 0, &txn_dst), "failed to begin destination transaction"); + MDB_CHECK(mdb_dbi_open(txn_dst, nullptr, MDB_CREATE, &dbi_dst), "failed to open destination database"); + + MDB_cursor *cursor; + MDB_val key, data; + + // Iterate over the source database and copy all key-value pairs to the destination database + MDB_CHECK(mdb_cursor_open(txn_src, dbi_src, &cursor), "failed to open cursor"); + + while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == MDB_SUCCESS) + { + MDB_CHECK(mdb_put(txn_dst, dbi_dst, &key, &data, 0), "failed to put data in destination database"); + } + + mdb_cursor_close(cursor); + + // commit transactions + MDB_CHECK(mdb_txn_commit(txn_src), "failed to commit source transaction"); + MDB_CHECK(mdb_txn_commit(txn_dst), "failed to commit destination transaction"); + + mdb_dbi_close(env_src, dbi_src); + mdb_dbi_close(env_dst, dbi_dst); + mdb_env_close(env_src); + mdb_env_close(env_dst); + + return true; + + #undef MDB_CHECK + } + } } diff --git a/src/common/db_backend_lmdb.h b/src/common/db_backend_lmdb.h index ef56c346..c2920f0c 100644 --- a/src/common/db_backend_lmdb.h +++ b/src/common/db_backend_lmdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2019 Zano Project +// Copyright (c) 2014-2024 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -36,6 +36,7 @@ namespace tools boost::recursive_mutex m_write_exclusive_lock; std::map m_txs; // size_t -> count of nested read_only transactions bool pop_tx_entry(tx_entry& txe); + public: lmdb_db_backend(); ~lmdb_db_backend(); @@ -60,6 +61,8 @@ namespace tools bool have_tx(); MDB_txn* get_current_tx(); + static bool convert_db_4kb_page_to_16kb_page(const std::string& source_path, const std::string& destination_path); + }; } } diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index 07528c56..94df1835 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2019 Zano Project +// Copyright (c) 2014-2024 Zano Project // Copyright (c) 2014-2018 The Louisdor Project // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying @@ -25,6 +25,7 @@ using namespace epee; #include "storages/http_abstract_invoke.h" #include "net/http_client.h" #include "currency_core/genesis_acc.h" +#include "common/db_backend_lmdb.h" #include namespace po = boost::program_options; @@ -63,6 +64,7 @@ namespace const command_line::arg_descriptor arg_pack_file ("pack-file", "perform gzip-packing and calculate hash for a given file"); const command_line::arg_descriptor arg_unpack_file ("unpack-file", "Perform gzip-unpacking and calculate hash for a given file"); const command_line::arg_descriptor arg_target_file ("target-file", "Specify target file for pack-file and unpack-file commands"); + const command_line::arg_descriptor arg_lmdb_page_4to16 ("convert-lmdb-4to16", "Perform LMDB conversion from 4k page size to 16k page size"); //const command_line::arg_descriptor arg_send_ipc ("send-ipc", "Send IPC request to UI"); } @@ -1251,6 +1253,34 @@ bool handle_pack_file(po::variables_map& vm) } } +bool handle_lmdb_page_4to16(po::variables_map& vm) +{ + std::string path_source; + std::string path_target; + + if (!command_line::has_arg(vm, arg_lmdb_page_4to16)) + return false; + + path_source = command_line::get_arg(vm, arg_lmdb_page_4to16); + + if (!command_line::has_arg(vm, arg_target_file)) + { + std::cout << "Error: Parameter target_file is not set." << ENDL; + return false; + } + path_target = command_line::get_arg(vm, arg_target_file); + + if (tools::db::lmdb_db_backend::convert_db_4kb_page_to_16kb_page(path_source, path_target)) + { + std::cout << "Conversion failed" << ENDL; + return false; + } + + std::cout << "Converted successfully" << ENDL; + return true; +} + + //--------------------------------------------------------------------------------------------------------------- int main(int argc, char* argv[]) @@ -1375,6 +1405,10 @@ int main(int argc, char* argv[]) { return handle_pack_file(vm) ? EXIT_SUCCESS : EXIT_FAILURE; } + else if (command_line::has_arg(vm, arg_lmdb_page_4to16)) + { + return handle_lmdb_page_4to16(vm) ? EXIT_SUCCESS : EXIT_FAILURE; + } /*else if (command_line::has_arg(vm, arg_send_ipc)) { handle_send_ipc(command_line::get_arg(vm, arg_send_ipc)) ? EXIT_SUCCESS : EXIT_FAILURE; From 0c90262e8a1c4e5e5d052f8db84c60a36691414d Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 13 Aug 2024 21:05:48 +0200 Subject: [PATCH 14/23] conn_tool: fixed minor error --- src/connectivity_tool/conn_tool.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index 94df1835..a7c32892 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -1222,7 +1222,10 @@ bool handle_pack_file(po::variables_map& vm) } if (!command_line::has_arg(vm, arg_target_file)) + { std::cout << "Error: Parameter target_file is not set." << ENDL; + return false; + } path_target = command_line::get_arg(vm, arg_target_file); std::ifstream source; From fde28efdc5d7efe8741dcb0e62ea0aebc805a373 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 14 Aug 2024 23:20:58 +0400 Subject: [PATCH 15/23] latest fixes for cake wallet --- CMakeLists.txt | 7 ++++++- src/crypto/random.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04790815..e320fafc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,7 +226,12 @@ endif() message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_OSX_DEPLOYMENT_TARGET 12.00) - set(Boost_LIBRARIES "libboost.a") + if(NOT DEFINED SKIP_BOOST_FATLIB_LIB OR NOT SKIP_BOOST_FATLIB_LIB) + message("Ios: libboost.a included as library") + set(Boost_LIBRARIES "libboost.a") + else() + message("Ios: libboost.a not included as library") + endif() #workaround for new XCode 12 policy for builds(now it includes a slice for the "arm64" when builds for simulator) set(__iphoneos_archs "arm64") #set(__iphonesimulator_archs "arm64,x86_64") diff --git a/src/crypto/random.c b/src/crypto/random.c index bdac1e7a..a54bdf74 100644 --- a/src/crypto/random.c +++ b/src/crypto/random.c @@ -43,7 +43,7 @@ void generate_system_random_bytes(size_t n, void *result) { void generate_system_random_bytes(size_t n, void *result) { int fd; if ((fd = open("/dev/urandom", O_RDONLY | O_NOCTTY | O_CLOEXEC)) < 0) { - err(EXIT_FAILURE, "open /dev/urandom"); + exit(EXIT_FAILURE); } for (;;) { ssize_t res = read(fd, result, n); @@ -52,17 +52,17 @@ void generate_system_random_bytes(size_t n, void *result) { } if (res < 0) { if (errno != EINTR) { - err(EXIT_FAILURE, "read /dev/urandom"); + exit(EXIT_FAILURE); } } else if (res == 0) { - errx(EXIT_FAILURE, "read /dev/urandom: end of file"); + exit(EXIT_FAILURE); } else { result = padd(result, (size_t) res); n -= (size_t) res; } } if (close(fd) < 0) { - err(EXIT_FAILURE, "close /dev/urandom"); + exit(EXIT_FAILURE); } } From 9e6faffb4923445bd25fdda405d5f220357924b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=D1=91pa=20Dolgorukov?= Date: Mon, 19 Aug 2024 15:13:56 +0500 Subject: [PATCH 16/23] Create multiassets test (#449) --- tests/unit_tests/multiassets_test.cpp | 1328 +++++++++++++++++++++++++ 1 file changed, 1328 insertions(+) create mode 100644 tests/unit_tests/multiassets_test.cpp diff --git a/tests/unit_tests/multiassets_test.cpp b/tests/unit_tests/multiassets_test.cpp new file mode 100644 index 00000000..4d677aab --- /dev/null +++ b/tests/unit_tests/multiassets_test.cpp @@ -0,0 +1,1328 @@ +// Copyright (c) 2024 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +#include +#include + +#include +#include + +#include "gtest/gtest.h" +#include "serialization/serialization.h" +#include "common/crypto_serialization.h" +#include "serialization/keyvalue_serialization.h" // epee key-value serialization +#include "currency_core/currency_basic.h" +#include "currency_core/currency_format_utils.h" +#include "common/boost_serialization_helper.h" +#include "storages/portable_storage_template_helper.h" + +namespace currency +{ + struct asset_descriptor_base_v0; + struct asset_descriptor_operation_v0; +} + +// develop, commit 0c90262e8a1c4e5e5d052f8db84c60a36691414d +struct currency::asset_descriptor_base_v0 +{ + uint64_t total_max_supply = 0; + uint64_t current_supply = 0; + uint8_t decimal_point = 0; + std::string ticker; + std::string full_name; + std::string meta_info; + crypto::public_key owner = currency::null_pkey; // consider premultipling by 1/8 + bool hidden_supply = false; + uint8_t version = 0; + + BEGIN_VERSIONED_SERIALIZE(0, version) + FIELD(total_max_supply) + FIELD(current_supply) + FIELD(decimal_point) + FIELD(ticker) + FIELD(full_name) + FIELD(meta_info) + FIELD(owner) + FIELD(hidden_supply) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(total_max_supply) + BOOST_SERIALIZE(current_supply) + BOOST_SERIALIZE(decimal_point) + BOOST_SERIALIZE(ticker) + BOOST_SERIALIZE(full_name) + BOOST_SERIALIZE(meta_info) + BOOST_SERIALIZE(owner) + BOOST_SERIALIZE(hidden_supply) + END_BOOST_SERIALIZATION() + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(total_max_supply) DOC_DSCR("Maximum possible supply for given asset, can't be changed after deployment") DOC_EXMP(1000000000000000000) DOC_END + KV_SERIALIZE(current_supply) DOC_DSCR("Currently emitted supply for given asset (ignored for REGISTER operation)") DOC_EXMP(500000000000000000) DOC_END + KV_SERIALIZE(decimal_point) DOC_DSCR("Decimal point") DOC_EXMP(12) DOC_END + KV_SERIALIZE(ticker) DOC_DSCR("Ticker associated with asset") DOC_EXMP("ZUSD") DOC_END + KV_SERIALIZE(full_name) DOC_DSCR("Full name of the asset") DOC_EXMP("Zano wrapped USD") DOC_END + KV_SERIALIZE(meta_info) DOC_DSCR("Any other information assetiaded with asset in a free form") DOC_EXMP("Stable and private") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(owner) DOC_DSCR("Owner's key, used only for EMIT and UPDATE validation, could be changed by transferring asset ownership") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END + KV_SERIALIZE(hidden_supply) DOC_DSCR("This one reserved for future use, will be documented later") DOC_END + END_KV_SERIALIZE_MAP() + + operator currency::asset_descriptor_base() const + { + currency::asset_descriptor_base asset_descriptor{}; + asset_descriptor.total_max_supply = total_max_supply; + asset_descriptor.current_supply = current_supply; + asset_descriptor.decimal_point = decimal_point; + asset_descriptor.ticker = ticker; + asset_descriptor.full_name = full_name; + asset_descriptor.meta_info = meta_info; + asset_descriptor.owner = owner; + asset_descriptor.hidden_supply = hidden_supply; + asset_descriptor.version = version; + return asset_descriptor; + } +}; + +struct currency::asset_descriptor_operation_v0 +{ + uint8_t operation_type = ASSET_DESCRIPTOR_OPERATION_UNDEFINED; + asset_descriptor_base_v0 descriptor; + crypto::public_key amount_commitment; // premultiplied by 1/8 + boost::optional opt_asset_id; // target asset_id - for update/emit + uint8_t verion = ASSET_DESCRIPTOR_OPERATION_STRUCTURE_VER; + + BEGIN_VERSIONED_SERIALIZE(ASSET_DESCRIPTOR_OPERATION_STRUCTURE_VER, verion) + FIELD(operation_type) + FIELD(descriptor) + FIELD(amount_commitment) + END_VERSION_UNDER(1) + FIELD(opt_asset_id) + END_SERIALIZE() + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(operation_type) + BOOST_SERIALIZE(descriptor) + BOOST_SERIALIZE(amount_commitment) + BOOST_END_VERSION_UNDER(1) + BOOST_SERIALIZE(opt_asset_id) + END_BOOST_SERIALIZATION() + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(operation_type) DOC_DSCR("Asset operation type identifier") DOC_EXMP(1) DOC_END + KV_SERIALIZE(descriptor) DOC_DSCR("Asset descriptor") DOC_EXMP_AUTO() DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(amount_commitment) DOC_DSCR("Amount commitment") DOC_EXMP("f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(opt_asset_id) DOC_DSCR("ID of an asset.") DOC_EXMP("cc4e69455e63f4a581257382191de6856c2156630b3fba0db4bdd73ffcfb36b6") DOC_END + END_KV_SERIALIZE_MAP() + + operator currency::asset_descriptor_operation() const + { + currency::asset_descriptor_operation operation_descriptor{}; + operation_descriptor.operation_type = operation_type; + operation_descriptor.descriptor = descriptor; + operation_descriptor.amount_commitment = amount_commitment; + operation_descriptor.opt_asset_id = opt_asset_id; + operation_descriptor.verion = verion; + + return operation_descriptor; + } +}; + +BOOST_CLASS_VERSION(currency::asset_descriptor_operation_v0, 1); + +currency::asset_descriptor_base get_asset_descriptor_for_test( + const crypto::public_key& owner = currency::null_pkey) +{ + currency::asset_descriptor_base descriptor_base{}; + descriptor_base.total_max_supply = 100; + descriptor_base.current_supply = 50; + descriptor_base.decimal_point = 0; + descriptor_base.ticker = "HLO"; + descriptor_base.full_name = "HELLO_WORLD"; + descriptor_base.meta_info = "Hello, world!"; + descriptor_base.owner = owner; + descriptor_base.hidden_supply = false; + descriptor_base.version = 1; + + return descriptor_base; +} + +currency::asset_descriptor_base_v0 get_asset_descriptor_v0_for_test( + const crypto::public_key& owner = currency::null_pkey) +{ + currency::asset_descriptor_base_v0 descriptor_base{}; + descriptor_base.total_max_supply = 100; + descriptor_base.current_supply = 50; + descriptor_base.decimal_point = 0; + descriptor_base.ticker = "HLO"; + descriptor_base.full_name = "HELLO_WORLD"; + descriptor_base.meta_info = "Hello, world!"; + descriptor_base.owner = owner; + descriptor_base.hidden_supply = false; + + return descriptor_base; +} + +currency::asset_descriptor_operation get_asset_descriptor_operation_for_test( + currency::asset_descriptor_base asset_descriptor, + std::uint8_t operation = ASSET_DESCRIPTOR_OPERATION_UNDEFINED +) +{ + currency::asset_descriptor_operation descriptor_operation{}; + descriptor_operation.operation_type = operation; + descriptor_operation.descriptor = asset_descriptor; + descriptor_operation.amount_commitment = currency::null_pkey; + + return descriptor_operation; +} + +currency::asset_descriptor_operation_v0 +get_asset_descriptor_operation_v0_for_test( + currency::asset_descriptor_base_v0 asset_descriptor, + std::uint8_t operation = ASSET_DESCRIPTOR_OPERATION_UNDEFINED +) +{ + currency::asset_descriptor_operation_v0 descriptor_operation{}; + descriptor_operation.operation_type = operation; + descriptor_operation.descriptor = asset_descriptor; + descriptor_operation.amount_commitment = currency::null_pkey; + + return descriptor_operation; +} + +TEST(multiassets, get_or_calculate_asset_id_register) +{ + bool success{false}; + + crypto::point_t pt_public_key{}; + success = pt_public_key.from_string( + "cf93bead4d2a8d6d174c1752237b2e5208a594b59618683ee50ef209cf1efb19"); + + ASSERT_TRUE(success); + + crypto::public_key owner_public_key{}; + pt_public_key.to_public_key(owner_public_key); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + const auto asset_descriptor{get_asset_descriptor_for_test(owner_public_key)}; + + const auto asset_operation_descriptor{ + get_asset_descriptor_operation_for_test(asset_descriptor, + ASSET_DESCRIPTOR_OPERATION_REGISTER)}; + + success = currency::get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "6f46324faae448b9e3b96dac94da17be6ab7eaaba398de86d8743042c98bace0"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_emit) +{ + bool success{false}; + + crypto::point_t pt_public_key{}; + success = pt_public_key.from_string( + "edab571c4be9eabfea5e7883036d744c097382eb6f739a914db06f72ba35099d"); + + ASSERT_TRUE(success); + + crypto::public_key owner_public_key{}; + pt_public_key.to_public_key(owner_public_key); + + const auto asset_descriptor{ + get_asset_descriptor_for_test(owner_public_key)}; + + auto asset_operation_descriptor{ + get_asset_descriptor_operation_for_test( + asset_descriptor, ASSET_DESCRIPTOR_OPERATION_REGISTER)}; + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "49a3d6652aaa0b3b77292c534e91ff80de9120aeb6fc1c5edc728047437d667e"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); + + asset_operation_descriptor.opt_asset_id = calculated_asset_id_key; + asset_operation_descriptor.operation_type = ASSET_DESCRIPTOR_OPERATION_EMIT; + + success = get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_update) +{ + bool success{false}; + + crypto::point_t pt_public_key{}; + success = pt_public_key.from_string( + "8cb6349f51da6599feeae7c0077293436eb6a5000f0e6e706e77886bb540e2c1"); + + ASSERT_TRUE(success); + + crypto::public_key owner_public_key{}; + pt_public_key.to_public_key(owner_public_key); + + const auto asset_descriptor{ + get_asset_descriptor_for_test(owner_public_key)}; + + auto asset_operation_descriptor{ + get_asset_descriptor_operation_for_test( + asset_descriptor, ASSET_DESCRIPTOR_OPERATION_REGISTER)}; + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "c371f60dd8333298c6aa746b71e1e20527b1ff5e1bed4ea9b5f592fadf90ed6b"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); + + asset_operation_descriptor.opt_asset_id = calculated_asset_id_key; + asset_operation_descriptor.operation_type = ASSET_DESCRIPTOR_OPERATION_UPDATE; + + success = get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_public_burn) +{ + bool success{false}; + + crypto::point_t pt_public_key{}; + success = pt_public_key.from_string( + "0c408cf8b7fb808f40593d6eb75890e2ab3d0ccdc7014a7fc6b6ab05163be060"); + + ASSERT_TRUE(success); + + crypto::public_key owner_public_key{}; + pt_public_key.to_public_key(owner_public_key); + + const auto asset_descriptor{ + get_asset_descriptor_for_test(owner_public_key)}; + + auto asset_operation_descriptor{ + get_asset_descriptor_operation_for_test( + asset_descriptor, ASSET_DESCRIPTOR_OPERATION_REGISTER)}; + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "54f3f72c72e5b014ad2b2b9001acef954fe82dd3ed56a38cd9ddc5db57673f8f"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); + + asset_operation_descriptor.opt_asset_id = calculated_asset_id_key; + asset_operation_descriptor.operation_type = + ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN; + + success = get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_undefined) +{ + bool success{false}; + + crypto::point_t pt_public_key{}; + success = pt_public_key.from_string( + "e91b9a73292d6ea46fb3d4f4cc79c34bfb7d14c2e684e58093a2471c92e51c16"); + + ASSERT_TRUE(success); + + crypto::public_key owner_public_key{}; + pt_public_key.to_public_key(owner_public_key); + + const auto asset_descriptor{ + get_asset_descriptor_for_test(owner_public_key)}; + + auto asset_operation_descriptor{ + get_asset_descriptor_operation_for_test( + asset_descriptor, ASSET_DESCRIPTOR_OPERATION_REGISTER)}; + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "979eb706ace2eb83f9125658b23fb352208480cb3b90c43e2df0d298f9754ebc"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); + + asset_operation_descriptor.opt_asset_id = calculated_asset_id_key; + asset_operation_descriptor.operation_type = + ASSET_DESCRIPTOR_OPERATION_UNDEFINED; + + success = get_or_calculate_asset_id(asset_operation_descriptor, + &calculated_asset_id_pt, + &calculated_asset_id_key); + + ASSERT_FALSE(success); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_register_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x01', '\x01', '\x00', 'd', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '2', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x03', 'H', 'L', 'O', '\x0b', 'H', 'E', + 'L', 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', + '\x0d', 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', + 'o', 'r', 'l', 'd', '!', '\xcf', '\x93', '\xbe', '\xad', + 'M', '*', '\x8d', 'm', '\x17', 'L', '\x17', 'R', '#', + '{', '.', 'R', '\x08', '\xa5', '\x94', '\xb5', '\x96', '\x18', + 'h', '>', '\xe5', '\x0e', '\xf2', '\x09', '\xcf', '\x1e', '\xfb', + '\x19', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'o', + 'F', '2', 'O', '\xaa', '\xe4', 'H', '\xb9', '\xe3', '\xb9', + 'm', '\xac', '\x94', '\xda', '\x17', '\xbe', 'j', '\xb7', '\xea', + '\xab', '\xa3', '\x98', '\xde', '\x86', '\xd8', 't', '0', 'B', + '\xc9', '\x8b', '\xac', '\xe0'}; + + success = t_unserializable_object_from_blob(asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "6f46324faae448b9e3b96dac94da17be6ab7eaaba398de86d8743042c98bace0"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_emit_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x01', '\x02', '\x00', 'd', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '2', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x03', 'H', 'L', 'O', '\x0b', 'H', 'E', + 'L', 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', + '\x0d', 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', + 'o', 'r', 'l', 'd', '!', '\xed', '\xab', 'W', '\x1c', + 'K', '\xe9', '\xea', '\xbf', '\xea', '^', 'x', '\x83', '\x03', + 'm', 't', 'L', '\x09', 's', '\x82', '\xeb', 'o', 's', + '\x9a', '\x91', 'M', '\xb0', 'o', 'r', '\xba', '5', '\x09', + '\x9d', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'I', + '\xa3', '\xd6', 'e', '*', '\xaa', '\x0b', ';', 'w', ')', + ',', 'S', 'N', '\x91', '\xff', '\x80', '\xde', '\x91', ' ', + '\xae', '\xb6', '\xfc', '\x1c', '^', '\xdc', 'r', '\x80', 'G', + 'C', '}', 'f', '~'}; + + success = t_unserializable_object_from_blob(asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "49a3d6652aaa0b3b77292c534e91ff80de9120aeb6fc1c5edc728047437d667e"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_update_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x01', '\x03', '\x00', 'd', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '2', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x03', 'H', 'L', 'O', '\x0b', 'H', 'E', + 'L', 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', + '\x0d', 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', + 'o', 'r', 'l', 'd', '!', '\x8c', '\xb6', '4', '\x9f', + 'Q', '\xda', 'e', '\x99', '\xfe', '\xea', '\xe7', '\xc0', '\x07', + 'r', '\x93', 'C', 'n', '\xb6', '\xa5', '\x00', '\x0f', '\x0e', + 'n', 'p', 'n', 'w', '\x88', 'k', '\xb5', '@', '\xe2', + '\xc1', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\xc3', + 'q', '\xf6', '\x0d', '\xd8', '3', '2', '\x98', '\xc6', '\xaa', + 't', 'k', 'q', '\xe1', '\xe2', '\x05', '\'', '\xb1', '\xff', + '^', '\x1b', '\xed', 'N', '\xa9', '\xb5', '\xf5', '\x92', '\xfa', + '\xdf', '\x90', '\xed', 'k'}; + + success = t_unserializable_object_from_blob(asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "c371f60dd8333298c6aa746b71e1e20527b1ff5e1bed4ea9b5f592fadf90ed6b"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_public_burn_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x01', '\x04', '\x00', 'd', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '2', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x03', 'H', 'L', 'O', '\x0b', 'H', 'E', + 'L', 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', + '\x0d', 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', + 'o', 'r', 'l', 'd', '!', '\x0c', '@', '\x8c', '\xf8', + '\xb7', '\xfb', '\x80', '\x8f', '@', 'Y', '=', 'n', '\xb7', + 'X', '\x90', '\xe2', '\xab', '=', '\x0c', '\xcd', '\xc7', '\x01', + 'J', '\x7f', '\xc6', '\xb6', '\xab', '\x05', '\x16', ';', '\xe0', + '`', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'T', + '\xf3', '\xf7', ',', 'r', '\xe5', '\xb0', '\x14', '\xad', '+', + '+', '\x90', '\x01', '\xac', '\xef', '\x95', 'O', '\xe8', '-', + '\xd3', '\xed', 'V', '\xa3', '\x8c', '\xd9', '\xdd', '\xc5', '\xdb', + 'W', 'g', '?', '\x8f'}; + + success = t_unserializable_object_from_blob(asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "54f3f72c72e5b014ad2b2b9001acef954fe82dd3ed56a38cd9ddc5db57673f8f"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_undefined_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x01', '\x00', '\x00', 'd', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '2', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x03', 'H', 'L', 'O', '\x0b', 'H', 'E', + 'L', 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', + '\x0d', 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', + 'o', 'r', 'l', 'd', '!', '\xe9', '\x1b', '\x9a', 's', + ')', '-', 'n', '\xa4', 'o', '\xb3', '\xd4', '\xf4', '\xcc', + 'y', '\xc3', 'K', '\xfb', '}', '\x14', '\xc2', '\xe6', '\x84', + '\xe5', '\x80', '\x93', '\xa2', 'G', '\x1c', '\x92', '\xe5', '\x1c', + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x97', + '\x9e', '\xb7', '\x06', '\xac', '\xe2', '\xeb', '\x83', '\xf9', '\x12', + 'V', 'X', '\xb2', '?', '\xb3', 'R', ' ', '\x84', '\x80', + '\xcb', ';', '\x90', '\xc4', '>', '-', '\xf0', '\xd2', '\x98', + '\xf9', 'u', 'N', '\xbc'}; + + success = t_unserializable_object_from_blob( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_FALSE(success); + + const std::string expected_asset_id_str{ + "979eb706ace2eb83f9125658b23fb352208480cb3b90c43e2df0d298f9754ebc"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_register_boost_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 's', + 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 't', + 'i', 'o', 'n', ':', ':', 'a', 'r', 'c', 'h', + 'i', 'v', 'e', '\x11', '\x00', '\x04', '\x08', '\x04', '\x08', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x00', 'd', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '2', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x03', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', 'H', 'L', 'O', '\x0b', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'E', 'L', + 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', '\x0d', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'e', + 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', + 'd', '!', '\x00', '\x00', '\x00', '\x00', '\x00', ' ', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\xcf', '\x93', '\xbe', + '\xad', 'M', '*', '\x8d', 'm', '\x17', 'L', '\x17', 'R', + '#', '{', '.', 'R', '\x08', '\xa5', '\x94', '\xb5', '\x96', + '\x18', 'h', '>', '\xe5', '\x0e', '\xf2', '\x09', '\xcf', '\x1e', + '\xfb', '\x19', '\x00', ' ', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'}; + + success = tools::unserialize_obj_from_buff( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "6f46324faae448b9e3b96dac94da17be6ab7eaaba398de86d8743042c98bace0"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_emit_boost_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 's', + 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 't', + 'i', 'o', 'n', ':', ':', 'a', 'r', 'c', 'h', + 'i', 'v', 'e', '\x11', '\x00', '\x04', '\x08', '\x04', '\x08', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', + '\x02', '\x00', '\x00', '\x00', '\x00', '\x00', 'd', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '2', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x03', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', 'H', 'L', 'O', '\x0b', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'E', 'L', + 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', '\x0d', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'e', + 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', + 'd', '!', '\x00', '\x00', '\x00', '\x00', '\x00', ' ', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\xed', '\xab', 'W', + '\x1c', 'K', '\xe9', '\xea', '\xbf', '\xea', '^', 'x', '\x83', + '\x03', 'm', 't', 'L', '\x09', 's', '\x82', '\xeb', 'o', + 's', '\x9a', '\x91', 'M', '\xb0', 'o', 'r', '\xba', '5', + '\x09', '\x9d', '\x00', ' ', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', + '\x00', '\x00', '\x00', '\x01', ' ', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', 'I', '\xa3', '\xd6', 'e', '*', '\xaa', + '\x0b', ';', 'w', ')', ',', 'S', 'N', '\x91', '\xff', + '\x80', '\xde', '\x91', ' ', '\xae', '\xb6', '\xfc', '\x1c', '^', + '\xdc', 'r', '\x80', 'G', 'C', '}', 'f', '~'}; + + success = tools::unserialize_obj_from_buff( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "49a3d6652aaa0b3b77292c534e91ff80de9120aeb6fc1c5edc728047437d667e"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_update_boost_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 's', + 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 't', + 'i', 'o', 'n', ':', ':', 'a', 'r', 'c', 'h', + 'i', 'v', 'e', '\x11', '\x00', '\x04', '\x08', '\x04', '\x08', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', + '\x03', '\x00', '\x00', '\x00', '\x00', '\x00', 'd', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '2', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x03', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', 'H', 'L', 'O', '\x0b', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'E', 'L', + 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', '\x0d', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'e', + 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', + 'd', '!', '\x00', '\x00', '\x00', '\x00', '\x00', ' ', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x8c', '\xb6', '4', + '\x9f', 'Q', '\xda', 'e', '\x99', '\xfe', '\xea', '\xe7', '\xc0', + '\x07', 'r', '\x93', 'C', 'n', '\xb6', '\xa5', '\x00', '\x0f', + '\x0e', 'n', 'p', 'n', 'w', '\x88', 'k', '\xb5', '@', + '\xe2', '\xc1', '\x00', ' ', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', + '\x00', '\x00', '\x00', '\x01', ' ', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\xc3', 'q', '\xf6', '\x0d', '\xd8', '3', + '2', '\x98', '\xc6', '\xaa', 't', 'k', 'q', '\xe1', '\xe2', + '\x05', '\'', '\xb1', '\xff', '^', '\x1b', '\xed', 'N', '\xa9', + '\xb5', '\xf5', '\x92', '\xfa', '\xdf', '\x90', '\xed', 'k'}; + + success = tools::unserialize_obj_from_buff( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "c371f60dd8333298c6aa746b71e1e20527b1ff5e1bed4ea9b5f592fadf90ed6b"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_public_burn_boost_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 's', + 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 't', + 'i', 'o', 'n', ':', ':', 'a', 'r', 'c', 'h', + 'i', 'v', 'e', '\x11', '\x00', '\x04', '\x08', '\x04', '\x08', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', + '\x04', '\x00', '\x00', '\x00', '\x00', '\x00', 'd', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '2', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x03', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', 'H', 'L', 'O', '\x0b', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'E', 'L', + 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', '\x0d', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'e', + 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', + 'd', '!', '\x00', '\x00', '\x00', '\x00', '\x00', ' ', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x0c', '@', '\x8c', + '\xf8', '\xb7', '\xfb', '\x80', '\x8f', '@', 'Y', '=', 'n', + '\xb7', 'X', '\x90', '\xe2', '\xab', '=', '\x0c', '\xcd', '\xc7', + '\x01', 'J', '\x7f', '\xc6', '\xb6', '\xab', '\x05', '\x16', ';', + '\xe0', '`', '\x00', ' ', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', + '\x00', '\x00', '\x00', '\x01', ' ', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', 'T', '\xf3', '\xf7', ',', 'r', '\xe5', + '\xb0', '\x14', '\xad', '+', '+', '\x90', '\x01', '\xac', '\xef', + '\x95', 'O', '\xe8', '-', '\xd3', '\xed', 'V', '\xa3', '\x8c', + '\xd9', '\xdd', '\xc5', '\xdb', 'W', 'g', '?', '\x8f'}; + + success = tools::unserialize_obj_from_buff( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "54f3f72c72e5b014ad2b2b9001acef954fe82dd3ed56a38cd9ddc5db57673f8f"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_undefined_boost_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '\x16', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 's', + 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 't', + 'i', 'o', 'n', ':', ':', 'a', 'r', 'c', 'h', + 'i', 'v', 'e', '\x11', '\x00', '\x04', '\x08', '\x04', '\x08', + '\x01', '\x00', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x00', + '\x04', '\x00', '\x00', '\x00', '\x00', '\x00', 'd', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '2', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x03', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', 'H', 'L', 'O', '\x0b', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'E', 'L', + 'L', 'O', '_', 'W', 'O', 'R', 'L', 'D', '\x0d', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', 'H', 'e', + 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', + 'd', '!', '\x00', '\x00', '\x00', '\x00', '\x00', ' ', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x0c', '@', '\x8c', + '\xf8', '\xb7', '\xfb', '\x80', '\x8f', '@', 'Y', '=', 'n', + '\xb7', 'X', '\x90', '\xe2', '\xab', '=', '\x0c', '\xcd', '\xc7', + '\x01', 'J', '\x7f', '\xc6', '\xb6', '\xab', '\x05', '\x16', ';', + '\xe0', '`', '\x00', ' ', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', + '\x00', '\x00', '\x00', '\x01', ' ', '\x00', '\x00', '\x00', '\x00', + '\x00', '\x00', '\x00', 'T', '\xf3', '\xf7', ',', 'r', '\xe5', + '\xb0', '\x14', '\xad', '+', '+', '\x90', '\x01', '\xac', '\xef', + '\x95', 'O', '\xe8', '-', '\xd3', '\xed', 'V', '\xa3', '\x8c', + '\xd9', '\xdd', '\xc5', '\xdb', 'W', 'g', '?', '\x8f'}; + + success = tools::unserialize_obj_from_buff( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_FALSE(success); +} + +TEST(multiassets, get_or_calculate_asset_id_register_key_value_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '{', '\x0d', '\x0a', ' ', ' ', '"', 'a', 'm', 'o', + 'u', 'n', 't', '_', 'c', 'o', 'm', 'm', 'i', + 't', 'm', 'e', 'n', 't', '"', ':', ' ', '"', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '"', ',', '\x0d', '\x0a', ' ', ' ', '"', 'd', + 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', + '"', ':', ' ', '{', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'c', 'u', 'r', 'r', 'e', 'n', 't', + '_', 's', 'u', 'p', 'p', 'l', 'y', '"', ':', + ' ', '5', '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'd', 'e', 'c', 'i', 'm', 'a', 'l', + '_', 'p', 'o', 'i', 'n', 't', '"', ':', ' ', + '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', + 'f', 'u', 'l', 'l', '_', 'n', 'a', 'm', 'e', + '"', ':', ' ', '"', 'H', 'E', 'L', 'L', 'O', + '_', 'W', 'O', 'R', 'L', 'D', '"', ',', '\x0d', + '\x0a', ' ', ' ', ' ', ' ', '"', 'h', 'i', 'd', + 'd', 'e', 'n', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', 'f', 'a', 'l', 's', 'e', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'm', + 'e', 't', 'a', '_', 'i', 'n', 'f', 'o', '"', + ':', ' ', '"', 'H', 'e', 'l', 'l', 'o', ',', + ' ', 'w', 'o', 'r', 'l', 'd', '!', '"', ',', + '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'o', 'w', + 'n', 'e', 'r', '"', ':', ' ', '"', 'c', 'f', + '9', '3', 'b', 'e', 'a', 'd', '4', 'd', '2', + 'a', '8', 'd', '6', 'd', '1', '7', '4', 'c', + '1', '7', '5', '2', '2', '3', '7', 'b', '2', + 'e', '5', '2', '0', '8', 'a', '5', '9', '4', + 'b', '5', '9', '6', '1', '8', '6', '8', '3', + 'e', 'e', '5', '0', 'e', 'f', '2', '0', '9', + 'c', 'f', '1', 'e', 'f', 'b', '1', '9', '"', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 't', + 'i', 'c', 'k', 'e', 'r', '"', ':', ' ', '"', + 'H', 'L', 'O', '"', ',', '\x0d', '\x0a', ' ', ' ', + ' ', ' ', '"', 't', 'o', 't', 'a', 'l', '_', + 'm', 'a', 'x', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', '1', '0', '0', '\x0d', '\x0a', + ' ', ' ', '}', ',', '\x0d', '\x0a', ' ', ' ', '"', + 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', + '_', 't', 'y', 'p', 'e', '"', ':', ' ', '1', + ',', '\x0d', '\x0a', ' ', ' ', '"', 'o', 'p', 't', + '_', 'a', 's', 's', 'e', 't', '_', 'i', 'd', + '"', ':', ' ', '"', '0', '1', '6', 'f', '4', + '6', '3', '2', '4', 'f', 'a', 'a', 'e', '4', + '4', '8', 'b', '9', 'e', '3', 'b', '9', '6', + 'd', 'a', 'c', '9', '4', 'd', 'a', '1', '7', + 'b', 'e', '6', 'a', 'b', '7', 'e', 'a', 'a', + 'b', 'a', '3', '9', '8', 'd', 'e', '8', '6', + 'd', '8', '7', '4', '3', '0', '4', '2', 'c', + '9', '8', 'b', 'a', 'c', 'e', '0', '"', '\x0d', + '\x0a', '}'}; + + success = epee::serialization::load_t_from_json( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "6f46324faae448b9e3b96dac94da17be6ab7eaaba398de86d8743042c98bace0"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + const crypto::public_key expected_asset_id_key{ + expected_asset_id_pt.to_public_key()}; + + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_emit_key_value_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '{', '\x0d', '\x0a', ' ', ' ', '"', 'a', 'm', 'o', + 'u', 'n', 't', '_', 'c', 'o', 'm', 'm', 'i', + 't', 'm', 'e', 'n', 't', '"', ':', ' ', '"', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '"', ',', '\x0d', '\x0a', ' ', ' ', '"', 'd', + 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', + '"', ':', ' ', '{', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'c', 'u', 'r', 'r', 'e', 'n', 't', + '_', 's', 'u', 'p', 'p', 'l', 'y', '"', ':', + ' ', '5', '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'd', 'e', 'c', 'i', 'm', 'a', 'l', + '_', 'p', 'o', 'i', 'n', 't', '"', ':', ' ', + '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', + 'f', 'u', 'l', 'l', '_', 'n', 'a', 'm', 'e', + '"', ':', ' ', '"', 'H', 'E', 'L', 'L', 'O', + '_', 'W', 'O', 'R', 'L', 'D', '"', ',', '\x0d', + '\x0a', ' ', ' ', ' ', ' ', '"', 'h', 'i', 'd', + 'd', 'e', 'n', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', 'f', 'a', 'l', 's', 'e', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'm', + 'e', 't', 'a', '_', 'i', 'n', 'f', 'o', '"', + ':', ' ', '"', 'H', 'e', 'l', 'l', 'o', ',', + ' ', 'w', 'o', 'r', 'l', 'd', '!', '"', ',', + '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'o', 'w', + 'n', 'e', 'r', '"', ':', ' ', '"', 'e', 'd', + 'a', 'b', '5', '7', '1', 'c', '4', 'b', 'e', + '9', 'e', 'a', 'b', 'f', 'e', 'a', '5', 'e', + '7', '8', '8', '3', '0', '3', '6', 'd', '7', + '4', '4', 'c', '0', '9', '7', '3', '8', '2', + 'e', 'b', '6', 'f', '7', '3', '9', 'a', '9', + '1', '4', 'd', 'b', '0', '6', 'f', '7', '2', + 'b', 'a', '3', '5', '0', '9', '9', 'd', '"', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 't', + 'i', 'c', 'k', 'e', 'r', '"', ':', ' ', '"', + 'H', 'L', 'O', '"', ',', '\x0d', '\x0a', ' ', ' ', + ' ', ' ', '"', 't', 'o', 't', 'a', 'l', '_', + 'm', 'a', 'x', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', '1', '0', '0', '\x0d', '\x0a', + ' ', ' ', '}', ',', '\x0d', '\x0a', ' ', ' ', '"', + 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', + '_', 't', 'y', 'p', 'e', '"', ':', ' ', '2', + ',', '\x0d', '\x0a', ' ', ' ', '"', 'o', 'p', 't', + '_', 'a', 's', 's', 'e', 't', '_', 'i', 'd', + '"', ':', ' ', '"', '0', '1', '4', '9', 'a', + '3', 'd', '6', '6', '5', '2', 'a', 'a', 'a', + '0', 'b', '3', 'b', '7', '7', '2', '9', '2', + 'c', '5', '3', '4', 'e', '9', '1', 'f', 'f', + '8', '0', 'd', 'e', '9', '1', '2', '0', 'a', + 'e', 'b', '6', 'f', 'c', '1', 'c', '5', 'e', + 'd', 'c', '7', '2', '8', '0', '4', '7', '4', + '3', '7', 'd', '6', '6', '7', 'e', '"', '\x0d', + '\x0a', '}'}; + + success = epee::serialization::load_t_from_json( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "49a3d6652aaa0b3b77292c534e91ff80de9120aeb6fc1c5edc728047437d667e"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_update_key_value_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '{', '\x0d', '\x0a', ' ', ' ', '"', 'a', 'm', 'o', + 'u', 'n', 't', '_', 'c', 'o', 'm', 'm', 'i', + 't', 'm', 'e', 'n', 't', '"', ':', ' ', '"', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '"', ',', '\x0d', '\x0a', ' ', ' ', '"', 'd', + 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', + '"', ':', ' ', '{', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'c', 'u', 'r', 'r', 'e', 'n', 't', + '_', 's', 'u', 'p', 'p', 'l', 'y', '"', ':', + ' ', '5', '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'd', 'e', 'c', 'i', 'm', 'a', 'l', + '_', 'p', 'o', 'i', 'n', 't', '"', ':', ' ', + '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', + 'f', 'u', 'l', 'l', '_', 'n', 'a', 'm', 'e', + '"', ':', ' ', '"', 'H', 'E', 'L', 'L', 'O', + '_', 'W', 'O', 'R', 'L', 'D', '"', ',', '\x0d', + '\x0a', ' ', ' ', ' ', ' ', '"', 'h', 'i', 'd', + 'd', 'e', 'n', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', 'f', 'a', 'l', 's', 'e', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'm', + 'e', 't', 'a', '_', 'i', 'n', 'f', 'o', '"', + ':', ' ', '"', 'H', 'e', 'l', 'l', 'o', ',', + ' ', 'w', 'o', 'r', 'l', 'd', '!', '"', ',', + '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'o', 'w', + 'n', 'e', 'r', '"', ':', ' ', '"', '8', 'c', + 'b', '6', '3', '4', '9', 'f', '5', '1', 'd', + 'a', '6', '5', '9', '9', 'f', 'e', 'e', 'a', + 'e', '7', 'c', '0', '0', '7', '7', '2', '9', + '3', '4', '3', '6', 'e', 'b', '6', 'a', '5', + '0', '0', '0', 'f', '0', 'e', '6', 'e', '7', + '0', '6', 'e', '7', '7', '8', '8', '6', 'b', + 'b', '5', '4', '0', 'e', '2', 'c', '1', '"', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 't', + 'i', 'c', 'k', 'e', 'r', '"', ':', ' ', '"', + 'H', 'L', 'O', '"', ',', '\x0d', '\x0a', ' ', ' ', + ' ', ' ', '"', 't', 'o', 't', 'a', 'l', '_', + 'm', 'a', 'x', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', '1', '0', '0', '\x0d', '\x0a', + ' ', ' ', '}', ',', '\x0d', '\x0a', ' ', ' ', '"', + 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', + '_', 't', 'y', 'p', 'e', '"', ':', ' ', '3', + ',', '\x0d', '\x0a', ' ', ' ', '"', 'o', 'p', 't', + '_', 'a', 's', 's', 'e', 't', '_', 'i', 'd', + '"', ':', ' ', '"', '0', '1', 'c', '3', '7', + '1', 'f', '6', '0', 'd', 'd', '8', '3', '3', + '3', '2', '9', '8', 'c', '6', 'a', 'a', '7', + '4', '6', 'b', '7', '1', 'e', '1', 'e', '2', + '0', '5', '2', '7', 'b', '1', 'f', 'f', '5', + 'e', '1', 'b', 'e', 'd', '4', 'e', 'a', '9', + 'b', '5', 'f', '5', '9', '2', 'f', 'a', 'd', + 'f', '9', '0', 'e', 'd', '6', 'b', '"', '\x0d', + '\x0a', '}'}; + + success = epee::serialization::load_t_from_json( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_TRUE(success); + + const std::string expected_asset_id_str{ + "c371f60dd8333298c6aa746b71e1e20527b1ff5e1bed4ea9b5f592fadf90ed6b"}; + + crypto::point_t expected_asset_id_pt{}; + success = expected_asset_id_pt.from_string(expected_asset_id_str); + ASSERT_TRUE(success); + + crypto::public_key expected_asset_id_key{}; + expected_asset_id_pt.to_public_key(expected_asset_id_key); + ASSERT_EQ(calculated_asset_id_pt, expected_asset_id_pt); + ASSERT_EQ(calculated_asset_id_key, expected_asset_id_key); +} + +TEST(multiassets, get_or_calculate_asset_id_undefined_key_value_serialization) +{ + bool success{false}; + currency::asset_descriptor_operation_v0 asset_descriptor_operation{}; + const std::string serialized_asset_descriptor_operation{ + '{', '\x0d', '\x0a', ' ', ' ', '"', 'a', 'm', 'o', + 'u', 'n', 't', '_', 'c', 'o', 'm', 'm', 'i', + 't', 'm', 'e', 'n', 't', '"', ':', ' ', '"', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '0', '0', '0', '0', '0', '0', '0', '0', + '0', '"', ',', '\x0d', '\x0a', ' ', ' ', '"', 'd', + 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', + '"', ':', ' ', '{', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'c', 'u', 'r', 'r', 'e', 'n', 't', + '_', 's', 'u', 'p', 'p', 'l', 'y', '"', ':', + ' ', '5', '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', + ' ', '"', 'd', 'e', 'c', 'i', 'm', 'a', 'l', + '_', 'p', 'o', 'i', 'n', 't', '"', ':', ' ', + '0', ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', + 'f', 'u', 'l', 'l', '_', 'n', 'a', 'm', 'e', + '"', ':', ' ', '"', 'H', 'E', 'L', 'L', 'O', + '_', 'W', 'O', 'R', 'L', 'D', '"', ',', '\x0d', + '\x0a', ' ', ' ', ' ', ' ', '"', 'h', 'i', 'd', + 'd', 'e', 'n', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', 'f', 'a', 'l', 's', 'e', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'm', + 'e', 't', 'a', '_', 'i', 'n', 'f', 'o', '"', + ':', ' ', '"', 'H', 'e', 'l', 'l', 'o', ',', + ' ', 'w', 'o', 'r', 'l', 'd', '!', '"', ',', + '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 'o', 'w', + 'n', 'e', 'r', '"', ':', ' ', '"', 'e', '9', + '1', 'b', '9', 'a', '7', '3', '2', '9', '2', + 'd', '6', 'e', 'a', '4', '6', 'f', 'b', '3', + 'd', '4', 'f', '4', 'c', 'c', '7', '9', 'c', + '3', '4', 'b', 'f', 'b', '7', 'd', '1', '4', + 'c', '2', 'e', '6', '8', '4', 'e', '5', '8', + '0', '9', '3', 'a', '2', '4', '7', '1', 'c', + '9', '2', 'e', '5', '1', 'c', '1', '6', '"', + ',', '\x0d', '\x0a', ' ', ' ', ' ', ' ', '"', 't', + 'i', 'c', 'k', 'e', 'r', '"', ':', ' ', '"', + 'H', 'L', 'O', '"', ',', '\x0d', '\x0a', ' ', ' ', + ' ', ' ', '"', 't', 'o', 't', 'a', 'l', '_', + 'm', 'a', 'x', '_', 's', 'u', 'p', 'p', 'l', + 'y', '"', ':', ' ', '1', '0', '0', '\x0d', '\x0a', + ' ', ' ', '}', ',', '\x0d', '\x0a', ' ', ' ', '"', + 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', + '_', 't', 'y', 'p', 'e', '"', ':', ' ', '0', + ',', '\x0d', '\x0a', ' ', ' ', '"', 'o', 'p', 't', + '_', 'a', 's', 's', 'e', 't', '_', 'i', 'd', + '"', ':', ' ', '"', '0', '1', '9', '7', '9', + 'e', 'b', '7', '0', '6', 'a', 'c', 'e', '2', + 'e', 'b', '8', '3', 'f', '9', '1', '2', '5', + '6', '5', '8', 'b', '2', '3', 'f', 'b', '3', + '5', '2', '2', '0', '8', '4', '8', '0', 'c', + 'b', '3', 'b', '9', '0', 'c', '4', '3', 'e', + '2', 'd', 'f', '0', 'd', '2', '9', '8', 'f', + '9', '7', '5', '4', 'e', 'b', 'c', '"', '\x0d', + '\x0a', '}'}; + + success = epee::serialization::load_t_from_json( + asset_descriptor_operation, + serialized_asset_descriptor_operation); + ASSERT_TRUE(success); + + crypto::point_t calculated_asset_id_pt{}; + crypto::public_key calculated_asset_id_key{}; + + success = currency::get_or_calculate_asset_id(asset_descriptor_operation, + &calculated_asset_id_pt, + &calculated_asset_id_key); + ASSERT_FALSE(success); +} From 443386489c7268c3c78b0cf39f62a78c54dd449a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=D1=91pa=20Dolgorukov?= Date: Tue, 20 Aug 2024 20:23:21 +0500 Subject: [PATCH 17/23] unit tests: wallet_seed.{timestamp_from_word, word_from_timestamp} added + typo fixed (#450) * Create wallet_seed.{timestamp_from_word, word_from_timestamp} tests * Rename functions that convert a word to a timestamp, a timestamp to a word * Make an implementation of the test in the source code shorter --- src/currency_core/account.cpp | 8 +- src/currency_core/currency_format_utils.cpp | 4 +- src/currency_core/currency_format_utils.h | 6 +- tests/unit_tests/wallet_seed_test.cpp | 151 ++++++++++++++++++++ 4 files changed, 160 insertions(+), 9 deletions(-) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index 675d2f1e..6a07b7c9 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -84,11 +84,11 @@ namespace currency } std::string keys_seed_text = tools::mnemonic_encoding::binary2text(processed_seed_binary); - std::string timestamp_word = currency::get_word_from_timstamp(m_creation_timestamp, !password.empty()); + std::string timestamp_word = currency::get_word_from_timestamp(m_creation_timestamp, !password.empty()); // floor creation time to WALLET_BRAIN_DATE_QUANTUM to make checksum calculation stable bool self_check_is_password_used = false; - uint64_t creation_timestamp_rounded = get_timstamp_from_word(timestamp_word, self_check_is_password_used); + uint64_t creation_timestamp_rounded = get_timestamp_from_word(timestamp_word, self_check_is_password_used); CHECK_AND_ASSERT_THROW_MES(self_check_is_password_used == !password.empty(), "Account seed phrase internal error: password flag encoded wrong"); constexpr uint16_t checksum_max = tools::mnemonic_encoding::NUMWORDS >> 1; // maximum value of checksum @@ -177,7 +177,7 @@ namespace currency bool has_password = false; try { - m_creation_timestamp = get_timstamp_from_word(timestamp_word, has_password); + m_creation_timestamp = get_timestamp_from_word(timestamp_word, has_password); } catch (...) { @@ -263,7 +263,7 @@ namespace currency return false; } - get_timstamp_from_word(timestamp_word, is_password_protected); + get_timestamp_from_word(timestamp_word, is_password_protected); return true; } diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index d706bc3d..f2ed06d4 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2853,7 +2853,7 @@ namespace currency return reward; } //--------------------------------------------------------------- - std::string get_word_from_timstamp(uint64_t timestamp, bool use_password) + std::string get_word_from_timestamp(uint64_t timestamp, bool use_password) { uint64_t date_offset = timestamp > WALLET_BRAIN_DATE_OFFSET ? timestamp - WALLET_BRAIN_DATE_OFFSET : 0; uint64_t weeks_count = date_offset / WALLET_BRAIN_DATE_QUANTUM; @@ -2868,7 +2868,7 @@ namespace currency return tools::mnemonic_encoding::word_by_num(weeks_count_32); } //--------------------------------------------------------------- - uint64_t get_timstamp_from_word(std::string word, bool& password_used) + uint64_t get_timestamp_from_word(std::string word, bool& password_used) { uint64_t count_of_weeks = tools::mnemonic_encoding::num_by_word(word); if (count_of_weeks >= WALLET_BRAIN_DATE_MAX_WEEKS_COUNT) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 3e875c08..78668536 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -457,9 +457,9 @@ namespace currency bool fill_block_rpc_details(block_rpc_extended_info& pei_rpc, const block_extended_info& bei_chain, const crypto::hash& h); void append_per_block_increments_for_tx(const transaction& tx, std::unordered_map& gindices); - std::string get_word_from_timstamp(uint64_t timestamp, bool use_password); - uint64_t get_timstamp_from_word(std::string word, bool& password_used, const std::string& buff); - uint64_t get_timstamp_from_word(std::string word, bool& password_used); + std::string get_word_from_timestamp(uint64_t timestamp, bool use_password); + uint64_t get_timestamp_from_word(std::string word, bool& password_used, const std::string& buff); + uint64_t get_timestamp_from_word(std::string word, bool& password_used); bool parse_vote(const std::string& buff, std::list>& votes); std::string generate_origin_for_htlc(const txout_htlc& htlc, const account_keys& acc_keys); diff --git a/tests/unit_tests/wallet_seed_test.cpp b/tests/unit_tests/wallet_seed_test.cpp index efbd2829..cfd6b860 100644 --- a/tests/unit_tests/wallet_seed_test.cpp +++ b/tests/unit_tests/wallet_seed_test.cpp @@ -2,10 +2,13 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include + #include "gtest/gtest.h" #include "include_base_utils.h" #include "currency_core/account.h" +#include "currency_core/currency_format_utils.h" TEST(wallet_seed, store_restore_test) { @@ -211,3 +214,151 @@ TEST(wallet_seed, basic_test) } } + +TEST(wallet_seed, word_from_timestamp) +{ + //timestamp = 0; use_password = false + ASSERT_EQ("like", currency::get_word_from_timestamp(0, false)); + + // timestamp = 0; use_password = true + ASSERT_EQ("among", currency::get_word_from_timestamp(0, true)); + + // timestamp = WALLET_BRAIN_DATE_OFFSET = 1543622400; use_password = false + ASSERT_EQ("like", currency::get_word_from_timestamp(1543622400, false)); + + // timestamp = WALLET_BRAIN_DATE_OFFSET = 1543622400; use_password = true + ASSERT_EQ("among", currency::get_word_from_timestamp(1543622400, true)); + + // timestamp = WALLET_BRAIN_DATE_OFFSET - 1 = 1543622399; use_password = false + ASSERT_EQ("like", currency::get_word_from_timestamp(1543622399, false)); + + // timestamp = WALLET_BRAIN_DATE_OFFSET + 1 = 1543622401; use_password = false + ASSERT_EQ("like", currency::get_word_from_timestamp(1543622401, false)); + + // timestamp = WALLET_BRAIN_DATE_OFFSET + 1 = 1543622401; use_password = true + ASSERT_EQ("among", currency::get_word_from_timestamp(1543622401, true)); + + /* + Values get_word_from_timestamp(1, true), + get_word_from_timestamp(1543622401, true) must be equal. + */ + + ASSERT_EQ("among", currency::get_word_from_timestamp(1, true)); + ASSERT_EQ(currency::get_word_from_timestamp(1, true), + currency::get_word_from_timestamp(1543622401, true)); + + /* + 2027462399 is the largest timestamp argument value under which the + inequality weeks_count < WALLET_BRAIN_DATE_MAX_WEEKS_COUNT is satisfied. + + timestamp = 2027462399 + date_offset = timestamp - WALLET_BRAIN_DATE_OFFSET = 483839999 + weeks_count = date_offset / WALLET_BRAIN_DATE_QUANTUM = 799 + WALLET_BRAIN_DATE_MAX_WEEKS_COUNT = 800 + WALLET_BRAIN_DATE_QUANTUM = 604800 + + floor(483839999 / 604800) = 799 + floor(483840000 / 604800) = 800 + */ + + // weeks_count_32 = 799; wordsArray[799] = "ugly" + ASSERT_EQ("ugly", currency::get_word_from_timestamp(2027462399, false)); + + // weeks_count_32 = 799 + 800 = 1599; wordsArray[1599] = "moan" + ASSERT_EQ("moan", currency::get_word_from_timestamp(2027462399, true)); + + /* + If you pass values ​​>= 2027462399 + 1, then the inequality + weeks_count < WALLET_BRAIN_DATE_MAX_WEEKS_COUNT is not satisfied. The + function throws an exception. + */ + + EXPECT_THROW(currency::get_word_from_timestamp(2027462400, false), + std::runtime_error); + + EXPECT_THROW(currency::get_word_from_timestamp(2027462400, true), + std::runtime_error); +} + +TEST(wallet_seed, timestamp_from_word) +{ + { + // WALLET_BRAIN_DATE_OFFSET = 1543622400 + + { + bool password_used{false}; + + ASSERT_EQ(1543622400, + currency::get_timestamp_from_word("like", password_used)); + ASSERT_FALSE(password_used); + } + + { + bool password_used{true}; + + ASSERT_EQ(1543622400, + currency::get_timestamp_from_word("like", password_used)); + ASSERT_FALSE(password_used); + } + } + + { + // WALLET_BRAIN_DATE_OFFSET = 1543622400 + + { + bool password_used{true}; + + ASSERT_EQ(1543622400, + currency::get_timestamp_from_word("among", password_used)); + ASSERT_TRUE(password_used); + } + + { + bool password_used{false}; + + ASSERT_EQ(1543622400, + currency::get_timestamp_from_word("among", password_used)); + ASSERT_TRUE(password_used); + } + } + + { + // (1625 - 800) * 604800 + 1543622400 = 2042582400 + + { + bool password_used{false}; + + ASSERT_EQ(2026857600, + currency::get_timestamp_from_word("ugly", password_used)); + ASSERT_FALSE(password_used); + } + + { + bool password_used{true}; + + ASSERT_EQ(2026857600, + currency::get_timestamp_from_word("ugly", password_used)); + ASSERT_FALSE(password_used); + } + } + + { + // (1625 - 800) * 604800 + 1543622400 = 2042582400 + + { + bool password_used{false}; + + ASSERT_EQ(2042582400, + currency::get_timestamp_from_word("weary", password_used)); + ASSERT_TRUE(password_used); + } + + { + bool password_used{true}; + + ASSERT_EQ(2042582400, + currency::get_timestamp_from_word("weary", password_used)); + ASSERT_TRUE(password_used); + } + } +} From 47a1bd985dc171d0bba89a3486ee3e41714dba7b Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 20 Aug 2024 18:27:17 +0200 Subject: [PATCH 18/23] unit_tests: fix for a gcc warning --- tests/unit_tests/amounts_tests.cpp | 234 ++++++++++++++--------------- 1 file changed, 117 insertions(+), 117 deletions(-) diff --git a/tests/unit_tests/amounts_tests.cpp b/tests/unit_tests/amounts_tests.cpp index 08abdaff..d2678d3c 100644 --- a/tests/unit_tests/amounts_tests.cpp +++ b/tests/unit_tests/amounts_tests.cpp @@ -312,139 +312,139 @@ TEST(decompose_amount_randomly, 1) TEST(print_money_brief, 1) { // decimal point 12 (default) - ASSERT_EQ(print_money_brief( 0), "0.0"); - ASSERT_EQ(print_money_brief( 1), "0.000000000001"); - ASSERT_EQ(print_money_brief( 1000000000000), "1.0"); - ASSERT_EQ(print_money_brief( 1900000000000), "1.9"); - ASSERT_EQ(print_money_brief( 1000000100000), "1.0000001"); - ASSERT_EQ(print_money_brief( 1000000000001), "1.000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999), "9.999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900), "90.0099900099"); - ASSERT_EQ(print_money_brief(10109010000000000000), "10109010.0"); - ASSERT_EQ(print_money_brief(10109010010000000000), "10109010.01"); - ASSERT_EQ(print_money_brief(18446744073709551610), "18446744.07370955161"); - ASSERT_EQ(print_money_brief(18446744073709551614), "18446744.073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615), "18446744.073709551615"); + ASSERT_EQ(print_money_brief( 0ull), "0.0"); + ASSERT_EQ(print_money_brief( 1ull), "0.000000000001"); + ASSERT_EQ(print_money_brief( 1000000000000ull), "1.0"); + ASSERT_EQ(print_money_brief( 1900000000000ull), "1.9"); + ASSERT_EQ(print_money_brief( 1000000100000ull), "1.0000001"); + ASSERT_EQ(print_money_brief( 1000000000001ull), "1.000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull), "9.999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull), "90.0099900099"); + ASSERT_EQ(print_money_brief(10109010000000000000ull), "10109010.0"); + ASSERT_EQ(print_money_brief(10109010010000000000ull), "10109010.01"); + ASSERT_EQ(print_money_brief(18446744073709551610ull), "18446744.07370955161"); + ASSERT_EQ(print_money_brief(18446744073709551614ull), "18446744.073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull), "18446744.073709551615"); // decimal point 0 - ASSERT_EQ(print_money_brief( 0, 0), "0"); - ASSERT_EQ(print_money_brief( 1, 0), "1"); - ASSERT_EQ(print_money_brief( 1000000000000, 0), "1000000000000"); - ASSERT_EQ(print_money_brief( 1900000000000, 0), "1900000000000"); - ASSERT_EQ(print_money_brief( 1000000100000, 0), "1000000100000"); - ASSERT_EQ(print_money_brief( 1000000000001, 0), "1000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999, 0), "9999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900, 0), "90009990009900"); - ASSERT_EQ(print_money_brief(10109010000000000000, 0), "10109010000000000000"); - ASSERT_EQ(print_money_brief(10109010010000000000, 0), "10109010010000000000"); - ASSERT_EQ(print_money_brief(18446744073709551610, 0), "18446744073709551610"); - ASSERT_EQ(print_money_brief(18446744073709551614, 0), "18446744073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 0), "18446744073709551615"); + ASSERT_EQ(print_money_brief( 0ull, 0), "0"); + ASSERT_EQ(print_money_brief( 1ull, 0), "1"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 0), "1000000000000"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 0), "1900000000000"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 0), "1000000100000"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 0), "1000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 0), "9999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 0), "90009990009900"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 0), "10109010000000000000"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 0), "10109010010000000000"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 0), "18446744073709551610"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 0), "18446744073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 0), "18446744073709551615"); // decimal point 1 - ASSERT_EQ(print_money_brief( 0, 1), "0.0"); - ASSERT_EQ(print_money_brief( 1, 1), "0.1"); - ASSERT_EQ(print_money_brief( 1000000000000, 1), "100000000000.0"); - ASSERT_EQ(print_money_brief( 1900000000000, 1), "190000000000.0"); - ASSERT_EQ(print_money_brief( 1000000100000, 1), "100000010000.0"); - ASSERT_EQ(print_money_brief( 1000000000001, 1), "100000000000.1"); - ASSERT_EQ(print_money_brief( 9999999999999, 1), "999999999999.9"); - ASSERT_EQ(print_money_brief( 90009990009900, 1), "9000999000990.0"); - ASSERT_EQ(print_money_brief(10109010000000000000, 1), "1010901000000000000.0"); - ASSERT_EQ(print_money_brief(10109010010000000000, 1), "1010901001000000000.0"); - ASSERT_EQ(print_money_brief(18446744073709551610, 1), "1844674407370955161.0"); - ASSERT_EQ(print_money_brief(18446744073709551614, 1), "1844674407370955161.4"); - ASSERT_EQ(print_money_brief(18446744073709551615, 1), "1844674407370955161.5"); + ASSERT_EQ(print_money_brief( 0ull, 1), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 1), "0.1"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 1), "100000000000.0"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 1), "190000000000.0"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 1), "100000010000.0"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 1), "100000000000.1"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 1), "999999999999.9"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 1), "9000999000990.0"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 1), "1010901000000000000.0"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 1), "1010901001000000000.0"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 1), "1844674407370955161.0"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 1), "1844674407370955161.4"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 1), "1844674407370955161.5"); // decimal point 2 - ASSERT_EQ(print_money_brief( 0, 2), "0.0"); - ASSERT_EQ(print_money_brief( 1, 2), "0.01"); - ASSERT_EQ(print_money_brief( 1000000000000, 2), "10000000000.0"); - ASSERT_EQ(print_money_brief( 1900000000000, 2), "19000000000.0"); - ASSERT_EQ(print_money_brief( 1000000100000, 2), "10000001000.0"); - ASSERT_EQ(print_money_brief( 1000000000001, 2), "10000000000.01"); - ASSERT_EQ(print_money_brief( 9999999999999, 2), "99999999999.99"); - ASSERT_EQ(print_money_brief( 90009990009900, 2), "900099900099.0"); - ASSERT_EQ(print_money_brief(10109010000000000000, 2), "101090100000000000.0"); - ASSERT_EQ(print_money_brief(10109010010000000000, 2), "101090100100000000.0"); - ASSERT_EQ(print_money_brief(18446744073709551610, 2), "184467440737095516.1"); - ASSERT_EQ(print_money_brief(18446744073709551614, 2), "184467440737095516.14"); - ASSERT_EQ(print_money_brief(18446744073709551615, 2), "184467440737095516.15"); + ASSERT_EQ(print_money_brief( 0ull, 2), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 2), "0.01"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 2), "10000000000.0"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 2), "19000000000.0"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 2), "10000001000.0"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 2), "10000000000.01"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 2), "99999999999.99"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 2), "900099900099.0"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 2), "101090100000000000.0"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 2), "101090100100000000.0"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 2), "184467440737095516.1"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 2), "184467440737095516.14"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 2), "184467440737095516.15"); // decimal point 3 - ASSERT_EQ(print_money_brief( 0, 3), "0.0"); - ASSERT_EQ(print_money_brief( 1, 3), "0.001"); - ASSERT_EQ(print_money_brief( 1000000000000, 3), "1000000000.0"); - ASSERT_EQ(print_money_brief( 1900000000000, 3), "1900000000.0"); - ASSERT_EQ(print_money_brief( 1000000100000, 3), "1000000100.0"); - ASSERT_EQ(print_money_brief( 1000000000001, 3), "1000000000.001"); - ASSERT_EQ(print_money_brief( 9999999999999, 3), "9999999999.999"); - ASSERT_EQ(print_money_brief( 90009990009900, 3), "90009990009.9"); - ASSERT_EQ(print_money_brief(10109010000000000000, 3), "10109010000000000.0"); - ASSERT_EQ(print_money_brief(10109010010000000000, 3), "10109010010000000.0"); - ASSERT_EQ(print_money_brief(18446744073709551610, 3), "18446744073709551.61"); - ASSERT_EQ(print_money_brief(18446744073709551614, 3), "18446744073709551.614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 3), "18446744073709551.615"); + ASSERT_EQ(print_money_brief( 0ull, 3), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 3), "0.001"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 3), "1000000000.0"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 3), "1900000000.0"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 3), "1000000100.0"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 3), "1000000000.001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 3), "9999999999.999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 3), "90009990009.9"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 3), "10109010000000000.0"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 3), "10109010010000000.0"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 3), "18446744073709551.61"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 3), "18446744073709551.614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 3), "18446744073709551.615"); // decimal point 18 - ASSERT_EQ(print_money_brief( 0, 18), "0.0"); - ASSERT_EQ(print_money_brief( 1, 18), "0.000000000000000001"); - ASSERT_EQ(print_money_brief( 1000000000000, 18), "0.000001"); - ASSERT_EQ(print_money_brief( 1900000000000, 18), "0.0000019"); - ASSERT_EQ(print_money_brief( 1000000100000, 18), "0.0000010000001"); - ASSERT_EQ(print_money_brief( 1000000000001, 18), "0.000001000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999, 18), "0.000009999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900, 18), "0.0000900099900099"); - ASSERT_EQ(print_money_brief(10109010000000000000, 18), "10.10901"); - ASSERT_EQ(print_money_brief(10109010010000000000, 18), "10.10901001"); - ASSERT_EQ(print_money_brief(18446744073709551610, 18), "18.44674407370955161"); - ASSERT_EQ(print_money_brief(18446744073709551614, 18), "18.446744073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 18), "18.446744073709551615"); + ASSERT_EQ(print_money_brief( 0ull, 18), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 18), "0.000000000000000001"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 18), "0.000001"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 18), "0.0000019"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 18), "0.0000010000001"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 18), "0.000001000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 18), "0.000009999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 18), "0.0000900099900099"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 18), "10.10901"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 18), "10.10901001"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 18), "18.44674407370955161"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 18), "18.446744073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 18), "18.446744073709551615"); // decimal point 19 - ASSERT_EQ(print_money_brief( 0, 19), "0.0"); - ASSERT_EQ(print_money_brief( 1, 19), "0.0000000000000000001"); - ASSERT_EQ(print_money_brief( 1000000000000, 19), "0.0000001"); - ASSERT_EQ(print_money_brief( 1900000000000, 19), "0.00000019"); - ASSERT_EQ(print_money_brief( 1000000100000, 19), "0.00000010000001"); - ASSERT_EQ(print_money_brief( 1000000000001, 19), "0.0000001000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999, 19), "0.0000009999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900, 19), "0.00000900099900099"); - ASSERT_EQ(print_money_brief(10109010000000000000, 19), "1.010901"); - ASSERT_EQ(print_money_brief(10109010010000000000, 19), "1.010901001"); - ASSERT_EQ(print_money_brief(18446744073709551610, 19), "1.844674407370955161"); - ASSERT_EQ(print_money_brief(18446744073709551614, 19), "1.8446744073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 19), "1.8446744073709551615"); + ASSERT_EQ(print_money_brief( 0ull, 19), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 19), "0.0000000000000000001"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 19), "0.0000001"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 19), "0.00000019"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 19), "0.00000010000001"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 19), "0.0000001000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 19), "0.0000009999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 19), "0.00000900099900099"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 19), "1.010901"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 19), "1.010901001"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 19), "1.844674407370955161"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 19), "1.8446744073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 19), "1.8446744073709551615"); // TODO: remove it after setting reasonable limit of 18 // decimal point 20 - ASSERT_EQ(print_money_brief( 0, 20), "0.0"); - ASSERT_EQ(print_money_brief( 1, 20), "0.00000000000000000001"); - ASSERT_EQ(print_money_brief( 1000000000000, 20), "0.00000001"); - ASSERT_EQ(print_money_brief( 1900000000000, 20), "0.000000019"); - ASSERT_EQ(print_money_brief( 1000000100000, 20), "0.000000010000001"); - ASSERT_EQ(print_money_brief( 1000000000001, 20), "0.00000001000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999, 20), "0.00000009999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900, 20), "0.000000900099900099"); - ASSERT_EQ(print_money_brief(10109010000000000000, 20), "0.1010901"); - ASSERT_EQ(print_money_brief(10109010010000000000, 20), "0.1010901001"); - ASSERT_EQ(print_money_brief(18446744073709551610, 20), "0.1844674407370955161"); - ASSERT_EQ(print_money_brief(18446744073709551614, 20), "0.18446744073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 20), "0.18446744073709551615"); + ASSERT_EQ(print_money_brief( 0ull, 20), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 20), "0.00000000000000000001"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 20), "0.00000001"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 20), "0.000000019"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 20), "0.000000010000001"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 20), "0.00000001000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 20), "0.00000009999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 20), "0.000000900099900099"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 20), "0.1010901"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 20), "0.1010901001"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 20), "0.1844674407370955161"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 20), "0.18446744073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 20), "0.18446744073709551615"); // TODO: remove it after setting reasonable limit of 18 // decimal point 21 - ASSERT_EQ(print_money_brief( 0, 21), "0.0"); - ASSERT_EQ(print_money_brief( 1, 21), "0.000000000000000000001"); - ASSERT_EQ(print_money_brief( 1000000000000, 21), "0.000000001"); - ASSERT_EQ(print_money_brief( 1900000000000, 21), "0.0000000019"); - ASSERT_EQ(print_money_brief( 1000000100000, 21), "0.0000000010000001"); - ASSERT_EQ(print_money_brief( 1000000000001, 21), "0.000000001000000000001"); - ASSERT_EQ(print_money_brief( 9999999999999, 21), "0.000000009999999999999"); - ASSERT_EQ(print_money_brief( 90009990009900, 21), "0.0000000900099900099"); - ASSERT_EQ(print_money_brief(10109010000000000000, 21), "0.01010901"); - ASSERT_EQ(print_money_brief(10109010010000000000, 21), "0.01010901001"); - ASSERT_EQ(print_money_brief(18446744073709551610, 21), "0.01844674407370955161"); - ASSERT_EQ(print_money_brief(18446744073709551614, 21), "0.018446744073709551614"); - ASSERT_EQ(print_money_brief(18446744073709551615, 21), "0.018446744073709551615"); + ASSERT_EQ(print_money_brief( 0ull, 21), "0.0"); + ASSERT_EQ(print_money_brief( 1ull, 21), "0.000000000000000000001"); + ASSERT_EQ(print_money_brief( 1000000000000ull, 21), "0.000000001"); + ASSERT_EQ(print_money_brief( 1900000000000ull, 21), "0.0000000019"); + ASSERT_EQ(print_money_brief( 1000000100000ull, 21), "0.0000000010000001"); + ASSERT_EQ(print_money_brief( 1000000000001ull, 21), "0.000000001000000000001"); + ASSERT_EQ(print_money_brief( 9999999999999ull, 21), "0.000000009999999999999"); + ASSERT_EQ(print_money_brief( 90009990009900ull, 21), "0.0000000900099900099"); + ASSERT_EQ(print_money_brief(10109010000000000000ull, 21), "0.01010901"); + ASSERT_EQ(print_money_brief(10109010010000000000ull, 21), "0.01010901001"); + ASSERT_EQ(print_money_brief(18446744073709551610ull, 21), "0.01844674407370955161"); + ASSERT_EQ(print_money_brief(18446744073709551614ull, 21), "0.018446744073709551614"); + ASSERT_EQ(print_money_brief(18446744073709551615ull, 21), "0.018446744073709551615"); } From 4d6291d7ff13b5b4f0577fb585151858c990f698 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 22 Aug 2024 15:30:51 +0200 Subject: [PATCH 19/23] rpc: find_outs_in_recent_blocks RPC implemented --- src/rpc/core_rpc_server.cpp | 104 ++++++++++++++++++++++++ src/rpc/core_rpc_server.h | 3 + src/rpc/core_rpc_server_commands_defs.h | 53 ++++++++++++ 3 files changed, 160 insertions(+) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index ee76e1ac..6d45766e 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1301,6 +1301,110 @@ namespace currency return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_find_outs_in_recent_blocks(const COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::request& req, COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::response& resp, epee::json_rpc::error& error_resp, connection_context& cntx) + { +#define LOCAL_CHECK(cond, msg) if (!(cond)) { error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM; error_resp.message = msg; LOG_PRINT_L1("on_find_outs_in_recent_blocks: " << msg); return false; } +#define LOCAL_CHECK_INT_ERR(cond, msg) if (!(cond)) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; error_resp.message = msg; LOG_PRINT_L1("on_find_outs_in_recent_blocks: " << msg); return false; } + + LOCAL_CHECK(req.address != account_public_address{}, "address is missing"); + LOCAL_CHECK(req.viewkey != null_skey, "viewkey is missing"); + LOCAL_CHECK(0 <= req.blocks_limit && req.blocks_limit <= 5, "blocks_limit is out of allowed bounds"); + + // verify addess keys + crypto::point_t view_pk, spend_pk; + LOCAL_CHECK(view_pk.from_public_key(req.address.view_public_key), "cannon load point from address.view_public_key"); + LOCAL_CHECK(view_pk.is_in_main_subgroup(), "address.view_public_key isn't in main subgroup"); + LOCAL_CHECK(spend_pk.from_public_key(req.address.spend_public_key), "cannon load point from address.spend_public_key"); + LOCAL_CHECK(spend_pk.is_in_main_subgroup(), "address.spend_public_key isn't in main subgroup"); + + // verify viewkey + crypto::scalar_t view_sc = req.viewkey; + LOCAL_CHECK(view_sc.is_reduced(), "viewkey is invalid"); + LOCAL_CHECK(view_sc * crypto::c_point_G == view_pk, "viewkey doesn't correspond to the given address"); + + const blockchain_storage& bcs = m_core.get_blockchain_storage(); + resp.blockchain_top_block_height = bcs.get_top_block_height(); + resp.blocks_limit = req.blocks_limit; + + // get blockchain transactions + std::unordered_map, std::list>> blockchain_txs; // block height -> (vector of tx_ids, list of txs) + if (req.blocks_limit > 0) + { + uint64_t start_offset = resp.blockchain_top_block_height - req.blocks_limit + 1; + std::list recent_blocks; + LOCAL_CHECK_INT_ERR(bcs.get_blocks(start_offset, req.blocks_limit, recent_blocks), "cannot get recent blocks"); + + std::vector blockchain_tx_ids, missed_tx; + for(auto& b : recent_blocks) + { + blockchain_tx_ids.insert(blockchain_tx_ids.end(), b.tx_hashes.begin(), b.tx_hashes.end()); + uint64_t height = get_block_height(b); + auto& el = blockchain_txs[height]; + el.first = b.tx_hashes; + missed_tx.clear(); + LOCAL_CHECK_INT_ERR(bcs.get_transactions(b.tx_hashes, el.second, missed_tx), "bcs.get_transactions failed"); + LOCAL_CHECK_INT_ERR(missed_tx.empty(), "missed_tx is not empty"); + LOCAL_CHECK_INT_ERR(el.first.size() == el.second.size(), "el.first.size() != el.second.size()"); + } + } + + // get pool transactions + std::list pool_txs; + LOCAL_CHECK_INT_ERR(m_core.get_tx_pool().get_transactions(pool_txs), "cannot get txs from pool"); + + // processor lambda + auto process_tx = [&](const transaction& tx, const crypto::hash& tx_id, const int64_t height) { + crypto::key_derivation derivation{}; + LOCAL_CHECK(generate_key_derivation(get_tx_pub_key_from_extra(tx), req.viewkey, derivation), "generate_key_derivation failed"); + + for(size_t i = 0, sz = tx.vout.size(); i < sz; ++i) + { + const tx_out_v& outv = tx.vout[i]; + if (outv.type() != typeid(tx_out_zarcanum)) + continue; + + uint64_t decoded_amount = 0; + crypto::public_key decoded_asset_id{}; + crypto::scalar_t amount_blinding_mask{}, asset_id_blinding_mask{}; + if (!is_out_to_acc(req.address, boost::get(outv), derivation, i, decoded_amount, decoded_asset_id, amount_blinding_mask, asset_id_blinding_mask)) + continue; + + auto& el = resp.outputs.emplace_back(); + el.amount = decoded_amount; + el.asset_id = decoded_asset_id; + el.tx_id = tx_id; + el.tx_block_height = height; + el.output_tx_index = i; + } + return true; + }; + + // process blockchain txs + for(auto& [height, pair] : blockchain_txs) + { + LOCAL_CHECK(pair.first.size() == pair.second.size(), "container size inconsistency"); + auto tx_it = pair.second.begin(); + for(size_t i = 0, sz = pair.first.size(); i < sz; ++i, ++tx_it) + { + const crypto::hash& tx_id = pair.first[i]; + LOCAL_CHECK(process_tx(*tx_it, tx_id, height), "process blockchain tx failed for tx " + crypto::pod_to_hex(tx_id)); + } + } + + // process pool txs + for(auto& tx : pool_txs) + { + crypto::hash tx_id = get_transaction_hash(tx); + LOCAL_CHECK(process_tx(tx, tx_id, -1), "process pool tx failed for tx " + crypto::pod_to_hex(tx_id)); + } + + resp.status = resp.outputs.empty() ? API_RETURN_CODE_NOT_FOUND : API_RETURN_CODE_OK; + return true; + +#undef LOCAL_CHECK_INT_ERR +#undef LOCAL_CHECK + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_aliases_by_address(const COMMAND_RPC_GET_ALIASES_BY_ADDRESS::request& req, COMMAND_RPC_GET_ALIASES_BY_ADDRESS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx) { account_public_address addr = AUTO_VAL_INIT(addr); diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 02e7b478..8e44a31a 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -94,6 +94,7 @@ namespace currency bool on_get_alt_block_details(const COMMAND_RPC_GET_BLOCK_DETAILS::request& req, COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx); bool on_get_alt_blocks_details(const COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::request& req, COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::response& res, connection_context& cntx); bool on_get_est_height_from_date(const COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE::request& req, COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE::response& res, connection_context& cntx); + bool on_find_outs_in_recent_blocks(const COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::request& req, COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx); bool on_validate_signature(const COMMAND_VALIDATE_SIGNATURE::request& req, COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx); @@ -133,6 +134,8 @@ namespace currency MAP_JON_RPC_WE("get_alias_by_address", on_aliases_by_address, COMMAND_RPC_GET_ALIASES_BY_ADDRESS) MAP_JON_RPC_WE("get_alias_reward", on_get_alias_reward, COMMAND_RPC_GET_ALIAS_REWARD) MAP_JON_RPC ("get_est_height_from_date", on_get_est_height_from_date, COMMAND_RPC_GET_EST_HEIGHT_FROM_DATE) + MAP_JON_RPC_WE("find_outs_in_recent_blocks", on_find_outs_in_recent_blocks, COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS) + //block explorer api MAP_JON_RPC ("get_blocks_details", on_rpc_get_blocks_details, COMMAND_RPC_GET_BLOCKS_DETAILS) MAP_JON_RPC_WE("get_tx_details", on_get_tx_details, COMMAND_RPC_GET_TX_DETAILS) diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 9a89d043..452a8316 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -23,6 +23,7 @@ #include #include #include +#include //#include "currency_core/basic_api_response_codes.h" namespace currency @@ -289,6 +290,58 @@ namespace currency }; }; //----------------------------------------------- + struct COMMAND_RPC_FIND_OUTS_IN_RECENT_BLOCKS + { + DOC_COMMAND("Retrieves information about outputs in recent blocks that are targeted for the given address with the corresponding secret view key.") + + static constexpr uint64_t blocks_limit_default = 5; + + struct request + { + account_public_address address; + crypto::secret_key viewkey; + uint64_t blocks_limit = blocks_limit_default; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE_ADDRESS_AS_TEXT(address) DOC_DSCR("Target address for which outputs are being searched") DOC_EXMP("ZxCSpsGGeJsS8fwvQ4HktDU3qBeauoJTR6j73jAWWZxFXdF7XTbGm4YfS2kXJmAP4Rf5BVsSQ9iZ45XANXEYsrLN2L2W77dH7") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(viewkey) DOC_DSCR("Secret view key corresponding to the given address.") DOC_EXMP("5fa8eaaf231a305053260ff91d69c6ef1ecbd0f5") DOC_END + KV_SERIALIZE(blocks_limit) DOC_DSCR("Block count limit. If 0, only the transaction pool will be searched. Maximum and default is " + epee::string_tools::num_to_string_fast(blocks_limit_default) + ".") DOC_EXMP(1711021795) DOC_END + END_KV_SERIALIZE_MAP() + }; + + struct out_entry + { + uint64_t amount; + crypto::public_key asset_id; + crypto::hash tx_id; + int64_t tx_block_height; + uint64_t output_tx_index; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(amount) DOC_DSCR("The amount of the output.") DOC_EXMP(1000000000000) DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) DOC_DSCR("Asset ID of the output.") DOC_EXMP("cc4e69455e63f4a581257382191de6856c2156630b3fba0db4bdd73ffcfb36b6") DOC_END + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) DOC_DSCR("Transaction ID where the output is present, if found.") DOC_EXMP("a6e8da986858e6825fce7a192097e6afae4e889cabe853a9c29b964985b23da8") DOC_END + KV_SERIALIZE(tx_block_height) DOC_DSCR("Block height where the transaction is present.") DOC_EXMP(2555000) DOC_END + KV_SERIALIZE(output_tx_index) DOC_DSCR("Index of the output in the transaction.") DOC_EXMP(2) DOC_END + END_KV_SERIALIZE_MAP() + }; + + struct response + { + std::vector outputs; + uint64_t blockchain_top_block_height; + uint64_t blocks_limit; + std::string status; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(outputs) DOC_DSCR("List of found outputs.") DOC_EXMP_AUTO(1) DOC_END + KV_SERIALIZE(blockchain_top_block_height) DOC_DSCR("Height of the most recent block in the blockchain.") DOC_EXMP(2555000) DOC_END + KV_SERIALIZE(blocks_limit) DOC_DSCR("Used limit for block count.") DOC_EXMP(5) DOC_END + KV_SERIALIZE(status) DOC_DSCR("Status of the call.") DOC_EXMP(API_RETURN_CODE_OK) DOC_END + END_KV_SERIALIZE_MAP() + }; + }; + //----------------------------------------------- struct COMMAND_RPC_GET_TX_POOL { DOC_COMMAND("Retreives transactions from tx pool (and other information).") From ee93fc00e60c143d172a62b3f55faae3e25b1441 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 27 Aug 2024 18:48:10 +0200 Subject: [PATCH 20/23] updated ui --- src/gui/qt-daemon/layout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index 748e8e96..65fb3594 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit 748e8e96d8f2653e6e698a11f67c172c1f84c2b2 +Subproject commit 65fb3594d1930d943c029b103a2de43fae498452 From 62c02dab24db75c8a5b4743812d9f413aa1cb51a Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 27 Aug 2024 18:52:34 +0200 Subject: [PATCH 21/23] minor improvements --- src/currency_core/blockchain_storage.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 419cdd1c..eec4e0df 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -3880,11 +3880,9 @@ uint64_t blockchain_storage::get_assets(uint64_t offset, uint64_t count, std::li m_db_assets.enumerate_items([&](uint64_t i, const crypto::public_key& asset_id, const std::list& asset_descriptor_history) { if (i < offset) - { - return true; - } + return true; // continue - CHECK_AND_ASSERT_THROW_MES(asset_descriptor_history.size(), "asset_descriptor_history unexpectedly have 0 size"); + CHECK_AND_ASSERT_THROW_MES(asset_descriptor_history.size(), "asset_descriptor_history unexpectedly have 0 size, asset_id: " << asset_id); assets.push_back(asset_descriptor_with_id()); static_cast(assets.back()) = asset_descriptor_history.back().descriptor; assets.back().asset_id = asset_id; From bc3077e42923a636d259fcadb5a2c313b141b561 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Tue, 27 Aug 2024 19:53:11 +0300 Subject: [PATCH 22/23] === build number: 337 -> 338 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index 2beb8256..60db7696 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 337 +#define PROJECT_VERSION_BUILD_NO 338 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 0b7a138abd4893b63f51136e63aaed7608e1a3ed Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 27 Aug 2024 19:50:05 +0200 Subject: [PATCH 23/23] attempt to fix macos compilation --- src/rpc/core_rpc_server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 6d45766e..57a5a2e8 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1332,7 +1332,7 @@ namespace currency { uint64_t start_offset = resp.blockchain_top_block_height - req.blocks_limit + 1; std::list recent_blocks; - LOCAL_CHECK_INT_ERR(bcs.get_blocks(start_offset, req.blocks_limit, recent_blocks), "cannot get recent blocks"); + LOCAL_CHECK_INT_ERR(bcs.get_blocks(start_offset, static_cast(req.blocks_limit), recent_blocks), "cannot get recent blocks"); std::vector blockchain_tx_ids, missed_tx; for(auto& b : recent_blocks)