From cf5bfd5b7913ce020c1d3a333b3d774a1641a5ed Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:32:35 +0000 Subject: [PATCH 01/14] CMake: make test building optional --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6adb8998..4a0376c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,8 +201,11 @@ else() endif() endif() +set(BUILD_TESTS FALSE CACHE BOOL "Build Zano tests") add_subdirectory(contrib) add_subdirectory(src) -add_subdirectory(tests) +if (BUILD_TESTS) + add_subdirectory(tests) +endif() From 2c79dbc5a7abb350979f0de47011c6721fe7f048 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:32:59 +0000 Subject: [PATCH 02/14] Makefile: refactor for extensibility + CMake MSYS --- Makefile | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 451319b0..4e093a59 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,43 @@ -all: all-release +# Define CMake generator +system := $(shell uname) +ifneq (, $(findstring MINGW, $(system))) + cmake_gen = -G 'MSYS Makefiles' +endif -cmake-debug: - mkdir -p build/debug - cd build/debug && cmake -D CMAKE_BUILD_TYPE=Debug ../.. +cmake = cmake $(cmake_gen) -build-debug: cmake-debug - cd build/debug && $(MAKE) +cmake_debug = $(cmake) -D CMAKE_BUILD_TYPE=Debug +cmake_release = $(cmake) -D CMAKE_BUILD_TYPE=Release +cmake_tests = $(cmake) -D BUILD_TESTS=ON -test-debug: build-debug - cd build/debug && $(MAKE) test +# Helper macro +define CMAKE + mkdir -p $1 && cd $1 && $2 ../../ +endef -all-debug: build-debug +build = build +dir_debug = $(build)/debug +dir_release = $(build)/release -cmake-release: - mkdir -p build/release - cd build/release && cmake -D CMAKE_BUILD_TYPE=Release ../.. +all: release -build-release: cmake-release - cd build/release && $(MAKE) +release: + $(eval command += $(cmake_release)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) -test-release: build-release - cd build/release && $(MAKE) test +test-release: + $(eval command += $(cmake_release) $(cmake_tests)) + $(call CMAKE,$(dir_release),$(command)) && $(MAKE) && $(MAKE) test -all-release: build-release +test: test-release + +debug: + $(eval command += $(cmake_debug)) + $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) + +test-debug: + $(eval command += $(cmake_debug) $(cmake_tests)) + $(call CMAKE,$(dir_debug),$(command)) && $(MAKE) && $(MAKE) test clean: rm -rf build @@ -30,4 +45,4 @@ clean: tags: ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest -.PHONY: all cmake-debug build-debug test-debug all-debug cmake-release build-release test-release all-release clean tags +.PHONY: all release test-release test all-debug debug test-debug clean tags From 71daaa827d369fd15e6ce9126f3fc13d2b75e3e4 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 02:42:47 +0000 Subject: [PATCH 03/14] Makefile: add copyright --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 4e093a59..7eff3b9e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +# Copyright (c) 2014-2019 Zano Project +# Copyright (c) 2014 The Cryptonote developers +# Distributed under the MIT/X11 software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + # Define CMake generator system := $(shell uname) ifneq (, $(findstring MINGW, $(system))) From e344efefb739196f0e75b86ee0e23388c02459ba Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 04:11:33 +0000 Subject: [PATCH 04/14] currency_core: resolve build warnings (-Wlogical-not-parentheses) --- src/currency_core/blockchain_storage.cpp | 2 +- src/currency_core/currency_format_utils.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index dfe9c6a4..13d7d90c 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -3544,7 +3544,7 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha if (!m_is_in_checkpoint_zone) { CHECK_AND_ASSERT_MES(tx.signatures.size() == sig_index, false, "tx signatures count differs from inputs"); - if (!get_tx_flags(tx)&TX_FLAG_SIGNATURE_MODE_SEPARATE) + if (!(get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE)) { bool r = validate_attachment_info(tx.extra, tx.attachment, false); CHECK_AND_ASSERT_MES(r, false, "Failed to validate attachments in tx " << tx_prefix_hash << ": incorrect extra_attachment_info in tx.extra"); diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 673092ca..ad612fe8 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -1109,7 +1109,7 @@ namespace currency att_count++; } } - if (!flags&TX_FLAG_SIGNATURE_MODE_SEPARATE) + if (!(flags & TX_FLAG_SIGNATURE_MODE_SEPARATE)) { //take hash from attachment and put into extra if (tx.attachment.size()) @@ -2374,7 +2374,7 @@ namespace currency //--------------------------------------------------------------- bool is_pos_block(const block& b) { - if (!b.flags&CURRENCY_BLOCK_FLAG_POS_BLOCK) + if (!(b.flags & CURRENCY_BLOCK_FLAG_POS_BLOCK)) return false; return is_pos_block(b.miner_tx); } From b3a8435175781c32e98abb5941f22518c71e9847 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 05:59:42 +0000 Subject: [PATCH 05/14] db_tests: fix undefined references in get_log_chunk_gzipped --- tests/db_tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/db_tests/CMakeLists.txt b/tests/db_tests/CMakeLists.txt index 294f3112..2333a149 100644 --- a/tests/db_tests/CMakeLists.txt +++ b/tests/db_tests/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(db_tests db_tests.cpp) -target_link_libraries(db_tests crypto common lmdb ${Boost_LIBRARIES}) +target_link_libraries(db_tests crypto common lmdb zlib ${Boost_LIBRARIES}) From 17373549c08008ec2de5fc572044a4dad0832c2c Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 07:19:02 +0000 Subject: [PATCH 06/14] zano: resolve build warnings (-Wdelete-non-virtual-dtor) --- src/currency_core/bc_attachments_service_manager.h | 2 ++ src/simplewallet/simplewallet.h | 2 +- src/wallet/core_default_rpc_proxy.h | 2 +- src/wallet/core_rpc_proxy.h | 2 ++ src/wallet/wallet2.h | 4 +++- tests/core_tests/test_core_proxy.h | 2 ++ 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/currency_core/bc_attachments_service_manager.h b/src/currency_core/bc_attachments_service_manager.h index 8f95d699..bd4f2640 100644 --- a/src/currency_core/bc_attachments_service_manager.h +++ b/src/currency_core/bc_attachments_service_manager.h @@ -12,6 +12,8 @@ namespace currency { struct i_bc_service { + virtual ~i_bc_service() = default; + virtual std::string get_id() = 0; virtual bool init(const std::string& config_folder, const boost::program_options::variables_map& vm) = 0; virtual bool deinit() = 0; diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 2b138841..70fa3f85 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -22,7 +22,7 @@ namespace currency /************************************************************************/ /* */ /************************************************************************/ - class simple_wallet : public tools::i_wallet2_callback, + class simple_wallet final : public tools::i_wallet2_callback, public std::enable_shared_from_this { public: diff --git a/src/wallet/core_default_rpc_proxy.h b/src/wallet/core_default_rpc_proxy.h index 6ac1b111..ec43ab5f 100644 --- a/src/wallet/core_default_rpc_proxy.h +++ b/src/wallet/core_default_rpc_proxy.h @@ -16,7 +16,7 @@ namespace tools { - class default_http_core_proxy: public i_core_proxy + class default_http_core_proxy final : public i_core_proxy { public: diff --git a/src/wallet/core_rpc_proxy.h b/src/wallet/core_rpc_proxy.h index 71a06eff..9ea481f2 100644 --- a/src/wallet/core_rpc_proxy.h +++ b/src/wallet/core_rpc_proxy.h @@ -16,6 +16,8 @@ namespace tools */ struct i_core_proxy { + virtual ~i_core_proxy() = default; + virtual bool set_connection_addr(const std::string& url){ return false; } virtual bool call_COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES(const currency::COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& rqt, currency::COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& rsp){ return false; } virtual bool call_COMMAND_RPC_GET_BLOCKS_FAST(const currency::COMMAND_RPC_GET_BLOCKS_FAST::request& rqt, currency::COMMAND_RPC_GET_BLOCKS_FAST::response& rsp){ return false; } diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 819fde3f..66440855 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -68,6 +68,8 @@ namespace tools class i_wallet2_callback { public: + virtual ~i_wallet2_callback() = default; + virtual void on_new_block(uint64_t /*height*/, const currency::block& /*block*/) {} virtual void on_transfer2(const wallet_rpc::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) {} virtual void on_pos_block_found(const currency::block& /*block*/) {} @@ -1204,4 +1206,4 @@ namespace tools #undef LOG_DEFAULT_CHANNEL #define LOG_DEFAULT_CHANNEL "wallet" -ENABLE_CHANNEL_BY_DEFAULT("wallet"); \ No newline at end of file +ENABLE_CHANNEL_BY_DEFAULT("wallet"); diff --git a/tests/core_tests/test_core_proxy.h b/tests/core_tests/test_core_proxy.h index eaad9e51..83694ecd 100644 --- a/tests/core_tests/test_core_proxy.h +++ b/tests/core_tests/test_core_proxy.h @@ -12,6 +12,8 @@ class test_core_listener { public: + virtual ~test_core_listener() = default; + virtual void before_tx_pushed_to_core(const currency::transaction& tx, const currency::blobdata& blob, currency::core& c, bool invalid_tx = false) {} // invalid_tx is true when processing a tx, marked as invalid in a test virtual void before_block_pushed_to_core(const currency::block& block, const currency::blobdata& blob, currency::core& c) {} }; From 5ac0b225cfdbc8881f86df054f68fc037b65a24e Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 07:21:48 +0000 Subject: [PATCH 07/14] core_fast_rpc_proxy: resolve build warning (-Winconsistent-missing-override) --- src/gui/qt-daemon/application/core_fast_rpc_proxy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/application/core_fast_rpc_proxy.h b/src/gui/qt-daemon/application/core_fast_rpc_proxy.h index 39f371e1..ca189240 100644 --- a/src/gui/qt-daemon/application/core_fast_rpc_proxy.h +++ b/src/gui/qt-daemon/application/core_fast_rpc_proxy.h @@ -124,7 +124,7 @@ namespace tools return m_rpc.on_get_current_core_tx_expiration_median(req, res, m_cntxt_stub); } //------------------------------------------------------------------------------------------------------------------------------ - bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) + bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) override { return m_rpc.on_get_pool_info(req, res, m_cntxt_stub); } From eec9c9e45c3daf8a9f1aa2145ebb6a221f65c47a Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 07:30:44 +0000 Subject: [PATCH 08/14] unit_tests: resolve epee build warning (-Wunused-lambda-capture) The local variable is not required to be captured for this impl. --- tests/unit_tests/epee_levin_protocol_handler_async.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index 996451a8..b256b12c 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -264,7 +264,7 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_initial TEST_F(positive_test_connection_to_levin_protocol_handler_calls, concurent_handler_initialization_and_destruction_is_correct) { const size_t connection_count = 10000; - auto create_and_destroy_connections = [this, connection_count]() + auto create_and_destroy_connections = [this]() { std::vector connections(connection_count); for (size_t i = 0; i < connection_count; ++i) From f91bce9a9167c6db73289462cae99ad03f82c512 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 07:33:26 +0000 Subject: [PATCH 09/14] core_tests: resolve build warning (-Wbackslash-newline-escape) --- tests/core_tests/pos_validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core_tests/pos_validation.cpp b/tests/core_tests/pos_validation.cpp index 9c45addf..a137fc8f 100644 --- a/tests/core_tests/pos_validation.cpp +++ b/tests/core_tests/pos_validation.cpp @@ -989,7 +989,7 @@ bool pos_altblocks_validation::generate(std::vector& events) c // || \- (2a)- #3a#- | <- alt chain // |+--------------+ \ | \ PoS block 2a uses stake already spent in main chain (okay) // +---------------|-------+ \ PoS block 3a uses stake already spent in current alt chain (fail) - // | \ \ + // | \ \ // | \ ...... (2br)- (3b)- #4b# <- alt chain // | | // +-----------------------+ PoS block 3b uses as stake an output, created in current alt chain (2a) From 86f93e3b939271051728d62abdde0ef5a771f6a7 Mon Sep 17 00:00:00 2001 From: anonimal Date: Wed, 20 Feb 2019 07:45:41 +0000 Subject: [PATCH 10/14] simplewallet: resolve build warning (-Wunused-lambda-capture) --- src/simplewallet/simplewallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 845c2ec2..b885ea86 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1401,7 +1401,7 @@ int main(int argc, char* argv[]) bool r = wrpc.init(vm); CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize wallet rpc server"); - tools::signal_handler::install([&wrpc, &wal] { + tools::signal_handler::install([&wrpc/*, &wal*/ /* TODO(unassigned): use? */] { wrpc.send_stop_signal(); }); LOG_PRINT_L0("Starting wallet rpc server"); From ad77ef54f50e67596f232915878fdb9f07930652 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Wed, 20 Feb 2019 20:04:11 +0100 Subject: [PATCH 11/14] attempt to fix #13 --- tests/core_tests/chain_switch_1.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/core_tests/chain_switch_1.cpp b/tests/core_tests/chain_switch_1.cpp index 512e23cf..d4a0f403 100644 --- a/tests/core_tests/chain_switch_1.cpp +++ b/tests/core_tests/chain_switch_1.cpp @@ -313,11 +313,8 @@ bool bad_chain_switching_with_rollback::c1(currency::core& c, size_t ev_index, c } //----------------------------------------------------------------------------------------------------- - struct tx_in_pool_info { - tx_in_pool_info() {} - tx_in_pool_info(crypto::hash hash, size_t blobsize) : hash(hash), blobsize(blobsize) {} crypto::hash hash; size_t blobsize; }; @@ -325,8 +322,13 @@ struct tx_in_pool_info struct params_tx_pool { params_tx_pool() {} - params_tx_pool(crypto::hash hash, size_t blobsize) : txs({ tx_in_pool_info(hash, blobsize) }) {} - params_tx_pool(crypto::hash hash1, size_t blobsize1, crypto::hash hash2, size_t blobsize2) : txs({ tx_in_pool_info(hash1, blobsize1), tx_in_pool_info(hash2, blobsize2) }) {} + params_tx_pool(crypto::hash hash, size_t blobsize) : txs{ tx_in_pool_info{ hash, blobsize } } + {} + params_tx_pool(crypto::hash hash1, size_t blobsize1, crypto::hash hash2, size_t blobsize2) + { + txs.push_back(tx_in_pool_info{ hash1, blobsize1 }); + txs.push_back(tx_in_pool_info{ hash2, blobsize2 }); + } std::vector txs; BEGIN_KV_SERIALIZE_MAP() From 0cceac7d660415ce67a1d4242f4958e140fea00a Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 21 Feb 2019 10:27:57 +0300 Subject: [PATCH 12/14] conn_tool: compilation warnings fixed --- src/connectivity_tool/conn_tool.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index 08edbcf2..e29adcf2 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -268,7 +268,7 @@ struct payment_method_summary void process_payment_entrie(payment_method_summary& pms, const std::string& amount_in_coin, uint64_t amount_in_this, const std::string& to_usd_rate) { double d_amount_in_coin = std::stod(amount_in_coin); - double d_to_usd_rate = std::stod(to_usd_rate); + // double d_to_usd_rate = std::stod(to_usd_rate); //CHECK_AND_ASSERT_THROW_MES(d_amount_in_coin, "unable to parse amount_in_coin: " << amount_in_coin); CHECK_AND_ASSERT_THROW_MES(amount_in_this, "unable to parse amount_this"); //CHECK_AND_ASSERT_THROW_MES(d_to_usd_rate, "unable to parse to_usd_rate: " << to_usd_rate); @@ -960,7 +960,6 @@ bool handle_download_peer_log(po::variables_map& vm) const uint64_t chunk_size = 1024 * 1024 * 5; uint64_t end_offset = start_offset; - uint64_t bytes = 0; while (true) { req.log_chunk_offset = end_offset; From ae3858c8bb897a8d5a6f56f854b730f5f3b834d5 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 21 Feb 2019 21:33:52 +0300 Subject: [PATCH 13/14] waller2: address prefix for logging --- src/wallet/wallet2.cpp | 247 ++++++++++++++++++---------------- src/wallet/wallet2.h | 65 +++++++-- src/wallet/wallet2_escrow.cpp | 21 +-- 3 files changed, 193 insertions(+), 140 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 49c403ae..29e2fe23 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -14,6 +14,7 @@ using namespace epee; #include "string_coding.h" +#define KEEP_WALLET_LOG_MACROS #include "wallet2.h" #include "currency_core/currency_format_utils.h" #include "currency_core/bc_offers_service_basic.h" @@ -33,19 +34,19 @@ ENABLE_CHANNEL_BY_DEFAULT("wallet") namespace tools { //---------------------------------------------------------------------------------------------------- -void fill_transfer_details(const currency::transaction& tx, const tools::money_transfer2_details& td, tools::wallet_rpc::wallet_transfer_info_details& res_td) +void wallet2::fill_transfer_details(const currency::transaction& tx, const tools::money_transfer2_details& td, tools::wallet_rpc::wallet_transfer_info_details& res_td) const { PROFILE_FUNC("wallet2::fill_transfer_details"); for (auto si : td.spent_indices) { - CHECK_AND_ASSERT_MES(si < tx.vin.size(), void(), "Internal error: wrong tx transfer details: spend index=" << si << " is greater than transaction inputs vector " << tx.vin.size()); + WLT_CHECK_AND_ASSERT_MES(si < tx.vin.size(), void(), "Internal error: wrong tx transfer details: spend index=" << si << " is greater than transaction inputs vector " << tx.vin.size()); if (tx.vin[si].type() == typeid(currency::txin_to_key)) res_td.spn.push_back(boost::get(tx.vin[si]).amount); } for (auto ri : td.receive_indices) { - CHECK_AND_ASSERT_MES(ri < tx.vout.size(), void(), "Internal error: wrong tx transfer details: reciev index=" << ri << " is greater than transaction outputs vector " << tx.vout.size()); + WLT_CHECK_AND_ASSERT_MES(ri < tx.vout.size(), void(), "Internal error: wrong tx transfer details: reciev index=" << ri << " is greater than transaction outputs vector " << tx.vout.size()); if (tx.vout[ri].target.type() == typeid(currency::txout_to_key)) res_td.rcv.push_back(tx.vout[ri].amount); } @@ -117,7 +118,7 @@ bool wallet2::get_transfer_info_by_key_image(const crypto::key_image& ki, transf //---------------------------------------------------------------------------------------------------- bool wallet2::get_transfer_info_by_index(size_t i, transfer_details& td) { - CHECK_AND_ASSERT_MES(i < m_transfers.size(), false, "wrong out in transaction: internal index, m_transfers.size()=" << m_transfers.size()); + WLT_CHECK_AND_ASSERT_MES(i < m_transfers.size(), false, "wrong out in transaction: internal index, m_transfers.size()=" << m_transfers.size()); td = m_transfers[i]; return true; } @@ -157,7 +158,7 @@ size_t wallet2::fix_collisions() { m_transfers[*it].m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT; m_transfers[*it].m_spent_height = *rsp_ki.images_stat.begin(); - LOG_PRINT_L0("Fixed collision for key image " << coll_entry.first << " transfer " << count); + WLT_LOG_L0("Fixed collision for key image " << coll_entry.first << " transfer " << count); count++; } } @@ -220,7 +221,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t is_derived_from_coinbase = true; else is_derived_from_coinbase = false; - LOG_PRINT_L0("Spent key out, transfer #" << it->second << ", amount: " << print_money(m_transfers[it->second].amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height << + WLT_LOG_L0("Spent key out, transfer #" << it->second << ", amount: " << print_money(m_transfers[it->second].amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height << "; flags: " << flags_before << " -> " << td.m_flags); mtd.spent_indices.push_back(i); remove_transfer_from_expiration_list(it->second); @@ -234,7 +235,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t { it->second.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT; it->second.m_spent_height = height; - LOG_PRINT_L0("Spent multisig out: " << multisig_id << ", amount: " << print_money(currency::get_amount_from_variant(in)) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); + WLT_LOG_L0("Spent multisig out: " << multisig_id << ", amount: " << print_money(currency::get_amount_from_variant(in)) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); mtd.spent_indices.push_back(i); } } @@ -286,7 +287,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t { THROW_IF_TRUE_WALLET_EX(it->second >= m_transfers.size(), error::wallet_internal_error, "m_key_images entry has wrong m_transfers index, it->second: " + epee::string_tools::num_to_string_fast(it->second) + ", m_transfers.size(): " + epee::string_tools::num_to_string_fast(m_transfers.size())); const transfer_details& local_td = m_transfers[it->second]; - LOG_PRINT_YELLOW("tx " << get_transaction_hash(tx) << " @ block " << height << " has output #" << o << " with key image " << ki << " that has already been seen in output #" << + WLT_LOG_YELLOW("tx " << get_transaction_hash(tx) << " @ block " << height << " has output #" << o << " with key image " << ki << " that has already been seen in output #" << local_td.m_internal_output_index << " in tx " << get_transaction_hash(local_td.m_ptx_wallet_info->m_tx) << " @ block " << local_td.m_spent_height << ". This output can't ever be spent and will be skipped.", LOG_LEVEL_0); THROW_IF_TRUE_WALLET_EX(tx_money_got_in_outs < tx.vout[o].amount, error::wallet_internal_error, "tx_money_got_in_outs: " + epee::string_tools::num_to_string_fast(tx_money_got_in_outs) + ", tx.vout[o].amount:" + print_money(tx.vout[o].amount)); @@ -315,17 +316,17 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t size_t transfer_index = m_transfers.size()-1; m_key_images[td.m_key_image] = transfer_index; add_transfer_to_transfers_cache(tx.vout[o].amount, transfer_index); - LOG_PRINT_L0("Received money, transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); + WLT_LOG_L0("Received money, transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << get_transaction_hash(tx) << ", at height " << height); } else if (tx.vout[o].target.type() == typeid(txout_multisig)) { crypto::hash multisig_id = currency::get_multisig_out_id(tx, o); - CHECK_AND_ASSERT_MES_NO_RET(m_multisig_transfers.count(multisig_id) == 0, "multisig_id = " << multisig_id << " already in multisig container"); + WLT_CHECK_AND_ASSERT_MES_NO_RET(m_multisig_transfers.count(multisig_id) == 0, "multisig_id = " << multisig_id << " already in multisig container"); transfer_details_base& tdb = m_multisig_transfers[multisig_id]; tdb.m_ptx_wallet_info = pwallet_info; tdb.m_internal_output_index = o; tdb.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_SPENT); - LOG_PRINT_L0("Received multisig, multisig out id: " << multisig_id << ", amount: " << tdb.amount() << ", with tx: " << get_transaction_hash(tx)); + WLT_LOG_L0("Received multisig, multisig out id: " << multisig_id << ", amount: " << tdb.amount() << ", with tx: " << get_transaction_hash(tx)); } } } @@ -342,7 +343,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t payment.m_block_height = height; payment.m_unlock_time = currency::get_tx_unlock_time(tx); m_payments.emplace(payment_id, payment); - LOG_PRINT_L2("Payment found, id (hex): " << epee::string_tools::buff_to_hex_nodelimer(payment_id) << ", tx: " << payment.m_tx_hash << ", amount: " << print_money_brief(payment.m_amount)); + WLT_LOG_L2("Payment found, id (hex): " << epee::string_tools::buff_to_hex_nodelimer(payment_id) << ", tx: " << payment.m_tx_hash << ", amount: " << print_money_brief(payment.m_amount)); } } @@ -357,7 +358,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t {//strange transfer, seems that in one transaction have transfers from different wallets. if (!is_coinbase(tx)) { - LOG_PRINT_RED_L0("Unusual transaction " << currency::get_transaction_hash(tx) << ", tx_money_spent_in_ins: " << tx_money_spent_in_ins << ", tx_money_got_in_outs: " << tx_money_got_in_outs); + WLT_LOG_RED("Unusual transaction " << currency::get_transaction_hash(tx) << ", tx_money_spent_in_ins: " << tx_money_spent_in_ins << ", tx_money_got_in_outs: " << tx_money_got_in_outs, LOG_LEVEL_0); } handle_money_received2(b, tx, (tx_money_got_in_outs - (tx_money_spent_in_ins - get_tx_fee(tx))), mtd); } @@ -412,17 +413,17 @@ void wallet2::resend_unconfirmed() for (auto& ut : m_unconfirmed_txs) { req.txs_as_hex.push_back(epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(ut.second.tx))); - LOG_PRINT_GREEN("Relaying tx: " << ut.second.tx_hash, LOG_LEVEL_0); + WLT_LOG_GREEN("Relaying tx: " << ut.second.tx_hash, LOG_LEVEL_0); } if (!req.txs_as_hex.size()) return; bool r = m_core_proxy->call_COMMAND_RPC_FORCE_RELAY_RAW_TXS(req, res); - CHECK_AND_ASSERT_MES(r, void(), "wrong result at call_COMMAND_RPC_FORCE_RELAY_RAW_TXS"); - CHECK_AND_ASSERT_MES(res.status == CORE_RPC_STATUS_OK, void(), "wrong result at call_COMMAND_RPC_FORCE_RELAY_RAW_TXS: status != OK, status=" << res.status); + WLT_CHECK_AND_ASSERT_MES(r, void(), "wrong result at call_COMMAND_RPC_FORCE_RELAY_RAW_TXS"); + WLT_CHECK_AND_ASSERT_MES(res.status == CORE_RPC_STATUS_OK, void(), "wrong result at call_COMMAND_RPC_FORCE_RELAY_RAW_TXS: status != OK, status=" << res.status); - LOG_PRINT_GREEN("Relayed " << req.txs_as_hex.size() << " txs", LOG_LEVEL_0); + WLT_LOG_GREEN("Relayed " << req.txs_as_hex.size() << " txs", LOG_LEVEL_0); } //----------------------------------------------------------------------------------------------------- void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_acceptance_fee, currency::transaction* p_acceptance_tx /* = nullptr */) @@ -570,7 +571,7 @@ void wallet2::accept_cancel_contract(const crypto::hash& contract_id, currency:: send_transaction_to_network(tx); TIME_MEASURE_FINISH_MS(timing3); if (timing1 + timing2 + timing1 > 500) - LOG_PRINT_RED_L0("[wallet2::accept_cancel_contract] LOW PERFORMANCE: " << timing1 << "," << timing2 << "," << timing1); + WLT_LOG_RED("[wallet2::accept_cancel_contract] LOW PERFORMANCE: " << timing1 << "," << timing2 << "," << timing1, LOG_LEVEL_0); if (p_cancellation_acceptance_tx != nullptr) *p_cancellation_acceptance_tx = tx; @@ -639,18 +640,18 @@ void wallet2::scan_tx_to_key_inputs(std::vector& found_transfers, cons } } //----------------------------------------------------------------------------------------------------- -void change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_rpc::wallet_transfer_info& wti) +void wallet2::change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_rpc::wallet_transfer_info& wti) const { - LOG_PRINT_YELLOW("escrow contract STATE CHANGE (" << (contract.is_a ? "A," : "B,") << contract_id << " via tx " << get_transaction_hash(wti.tx) << ", height: " << wti.height << ") : " + WLT_LOG_YELLOW("escrow contract STATE CHANGE (" << (contract.is_a ? "A," : "B,") << contract_id << " via tx " << get_transaction_hash(wti.tx) << ", height: " << wti.height << ") : " << wallet_rpc::get_escrow_contract_state_name(contract.state) << " -> " << wallet_rpc::get_escrow_contract_state_name(new_state), LOG_LEVEL_1); contract.state = new_state; contract.height = wti.height; // update height of last state change } //----------------------------------------------------------------------------------------------------- -void change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") +void wallet2::change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason /*= "internal intention"*/) const { - LOG_PRINT_YELLOW("escrow contract STATE CHANGE (" << (contract.is_a ? "A," : "B,") << contract_id << " " << reason << ") : " + WLT_LOG_YELLOW("escrow contract STATE CHANGE (" << (contract.is_a ? "A," : "B,") << contract_id << " " << reason << ") : " << wallet_rpc::get_escrow_contract_state_name(contract.state) << " -> " << wallet_rpc::get_escrow_contract_state_name(new_state), LOG_LEVEL_1); contract.state = new_state; @@ -694,7 +695,7 @@ bool wallet2::handle_proposal(wallet_rpc::wallet_transfer_info& wti, const bc_se THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to lookup_acc_outs for tx: " << get_transaction_hash(prop.tx_template)); add_transfers_to_expiration_list(found_transfers, ed.expiration_time, tx_money_got_in_outs, wti.tx_hash); - LOG_PRINT_GREEN("Locked " << found_transfers.size() << " transfers due to proposal " << ms_id, LOG_LEVEL_0); + WLT_LOG_GREEN("Locked " << found_transfers.size() << " transfers due to proposal " << ms_id, LOG_LEVEL_0); } @@ -705,11 +706,11 @@ bool wallet2::handle_release_contract(wallet_rpc::wallet_transfer_info& wti, con { PROFILE_FUNC("wallet2::handle_release_contract"); size_t n = get_multisig_in_index(wti.tx.vin); - CHECK_AND_ASSERT_MES(n != wti.tx.vin.size(), false, "Multisig out not found in tx template in proposal"); + WLT_CHECK_AND_ASSERT_MES(n != wti.tx.vin.size(), false, "Multisig out not found in tx template in proposal"); crypto::hash ms_id = boost::get(wti.tx.vin[n]).multisig_out_id; - CHECK_AND_ASSERT_MES(ms_id != null_hash, false, "Multisig out not found in tx template in proposal"); + WLT_CHECK_AND_ASSERT_MES(ms_id != null_hash, false, "Multisig out not found in tx template in proposal"); auto it = m_contracts.find(ms_id); - CHECK_AND_ASSERT_MES(it != m_contracts.end(), false, "Multisig out not found in tx template in proposal"); + WLT_CHECK_AND_ASSERT_MES(it != m_contracts.end(), false, "Multisig out not found in tx template in proposal"); if (release_instruction == BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_NORMAL) change_contract_state(it->second, wallet_rpc::escrow_contract_details_basic::contract_released_normal, ms_id, wti); @@ -730,7 +731,7 @@ bool wallet2::handle_release_contract(wallet_rpc::wallet_transfer_info& wti, con } else { - LOG_ERROR("wrong release_instruction: " << release_instruction); + WLT_LOG_ERROR("wrong release_instruction: " << release_instruction); return false; } @@ -787,13 +788,13 @@ bool wallet2::handle_cancel_proposal(wallet_rpc::wallet_transfer_info& wti, cons { PROFILE_FUNC("wallet2::handle_cancel_proposal"); //validate cancel proposal - CHECK_AND_ASSERT_MES(ectb.tx_cancel_template.vin.size() && ectb.tx_cancel_template.vin[0].type() == typeid(currency::txin_multisig), false, "Wrong cancel ecrow proposal"); + WLT_CHECK_AND_ASSERT_MES(ectb.tx_cancel_template.vin.size() && ectb.tx_cancel_template.vin[0].type() == typeid(currency::txin_multisig), false, "Wrong cancel ecrow proposal"); crypto::hash contract_id = boost::get(ectb.tx_cancel_template.vin[0]).multisig_out_id; auto it = m_contracts.find(contract_id); - CHECK_AND_ASSERT_MES(it != m_contracts.end(), false, "Multisig out not found in tx template in proposal"); + WLT_CHECK_AND_ASSERT_MES(it != m_contracts.end(), false, "Multisig out not found in tx template in proposal"); bool r = validate_escrow_cancel_proposal(wti, ectb, decrypted_attach, contract_id, it->second.private_detailes, it->second.proposal.tx_template); - CHECK_AND_ASSERT_MES(r, false, "failed to validate escrow cancel request, contract id: " << contract_id); + WLT_CHECK_AND_ASSERT_MES(r, false, "failed to validate escrow cancel request, contract id: " << contract_id); uint32_t contract_state = it->second.state; switch (contract_state) @@ -810,7 +811,7 @@ bool wallet2::handle_cancel_proposal(wallet_rpc::wallet_transfer_info& wti, cons wti.contract.back().contract_id = contract_id; return true; default: - LOG_PRINT_RED("handle_cancel_proposal for contract (" << (it->second.is_a ? "A," : "B,") << contract_id << " via tx " << get_transaction_hash(wti.tx) << ", height: " << wti.height << ") : " << ENDL << + WLT_LOG_RED("handle_cancel_proposal for contract (" << (it->second.is_a ? "A," : "B,") << contract_id << " via tx " << get_transaction_hash(wti.tx) << ", height: " << wti.height << ") : " << ENDL << "incorrect state " << wallet_rpc::get_escrow_contract_state_name(it->second.state) << ", while 'contract_accepted' or 'contract_cancel_proposal_sent' was expected -- decline cancel proposal", LOG_LEVEL_1); } @@ -832,7 +833,7 @@ bool wallet2::process_contract_info(wallet_rpc::wallet_transfer_info& wti, const bc_services::proposal_body prop = AUTO_VAL_INIT(prop); if (!t_unserializable_object_from_blob(prop, sa.body)) { - LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); + WLT_LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); return false; } handle_proposal(wti, prop); @@ -843,7 +844,7 @@ bool wallet2::process_contract_info(wallet_rpc::wallet_transfer_info& wti, const bc_services::contract_private_details cntr = AUTO_VAL_INIT(cntr); if (!epee::serialization::load_t_from_json(cntr, sa.body)) { - LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); + WLT_LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); return false; } handle_contract(wti, cntr, decrypted_attach); @@ -863,7 +864,7 @@ bool wallet2::process_contract_info(wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body cpb = AUTO_VAL_INIT(cpb); if (!t_unserializable_object_from_blob(cpb, sa.body)) { - LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); + WLT_LOG_ERROR("Failed to unpack attachment for tx: " << wti.tx_hash); return false; } handle_cancel_proposal(wti, cpb, decrypted_attach); @@ -983,10 +984,10 @@ void wallet2::process_new_blockchain_entry(const currency::block& b, const curre process_new_transaction(tx_entry->tx, height, b); } TIME_MEASURE_FINISH(txs_handle_time); - LOG_PRINT_L2("Processed block: " << bl_id << ", height " << height << ", " << miner_tx_handle_time + txs_handle_time << "(" << miner_tx_handle_time << "/" << txs_handle_time <<")ms"); + WLT_LOG_L2("Processed block: " << bl_id << ", height " << height << ", " << miner_tx_handle_time + txs_handle_time << "(" << miner_tx_handle_time << "/" << txs_handle_time <<")ms"); }else { - LOG_PRINT_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime()); + WLT_LOG_L2( "Skipped block by timestamp, height: " << height << ", block time " << b.timestamp << ", account time " << m_account.get_createtime()); } m_blockchain.push_back(bl_id); ++m_local_bc_height; @@ -1033,7 +1034,7 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic& stop) THROW_IF_TRUE_WALLET_EX(!r, error::no_connection_to_daemon, "getblocks.bin"); if (res.status == CORE_RPC_STATUS_GENESIS_MISMATCH) { - LOG_PRINT_MAGENTA("Reseting genesis block...", LOG_LEVEL_0); + WLT_LOG_MAGENTA("Reseting genesis block...", LOG_LEVEL_0); COMMAND_RPC_GET_BLOCKS_DETAILS::request gbd_req = AUTO_VAL_INIT(gbd_req); COMMAND_RPC_GET_BLOCKS_DETAILS::response gbd_res = AUTO_VAL_INIT(gbd_res); gbd_req.height_start = 0; @@ -1048,7 +1049,7 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic& stop) THROW_IF_TRUE_WALLET_EX(!r, error::no_connection_to_daemon, "get_blocks_details"); reset_all(); m_blockchain.push_back(new_genesis_id); - LOG_PRINT_MAGENTA("New genesis set for wallet: " << new_genesis_id, LOG_LEVEL_0); + WLT_LOG_MAGENTA("New genesis set for wallet: " << new_genesis_id, LOG_LEVEL_0); get_short_chain_history(req.block_ids); //req.block_ids.push_back(new_genesis_id); bool r = m_core_proxy->call_COMMAND_RPC_GET_BLOCKS_DIRECT(req, res); @@ -1056,7 +1057,7 @@ void wallet2::pull_blocks(size_t& blocks_added, std::atomic& stop) } if (res.status == CORE_RPC_STATUS_BUSY) { - LOG_PRINT_L1("Core is busy, pull cancelled"); + WLT_LOG_L1("Core is busy, pull cancelled"); stop = true; return; } @@ -1111,7 +1112,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop } else { - LOG_PRINT_L2("Block " << bl_id << " @ " << current_index << " is already in wallet's blockchain"); + WLT_LOG_L2("Block " << bl_id << " @ " << current_index << " is already in wallet's blockchain"); } ++current_index; @@ -1126,7 +1127,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop } } - LOG_PRINT_L1("[PULL BLOCKS] " << res.start_height << " --> " << m_blockchain.size()); + WLT_LOG_L1("[PULL BLOCKS] " << res.start_height << " --> " << m_blockchain.size()); } //---------------------------------------------------------------------------------------------------- void wallet2::refresh() @@ -1303,7 +1304,7 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) r = unconfirmed_multisig_transfers_from_tx_pool.insert(std::make_pair(multisig_id, std::make_pair(tx, td))).second; if (!r) { - LOG_PRINT_RED_L0("Warning: Receiving the same multisig out id from tx pool more then once: " << multisig_id); + WLT_LOG_RED("Warning: Receiving the same multisig out id from tx pool more then once: " << multisig_id, LOG_LEVEL_0); } if (m_unconfirmed_multisig_transfers.count(multisig_id) == 0) { @@ -1311,7 +1312,7 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) uint32_t flags_before = it->second.m_flags; it->second.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT; // mark as spent it->second.m_spent_height = 0; // height 0 means unconfirmed - LOG_PRINT_L0("From tx pool got new unconfirmed multisig out with id: " << multisig_id << " tx: " << get_transaction_hash(tx) << " Marked as SPENT, flags: " << flags_before << " -> " << it->second.m_flags); + WLT_LOG_L0("From tx pool got new unconfirmed multisig out with id: " << multisig_id << " tx: " << get_transaction_hash(tx) << " Marked as SPENT, flags: " << flags_before << " -> " << it->second.m_flags); new_multisig_spend_detected = true; } @@ -1342,7 +1343,7 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) uint64_t amount = 0; /*if (!new_multisig_spend_detected && tx_money_spent_in_ins < tx_money_got_in_outs+get_tx_fee(tx)) { - LOG_ERROR("Transaction that get more then send: tx_money_spent_in_ins=" << tx_money_spent_in_ins + WLT_LOG_ERROR("Transaction that get more then send: tx_money_spent_in_ins=" << tx_money_spent_in_ins << ", tx_money_got_in_outs=" << tx_money_got_in_outs << ", tx_id=" << tx_hash); } else*/ if (new_multisig_spend_detected) @@ -1364,12 +1365,12 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) { if (tr_index > m_transfers.size()) { - LOG_ERROR("INTERNAL ERROR: tr_index " << tr_index << " more then m_transfers.size()=" << m_transfers.size()); + WLT_LOG_ERROR("INTERNAL ERROR: tr_index " << tr_index << " more then m_transfers.size()=" << m_transfers.size()); continue; } uint32_t flags_before = m_transfers[tr_index].m_flags; m_transfers[tr_index].m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT; - LOG_PRINT_L1("wallet transfer #" << tr_index << " is marked as spent, flags: " << flags_before << " -> " << m_transfers[tr_index].m_flags << ", reason: UNCONFIRMED tx: " << tx_hash); + WLT_LOG_L1("wallet transfer #" << tr_index << " is marked as spent, flags: " << flags_before << " -> " << m_transfers[tr_index].m_flags << ", reason: UNCONFIRMED tx: " << tx_hash); unconfirmed_wti.selected_indicies.push_back(tr_index); } rise_on_transfer2(unconfirmed_wti); @@ -1405,7 +1406,7 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) // So, clear spent flag. uint32_t flags_before = it->second.m_flags; it->second.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_SPENT); - LOG_PRINT_L0("Unconfirmed multisig out with id: " << multisig_id << " was presiously marked as spent and now seems to be removed from the pool, while still not added to the blockchain. Marked as NOT SPENT" << ENDL + WLT_LOG_L0("Unconfirmed multisig out with id: " << multisig_id << " was presiously marked as spent and now seems to be removed from the pool, while still not added to the blockchain. Marked as NOT SPENT" << ENDL << "ms source tx: " << (it->second.m_ptx_wallet_info != nullptr ? get_transaction_hash(it->second.m_ptx_wallet_info->m_tx) : null_hash) << " flags: " << flags_before << " -> " << it->second.m_flags); } } @@ -1432,20 +1433,20 @@ bool wallet2::scan_unconfirmed_outdate_tx() bool tx_outdated = it->second.timestamp < time_limit; if (tx_outdated || is_tx_expired(it->second.tx, tx_expiration_ts_median)) { - LOG_PRINT_BLUE("removing unconfirmed tx " << it->second.tx_hash << ", reason: " << (tx_outdated ? "outdated" : "expired"), LOG_LEVEL_0); + WLT_LOG_BLUE("removing unconfirmed tx " << it->second.tx_hash << ", reason: " << (tx_outdated ? "outdated" : "expired"), LOG_LEVEL_0); //lookup all used transfer and update flags for (auto i : it->second.selected_indicies) { if (i >= m_transfers.size()) { - LOG_ERROR("Wrong index '" << i << "' in 'selected_indicies', while m_transfers.size() = " << m_transfers.size()); + WLT_LOG_ERROR("Wrong index '" << i << "' in 'selected_indicies', while m_transfers.size() = " << m_transfers.size()); continue; } if (!m_transfers[i].m_spent_height) { uint32_t flags_before = m_transfers[i].m_flags; m_transfers[i].m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_SPENT); - LOG_PRINT_BLUE("mark transfer #" << i << " as unspent, flags: " << flags_before << " -> " << m_transfers[i].m_flags << ", reason: removing unconfirmed tx " << it->second.tx_hash, LOG_LEVEL_0); + WLT_LOG_BLUE("mark transfer #" << i << " as unspent, flags: " << flags_before << " -> " << m_transfers[i].m_flags << ", reason: removing unconfirmed tx " << it->second.tx_hash, LOG_LEVEL_0); } } //fire some event @@ -1483,7 +1484,7 @@ bool wallet2::scan_unconfirmed_outdate_tx() { uint32_t flags_before = t.m_flags; t.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_SPENT); - LOG_PRINT_BLUE("Transfer [" << i << "] marked as unspent, flags: " << flags_before << " -> " << t.m_flags << ", reason: there is no unconfirmed tx relataed to this key image", LOG_LEVEL_0); + WLT_LOG_BLUE("Transfer [" << i << "] marked as unspent, flags: " << flags_before << " -> " << t.m_flags << ", reason: there is no unconfirmed tx relataed to this key image", LOG_LEVEL_0); } } @@ -1515,12 +1516,12 @@ void wallet2::refresh(size_t & blocks_fetched, bool& received_money, std::atomic blocks_fetched += added_blocks; if(try_count < 3) { - LOG_PRINT_L1("Another try pull_blocks (try_count=" << try_count << "), exception: " << e.what()); + WLT_LOG_L1("Another try pull_blocks (try_count=" << try_count << "), exception: " << e.what()); ++try_count; } else { - LOG_ERROR("pull_blocks failed, try_count=" << try_count << ", exception: " << e.what()); + WLT_LOG_ERROR("pull_blocks failed, try_count=" << try_count << ", exception: " << e.what()); return; //throw; } @@ -1541,7 +1542,7 @@ void wallet2::refresh(size_t & blocks_fetched, bool& received_money, std::atomic } - LOG_PRINT_L1("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money(balance()) << ", unlocked: " << print_money(unlocked_balance())); + WLT_LOG_L1("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money(balance()) << ", unlocked: " << print_money(unlocked_balance())); } //---------------------------------------------------------------------------------------------------- bool wallet2::handle_expiration_list(uint64_t tx_expiration_ts_median) @@ -1560,12 +1561,12 @@ bool wallet2::handle_expiration_list(uint64_t tx_expiration_ts_median) uint32_t flags_before = transfer.m_flags; transfer.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_BLOCKED); transfer.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION); - LOG_PRINT_GREEN("Unlocked money from expiration_list: transfer #" << tr_ind << ", flags: " << flags_before << " -> " << transfer.m_flags << ", amount: " << print_money(transfer.amount()) << ", tx: " << + WLT_LOG_GREEN("Unlocked money from expiration_list: transfer #" << tr_ind << ", flags: " << flags_before << " -> " << transfer.m_flags << ", amount: " << print_money(transfer.amount()) << ", tx: " << (transfer.m_ptx_wallet_info != nullptr ? get_transaction_hash(transfer.m_ptx_wallet_info->m_tx) : null_hash), LOG_LEVEL_0); } } - LOG_PRINT_GREEN("expiration_list entry removed by median: " << tx_expiration_ts_median << ", expiration time: " << it->expiration_time << ", related tx: " << it->related_tx_id, LOG_LEVEL_0); + WLT_LOG_GREEN("expiration_list entry removed by median: " << tx_expiration_ts_median << ", expiration time: " << it->expiration_time << ", related tx: " << it->related_tx_id, LOG_LEVEL_0); it = m_money_expirations.erase(it); } else @@ -1610,7 +1611,7 @@ bool wallet2::refresh(size_t & blocks_fetched, bool& received_money, bool& ok, s //---------------------------------------------------------------------------------------------------- void wallet2::detach_blockchain(uint64_t height) { - LOG_PRINT_L0("Detaching blockchain on height " << height); + WLT_LOG_L0("Detaching blockchain on height " << height); size_t transfers_detached = 0; { @@ -1642,7 +1643,7 @@ void wallet2::detach_blockchain(uint64_t height) { uint32_t flags_before = tr.m_flags; tr.m_flags &= ~(WALLET_TRANSFER_DETAIL_FLAG_SPENT); - LOG_PRINT_BLUE("Transfer [" << i << "] marked as unspent, flags: " << flags_before << " -> " << tr.m_flags << ", reason: blockchain detach height " << height << " is lower or equal to transfer spent height " << tr.m_spent_height, LOG_LEVEL_1); + WLT_LOG_BLUE("Transfer [" << i << "] marked as unspent, flags: " << flags_before << " -> " << tr.m_flags << ", reason: blockchain detach height " << height << " is lower or equal to transfer spent height " << tr.m_spent_height, LOG_LEVEL_1); tr.m_spent_height = 0; } } @@ -1667,7 +1668,7 @@ void wallet2::detach_blockchain(uint64_t height) ++it; } - LOG_PRINT_L0("Detached blockchain on height " << height << ", transfers detached " << transfers_detached << ", blocks detached " << blocks_detached); + WLT_LOG_L0("Detached blockchain on height " << height << ", transfers detached " << transfers_detached << ", blocks detached " << blocks_detached); } //---------------------------------------------------------------------------------------------------- bool wallet2::deinit() @@ -1708,7 +1709,7 @@ bool wallet2::store_keys(std::string& buff, const std::string& password) { std::string account_data; bool r = epee::serialization::store_t_to_binary(m_account, account_data); - CHECK_AND_ASSERT_MES(r, false, "failed to serialize wallet keys"); + WLT_CHECK_AND_ASSERT_MES(r, false, "failed to serialize wallet keys"); wallet2::keys_file_data keys_file_data = boost::value_initialized(); crypto::chacha8_key key; @@ -1728,10 +1729,10 @@ bool wallet2::backup_keys(const std::string& path) { std::string buff; bool r = store_keys(buff, m_password); - CHECK_AND_ASSERT_MES(r, false, "Failed to store keys"); + WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to store keys"); r = file_io_utils::save_string_to_file(path, buff); - CHECK_AND_ASSERT_MES(r, false, "Failed to save_string_to_file at store keys"); + WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to save_string_to_file at store keys"); return true; } //---------------------------------------------------------------------------------------------------- @@ -1777,10 +1778,11 @@ void wallet2::load_keys(const std::string& buff, const std::string& password) r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key); if (!r) { - LOG_PRINT_L0("Wrong password for wallet " << string_encoding::convert_to_ansii(m_wallet_file)); + WLT_LOG_L0("Wrong password for wallet " << string_encoding::convert_to_ansii(m_wallet_file)); tools::error::throw_wallet_ex(std::string(__FILE__ ":" STRINGIZE(__LINE__))); } - //THROW_IF_TRUE_WALLET_EX(!r, ); + + m_log_prefix = m_account.get_public_address_str().substr(0, 6); } //---------------------------------------------------------------------------------------------------- void wallet2::assign_account(const currency::account_base& acc) @@ -1848,7 +1850,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) data_file.read((char*)keys_buff.data(), wbh.m_cb_keys); load_keys(keys_buff, password); - LOG_PRINT_L0("Loaded wallet keys file, with public address: " << m_account.get_public_address_str()); + WLT_LOG_L0("Loaded wallet keys file, with public address: " << m_account.get_public_address_str()); bool r = tools::portable_unserialize_obj_from_stream(*this, data_file); @@ -1894,7 +1896,7 @@ void wallet2::store(const std::wstring& path_to_save) data_file.open(path_to_save, std::ios_base::binary | std::ios_base::out | std::ios::trunc); CHECK_AND_ASSERT_THROW_MES(!data_file.fail(), "failed to open binary wallet file for saving: " << epee::string_encoding::convert_to_ansii(m_wallet_file)); data_file << header_buff << keys_buff; - LOG_PRINT_L0("Storing to file..."); + WLT_LOG_L0("Storing to file..."); r = tools::portble_serialize_obj_to_stream(*this, data_file); CHECK_AND_ASSERT_THROW_MES(r, "failed to portble_serialize_obj_to_stream for wallet " << epee::string_encoding::convert_to_ansii(m_wallet_file)); @@ -2097,11 +2099,11 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b, const std::vector& keys_ptrs) { //generate coinbase transaction - CHECK_AND_ASSERT_MES(b.miner_tx.vin[0].type() == typeid(currency::txin_gen), false, "Wrong output input in transaction"); - CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(currency::txin_to_key), false, "Wrong output input in transaction"); + WLT_CHECK_AND_ASSERT_MES(b.miner_tx.vin[0].type() == typeid(currency::txin_gen), false, "Wrong output input in transaction"); + WLT_CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(currency::txin_to_key), false, "Wrong output input in transaction"); auto& txin = boost::get(b.miner_tx.vin[1]); txin.k_image = pos_info.keyimage; - CHECK_AND_ASSERT_MES(b.miner_tx.signatures.size() == 1 && b.miner_tx.signatures[0].size() == txin.key_offsets.size(), + WLT_CHECK_AND_ASSERT_MES(b.miner_tx.signatures.size() == 1 && b.miner_tx.signatures[0].size() == txin.key_offsets.size(), false, "Wrong signatures amount in coinbase transacton"); @@ -2112,7 +2114,7 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b, m_account.get_keys().m_view_secret_key, pos_coin_derivation); - CHECK_AND_ASSERT_MES(r, false, "internal error: pos coin base generator: failed to generate_key_derivation(" + WLT_CHECK_AND_ASSERT_MES(r, false, "internal error: pos coin base generator: failed to generate_key_derivation(" << source_tx_pub_key << ", view secret key: " << m_account.get_keys().m_view_secret_key << ")"); @@ -2132,7 +2134,7 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b, 0, &b.miner_tx.signatures[0][0]); - LOG_PRINT_L4("GENERATED RING SIGNATURE: block_id " << block_hash + WLT_LOG_L4("GENERATED RING SIGNATURE: block_id " << block_hash << "txin.k_image" << txin.k_image << "key_ptr:" << *keys_ptrs[0] << "signature:" << b.miner_tx.signatures[0][0]); @@ -2166,7 +2168,7 @@ bool wallet2::fill_mining_context(mining_context& ctx) bool r = get_pos_entries(ctx.sp); - CHECK_AND_ASSERT_MES(r, false, "Failed to get_pos_entries()"); + WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to get_pos_entries()"); currency::COMMAND_RPC_GET_POS_MINING_DETAILS::request pos_details_req = AUTO_VAL_INIT(pos_details_req); currency::COMMAND_RPC_GET_POS_MINING_DETAILS::response pos_details_resp = AUTO_VAL_INIT(pos_details_resp); @@ -2186,14 +2188,14 @@ bool wallet2::fill_mining_context(mining_context& ctx) bool wallet2::try_mint_pos() { mining_context ctx = AUTO_VAL_INIT(ctx); - LOG_PRINT_L0("Starting PoS mint iteration"); + WLT_LOG_L0("Starting PoS mint iteration"); fill_mining_context(ctx); if (!ctx.rsp.is_pos_allowed) { - LOG_PRINT_L0("POS MINING NOT ALLOWED YET"); + WLT_LOG_L0("POS MINING NOT ALLOWED YET"); return true; } - LOG_PRINT_L0("POS_ENTRIES: " << ctx.sp.pos_entries.size()); + WLT_LOG_L0("POS_ENTRIES: " << ctx.sp.pos_entries.size()); std::atomic stop(false); scan_pos(ctx, stop, [this](){ @@ -2201,7 +2203,7 @@ bool wallet2::try_mint_pos() refresh(blocks_fetched); if (blocks_fetched) { - LOG_PRINT_L0("Detected new block, minting interrupted"); + WLT_LOG_L0("Detected new block, minting interrupted"); return false; } return true; @@ -2211,7 +2213,7 @@ bool wallet2::try_mint_pos() { build_minted_block(ctx.sp, ctx.rsp); } - LOG_PRINT_L0("PoS mint iteration finished(" << ctx.rsp.status << ")"); + WLT_LOG_L0("PoS mint iteration finished(" << ctx.rsp.status << ")"); return true; } @@ -2243,7 +2245,7 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& uint64_t new_block_expected_height /* UINT64_MAX */) { //found a block, construct it, sign and push to daemon - LOG_PRINT_GREEN("Found kernel, constructing block", LOG_LEVEL_0); + WLT_LOG_GREEN("Found kernel, constructing block", LOG_LEVEL_0); CHECK_AND_NO_ASSERT_MES(rsp.index < req.pos_entries.size(), false, "call_COMMAND_RPC_SCAN_POS returned wrong index: " << rsp.index << ", expected less then " << req.pos_entries.size()); @@ -2256,27 +2258,27 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& tmpl_req.pos_index = req.pos_entries[rsp.index].index; tmpl_req.extra_text = m_miner_text_info; m_core_proxy->call_COMMAND_RPC_GETBLOCKTEMPLATE(tmpl_req, tmpl_rsp); - CHECK_AND_ASSERT_MES(tmpl_rsp.status == CORE_RPC_STATUS_OK, false, "Failed to create block template after kernel hash found!"); + WLT_CHECK_AND_ASSERT_MES(tmpl_rsp.status == CORE_RPC_STATUS_OK, false, "Failed to create block template after kernel hash found!"); currency::block b = AUTO_VAL_INIT(b); currency::blobdata block_blob; bool res = epee::string_tools::parse_hexstr_to_binbuff(tmpl_rsp.blocktemplate_blob, block_blob); - CHECK_AND_ASSERT_MES(res, false, "Failed to create block template after kernel hash found!"); + WLT_CHECK_AND_ASSERT_MES(res, false, "Failed to create block template after kernel hash found!"); res = parse_and_validate_block_from_blob(block_blob, b); - CHECK_AND_ASSERT_MES(res, false, "Failed to create block template after kernel hash found!"); + WLT_CHECK_AND_ASSERT_MES(res, false, "Failed to create block template after kernel hash found!"); if (rsp.last_block_hash != b.prev_id) { - LOG_PRINT_YELLOW("Kernel was found but block is behindhand, b.prev_id=" << b.prev_id << ", last_block_hash=" << rsp.last_block_hash, LOG_LEVEL_0); + WLT_LOG_YELLOW("Kernel was found but block is behindhand, b.prev_id=" << b.prev_id << ", last_block_hash=" << rsp.last_block_hash, LOG_LEVEL_0); return false; } std::vector keys_ptrs; - CHECK_AND_ASSERT_MES(req.pos_entries[rsp.index].wallet_index < m_transfers.size(), + WLT_CHECK_AND_ASSERT_MES(req.pos_entries[rsp.index].wallet_index < m_transfers.size(), false, "Wrong wallet_index at generating coinbase transacton"); const auto& target = m_transfers[req.pos_entries[rsp.index].wallet_index].m_ptx_wallet_info->m_tx.vout[m_transfers[req.pos_entries[rsp.index].wallet_index].m_internal_output_index].target; - CHECK_AND_ASSERT_MES(target.type() == typeid(currency::txout_to_key), false, "wrong type_id in source transaction in coinbase tx"); + WLT_CHECK_AND_ASSERT_MES(target.type() == typeid(currency::txout_to_key), false, "wrong type_id in source transaction in coinbase tx"); const currency::txout_to_key& txtokey = boost::get(target); keys_ptrs.push_back(&txtokey.key); @@ -2286,7 +2288,7 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& currency::etc_tx_time tt = AUTO_VAL_INIT(tt); tt.v = m_core_runtime_config.get_core_time(); b.miner_tx.extra.push_back(tt); - LOG_PRINT_MAGENTA("Applying actual timestamp: " << epee::misc_utils::get_time_str(tt.v), LOG_LEVEL_0); + WLT_LOG_MAGENTA("Applying actual timestamp: " << epee::misc_utils::get_time_str(tt.v), LOG_LEVEL_0); //sign block res = prepare_and_sign_pos_block(b, @@ -2294,9 +2296,9 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& get_tx_pub_key_from_extra(m_transfers[req.pos_entries[rsp.index].wallet_index].m_ptx_wallet_info->m_tx), m_transfers[req.pos_entries[rsp.index].wallet_index].m_internal_output_index, keys_ptrs); - CHECK_AND_ASSERT_MES(res, false, "Failed to prepare_and_sign_pos_block"); + WLT_CHECK_AND_ASSERT_MES(res, false, "Failed to prepare_and_sign_pos_block"); - LOG_PRINT_GREEN("Block constructed <" << get_block_hash(b) << ">, sending to core...", LOG_LEVEL_0); + WLT_LOG_GREEN("Block constructed <" << get_block_hash(b) << ">, sending to core...", LOG_LEVEL_0); currency::COMMAND_RPC_SUBMITBLOCK::request subm_req = AUTO_VAL_INIT(subm_req); currency::COMMAND_RPC_SUBMITBLOCK::response subm_rsp = AUTO_VAL_INIT(subm_rsp); @@ -2304,17 +2306,17 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& m_core_proxy->call_COMMAND_RPC_SUBMITBLOCK(subm_req, subm_rsp); if (subm_rsp.status != CORE_RPC_STATUS_OK) { - LOG_ERROR("Constructed block is not accepted by core, status: " << subm_rsp.status); + WLT_LOG_ERROR("Constructed block is not accepted by core, status: " << subm_rsp.status); return false; } - LOG_PRINT_GREEN("POS block generated and accepted, congrats!", LOG_LEVEL_0); + WLT_LOG_GREEN("POS block generated and accepted, congrats!", LOG_LEVEL_0); m_wcallback->on_pos_block_found(b); //@#@ //double check timestamp if (time(NULL) - get_actual_timestamp(b) > 5) { - LOG_PRINT_RED_L0("Found block (" << get_block_hash(b) << ") timestamp (" << get_actual_timestamp(b) - << ") is suspiciously less (" << time(NULL) - get_actual_timestamp(b) << ") then curren time( " << time(NULL) << ")"); + WLT_LOG_RED("Found block (" << get_block_hash(b) << ") timestamp (" << get_actual_timestamp(b) + << ") is suspiciously less (" << time(NULL) - get_actual_timestamp(b) << ") then curren time( " << time(NULL) << ")", LOG_LEVEL_0); } // return true; @@ -2355,7 +2357,7 @@ namespace template T pop_random_value(std::vector& vec) { - CHECK_AND_ASSERT_MES(!vec.empty(), T(), "Vector must be non-empty"); + WLT_CHECK_AND_ASSERT_MES(!vec.empty(), T(), "Vector must be non-empty"); size_t idx = crypto::rand() % vec.size(); T res = vec[idx]; @@ -2476,7 +2478,7 @@ void wallet2::request_alias_update(currency::extra_alias_entry& ai, currency::tr } bool r = currency::sign_extra_alias_entry(ai, m_account.get_keys().m_account_address.m_spend_public_key, m_account.get_keys().m_spend_secret_key); CHECK_AND_ASSERT_THROW_MES(r, "Failed to sign alias update"); - LOG_PRINT_L2("Generated upodate alias info: " << ENDL + WLT_LOG_L2("Generated upodate alias info: " << ENDL << "alias: " << ai.m_alias << ENDL << "signature: " << currency::print_t_array(ai.m_sign) << ENDL << "signed(owner) pub key: " << m_account.get_keys().m_account_address.m_spend_public_key << ENDL @@ -2516,7 +2518,7 @@ bool wallet2::check_available_sources(std::list& amounts) } - LOG_PRINT_MAGENTA("[CHECK_AVAILABLE_SOURCES]: " << amounts << " res: " << res << ENDL <<" holds: " << holds, LOG_LEVEL_0); + WLT_LOG_MAGENTA("[CHECK_AVAILABLE_SOURCES]: " << amounts << " res: " << res << ENDL <<" holds: " << holds, LOG_LEVEL_0); return res; } //---------------------------------------------------------------------------------------------------- @@ -2809,7 +2811,7 @@ void wallet2::add_transfers_to_expiration_list(const std::vector& sele << std::setw(2) << std::left << flags_before << " -> " << std::setw(2) << std::left << m_transfers[tr_ind].m_flags << " " << get_transaction_hash(m_transfers[tr_ind].m_ptx_wallet_info->m_tx) << std::endl; } - LOG_PRINT_GREEN(m_money_expirations.back().selected_transfers.size() << " transfer(s) added to expiration list:" << ENDL << + WLT_LOG_GREEN(m_money_expirations.back().selected_transfers.size() << " transfer(s) added to expiration list:" << ENDL << "index amount flags tx hash" << ENDL << ss.str() << "change_amount: " << print_money_brief(change_amount) << ", expire(s) at: " << expiration, LOG_LEVEL_0); @@ -2824,7 +2826,7 @@ void wallet2::remove_transfer_from_expiration_list(uint64_t transfer_index) auto jt = std::find(st.begin(), st.end(), transfer_index); if (jt != st.end()) { - LOG_PRINT_GREEN("Transfer [" << transfer_index << "], amount: " << print_money(m_transfers[transfer_index].amount()) << ", tx: " << get_transaction_hash(m_transfers[transfer_index].m_ptx_wallet_info->m_tx) << + WLT_LOG_GREEN("Transfer [" << transfer_index << "], amount: " << print_money(m_transfers[transfer_index].amount()) << ", tx: " << get_transaction_hash(m_transfers[transfer_index].m_ptx_wallet_info->m_tx) << " was removed from the expiration list", LOG_LEVEL_0); st.erase(jt); if (st.empty()) @@ -2839,7 +2841,7 @@ void wallet2::remove_transfer_from_expiration_list(uint64_t transfer_index) uint32_t flags_before = m_transfers[transfer_index].m_flags; m_transfers[transfer_index].m_flags &= ~WALLET_TRANSFER_DETAIL_FLAG_BLOCKED; m_transfers[transfer_index].m_flags &= ~WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION; - LOG_PRINT_BLUE("Transfer [" << transfer_index << "] was cleared from escrow proposal reservation, flags: " << flags_before << " -> " << m_transfers[transfer_index].m_flags << ", reason: intentional removing from expiration list", LOG_LEVEL_0); + WLT_LOG_BLUE("Transfer [" << transfer_index << "] was cleared from escrow proposal reservation, flags: " << flags_before << " -> " << m_transfers[transfer_index].m_flags << ", reason: intentional removing from expiration list", LOG_LEVEL_0); // (don't change m_spent flag, because transfer status is unclear - the caller should take care of it) } @@ -3010,7 +3012,7 @@ bool wallet2::prepare_tx_sources(uint64_t needed_money, size_t fake_outputs_coun src.real_out_tx_key = get_tx_pub_key_from_extra(td.m_ptx_wallet_info->m_tx); src.real_output = interted_it - src.outputs.begin(); src.real_output_in_tx_index = td.m_internal_output_index; - detail::print_source_entry(src); + print_source_entry(src); ++i; } return true; @@ -3066,7 +3068,7 @@ void wallet2::send_transaction_to_network(const transaction& tx) THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status == CORE_RPC_STATUS_DISCONNECTED, error::wallet_internal_error, "Transfer attempt while daemon offline"); THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status != CORE_RPC_STATUS_OK, error::tx_rejected, tx, daemon_send_resp.status); - LOG_PRINT_L2("transaction " << get_transaction_hash(tx) << " generated ok and sent to daemon:" << ENDL << currency::obj_to_json_str(tx)); + WLT_LOG_L2("transaction " << get_transaction_hash(tx) << " generated ok and sent to daemon:" << ENDL << currency::obj_to_json_str(tx)); } void wallet2::add_sent_tx_detailed_info(const transaction& tx, @@ -3099,7 +3101,7 @@ void wallet2::mark_transfers_with_flag(const std::vector& selected_tra THROW_IF_TRUE_WALLET_EX(i >= m_transfers.size(), error::wallet_internal_error, "i >= m_transfers.size()"); uint32_t flags_before = m_transfers[i].m_flags; m_transfers[i].m_flags |= flag; - LOG_PRINT_L1("marking transfer #" << std::setfill('0') << std::right << std::setw(3) << i << " with flag " << flag << " : " << flags_before << " -> " << m_transfers[i].m_flags << + WLT_LOG_L1("marking transfer #" << std::setfill('0') << std::right << std::setw(3) << i << " with flag " << flag << " : " << flags_before << " -> " << m_transfers[i].m_flags << (reason.empty() ? "" : ", reason: ") << reason); } } @@ -3111,7 +3113,7 @@ void wallet2::clear_transfers_from_flag(const std::vector& selected_tr THROW_IF_TRUE_WALLET_EX(i >= m_transfers.size(), error::wallet_internal_error, "i >= m_transfers.size()"); uint32_t flags_before = m_transfers[i].m_flags; m_transfers[i].m_flags &= ~flag; - LOG_PRINT_L1("clearing transfer #" << std::setfill('0') << std::right << std::setw(3) << i << " from flag " << flag << " : " << flags_before << " -> " << m_transfers[i].m_flags << + WLT_LOG_L1("clearing transfer #" << std::setfill('0') << std::right << std::setw(3) << i << " from flag " << flag << " : " << flags_before << " -> " << m_transfers[i].m_flags << (reason.empty() ? "" : ", reason: ") << reason); } } @@ -3136,7 +3138,7 @@ bool wallet2::extract_offers_from_transfer_entry(size_t i, std::unordered_map& offers //---------------------------------------------------------------------------------------------------- uint64_t wallet2::select_indices_for_transfer(std::vector& selected_indexes, free_amounts_cache_type& found_free_amounts, uint64_t needed_money, uint64_t fake_outputs_count) { - LOG_PRINT_GREEN("Selecting indices for transfer found_free_amounts.size()=" << found_free_amounts.size() << "...", LOG_LEVEL_0); + WLT_LOG_GREEN("Selecting indices for transfer found_free_amounts.size()=" << found_free_amounts.size() << "...", LOG_LEVEL_0); uint64_t found_money = 0; while(found_money < needed_money && found_free_amounts.size()) { @@ -3259,20 +3261,20 @@ uint64_t wallet2::select_indices_for_transfer(std::vector& selected_in if (!(it != found_free_amounts.end() && it->second.size())) { it = --found_free_amounts.end(); - CHECK_AND_ASSERT_MES(it->second.size(), 0, "internal error: empty found_free_amounts map"); + WLT_CHECK_AND_ASSERT_MES(it->second.size(), 0, "internal error: empty found_free_amounts map"); } if (is_transfer_ready_to_go(m_transfers[*it->second.begin()], fake_outputs_count)) { found_money += it->first; selected_indexes.push_back(*it->second.begin()); - LOG_PRINT_L2("Selected index: " << *it->second.begin() << ", transfer_details: " << ENDL << epee::serialization::store_t_to_json(m_transfers[*it->second.begin()])); + WLT_LOG_L2("Selected index: " << *it->second.begin() << ", transfer_details: " << ENDL << epee::serialization::store_t_to_json(m_transfers[*it->second.begin()])); } it->second.erase(it->second.begin()); if (!it->second.size()) found_free_amounts.erase(it); } - LOG_PRINT_GREEN("Selected " << print_money(found_money) << " coins, found_free_amounts.size()=" << found_free_amounts.size(), LOG_LEVEL_0); + WLT_LOG_GREEN("Selected " << print_money(found_money) << " coins, found_free_amounts.size()=" << found_free_amounts.size(), LOG_LEVEL_0); return found_money; } //---------------------------------------------------------------------------------------------------- @@ -3297,7 +3299,7 @@ bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_o //---------------------------------------------------------------------------------------------------- bool wallet2::prepare_free_transfers_cache(uint64_t fake_outputs_count) { - LOG_PRINT_L2("Preparing transfers_cache..."); + WLT_LOG_L2("Preparing transfers_cache..."); uint64_t count = 0; if (!m_found_free_amounts.size() || fake_outputs_count != m_fake_outputs_count) { @@ -3314,7 +3316,7 @@ bool wallet2::prepare_free_transfers_cache(uint64_t fake_outputs_count) m_fake_outputs_count = fake_outputs_count; } - LOG_PRINT_L2("Transfers_cache prepared. " << count << " items cached for " << m_found_free_amounts.size() << " amounts"); + WLT_LOG_L2("Transfers_cache prepared. " << count << " items cached for " << m_found_free_amounts.size() << " amounts"); return true; } //---------------------------------------------------------------------------------------------------- @@ -3396,7 +3398,7 @@ std::string wallet2::get_alias_for_address(const std::string& addr) currency::COMMAND_RPC_GET_ALIASES_BY_ADDRESS::response res = AUTO_VAL_INIT(res); if (!m_core_proxy->call_COMMAND_RPC_GET_ALIASES_BY_ADDRESS(req, res)) { - LOG_PRINT_L0("Failed to COMMAND_RPC_GET_ALIASES_BY_ADDRESS"); + WLT_LOG_L0("Failed to COMMAND_RPC_GET_ALIASES_BY_ADDRESS"); return ""; } return res.alias_info.alias; @@ -3424,7 +3426,7 @@ bool wallet2::is_connected_to_net() currency::COMMAND_RPC_GET_INFO::response res = AUTO_VAL_INIT(res); if (!m_core_proxy->call_COMMAND_RPC_GET_INFO(req, res)) { - LOG_PRINT_L0("Failed to COMMAND_RPC_GET_INFO"); + WLT_LOG_L0("Failed to COMMAND_RPC_GET_INFO"); return false; } return (res.synchronized_connections_count) ? true : false; @@ -3439,7 +3441,7 @@ void wallet2::process_genesis_if_needed(const currency::block& genesis) crypto::hash genesis_hash = get_block_hash(genesis); if (m_blockchain.size() == 1 && m_blockchain[0] != genesis_hash) - LOG_PRINT("Changing genesis block for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash, LOG_LEVEL_0); + WLT_LOG_L0("Changing genesis block for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash); m_blockchain.clear(); @@ -3447,14 +3449,14 @@ void wallet2::process_genesis_if_needed(const currency::block& genesis) m_local_bc_height = 1; m_last_bc_timestamp = genesis.timestamp; - LOG_PRINT_L2("Processing genesis block: " << genesis_hash); + WLT_LOG_L2("Processing genesis block: " << genesis_hash); process_new_transaction(genesis.miner_tx, 0, genesis); } void wallet2::set_genesis(const crypto::hash& genesis_hash) { THROW_IF_TRUE_WALLET_EX(m_blockchain.size() != 1, error::wallet_internal_error, "Can't change wallet genesis hash once the blockchain has been populated"); - LOG_PRINT("Changing genesis hash for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash, LOG_LEVEL_0); + WLT_LOG_L0("Changing genesis hash for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash); m_blockchain[0] = genesis_hash; } //---------------------------------------------------------------------------------------------------- @@ -3463,7 +3465,7 @@ void wallet2::print_tx_sent_message(const currency::transaction& tx, const std:: //uint64_t balance_unlocked = 0; //uint64_t balance_total = balance(balance_unlocked); - LOG_PRINT_CYAN("Transaction " << get_transaction_hash(tx) << " was successfully sent " << description << ENDL + WLT_LOG_CYAN("Transaction " << get_transaction_hash(tx) << " was successfully sent " << description << ENDL << "Commission: " << std::setw(21) << std::right << print_money(fee) << ENDL // << "Balance: " << std::setw(21) << print_money(balance_total) << ENDL // << "Unlocked: " << std::setw(21) << print_money(balance_unlocked) << ENDL @@ -3479,12 +3481,19 @@ uint64_t wallet2::get_tx_expiration_median() const if (res.status != CORE_RPC_STATUS_OK) { - LOG_ERROR("COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN failed, status: " << res.status); + WLT_LOG_ERROR("COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN failed, status: " << res.status); return 0; } return res.expiration_median; } //---------------------------------------------------------------------------------------------------- +void wallet2::print_source_entry(const currency::tx_source_entry& src) const +{ + std::ostringstream indexes; + std::for_each(src.outputs.begin(), src.outputs.end(), [&](const currency::tx_source_entry::output_entry& s_e) { indexes << s_e.first << " "; }); + WLT_LOG_L0("amount=" << currency::print_money(src.amount) << ", real_output=" << src.real_output << ", real_output_in_tx_index=" << src.real_output_in_tx_index << ", indexes: " << indexes.str()); +} +//---------------------------------------------------------------------------------------------------- } // namespace tools diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 66440855..927015a5 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -46,6 +46,22 @@ #define LOG_DEFAULT_CHANNEL "wallet" ENABLE_CHANNEL_BY_DEFAULT("wallet"); +// wallet-specific logging functions +#define WLT_LOG_L0(msg) LOG_PRINT_L0("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_L1(msg) LOG_PRINT_L1("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_L2(msg) LOG_PRINT_L2("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_L3(msg) LOG_PRINT_L3("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_L4(msg) LOG_PRINT_L4("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_ERROR(msg) LOG_ERROR("[W:" << m_log_prefix << "]" << msg) +#define WLT_LOG_BLUE(msg, log_level) LOG_PRINT_BLUE("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_LOG_CYAN(msg, log_level) LOG_PRINT_CYAN("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_LOG_GREEN(msg, log_level) LOG_PRINT_GREEN("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_LOG_MAGENTA(msg, log_level) LOG_PRINT_MAGENTA("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_LOG_RED(msg, log_level) LOG_PRINT_RED("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_LOG_YELLOW(msg, log_level) LOG_PRINT_YELLOW("[W:" << m_log_prefix << "]" << msg, log_level) +#define WLT_CHECK_AND_ASSERT_MES(expr, ret, msg) CHECK_AND_ASSERT_MES(expr, ret, "[W:" << m_log_prefix << "]" << msg) +#define WLT_CHECK_AND_ASSERT_MES_NO_RET(expr, msg) CHECK_AND_ASSERT_MES_NO_RET(expr, "[W:" << m_log_prefix << "]" << msg) + namespace tools { #pragma pack(push, 1) @@ -114,7 +130,8 @@ namespace tools m_height_of_start_sync(0), m_last_sync_percent(0), m_fake_outputs_count(0), - m_do_rise_transfer(false) + m_do_rise_transfer(false), + m_log_prefix("???") { m_core_runtime_config = currency::get_default_core_runtime_config(); }; @@ -550,6 +567,10 @@ private: bool handle_expiration_list(uint64_t tx_expiration_ts_median); void handle_contract_expirations(uint64_t tx_expiration_ts_median); + void change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_rpc::wallet_transfer_info& wti) const; + void change_contract_state(wallet_rpc::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const; + + uint64_t get_tx_expiration_median() const; void print_tx_sent_message(const currency::transaction& tx, const std::string& description, uint64_t fee); @@ -558,13 +579,23 @@ private: bool validate_escrow_proposal(const wallet_rpc::wallet_transfer_info& wti, const bc_services::proposal_body& prop, std::vector& decrypted_items, crypto::hash& ms_id, bc_services::contract_private_details& cpd); + bool validate_escrow_release(const currency::transaction& tx, bool release_type_normal, const bc_services::contract_private_details& cpd, + const currency::txout_multisig& source_ms_out, const crypto::hash& ms_id, size_t source_ms_out_index, const currency::transaction& source_tx, const currency::account_keys& a_keys) const; + bool validate_escrow_contract(const wallet_rpc::wallet_transfer_info& wti, const bc_services::contract_private_details& cpd, bool is_a, const std::vector& decrypted_items, crypto::hash& ms_id, bc_services::escrow_relese_templates_body& rtb); + bool validate_escrow_cancel_release(const currency::transaction& tx, const wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, + const std::vector& decrypted_items, crypto::hash& ms_id, bc_services::contract_private_details& cpd, const currency::transaction& source_tx, + size_t source_ms_out_index, const currency::account_keys& b_keys, uint64_t minimum_release_fee) const; + bool validate_escrow_cancel_proposal(const wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector& decrypted_items, crypto::hash& ms_id, bc_services::contract_private_details& cpd, const currency::transaction& proposal_template_tx); + void fill_transfer_details(const currency::transaction& tx, const tools::money_transfer2_details& td, tools::wallet_rpc::wallet_transfer_info_details& res_td) const; + void print_source_entry(const currency::tx_source_entry& src) const; + struct construct_tx_param { std::vector dsts; @@ -610,6 +641,7 @@ private: currency::account_base m_account; + std::string m_log_prefix; // part of pub address, prefix for logging functions std::wstring m_wallet_file; std::string m_password; std::vector m_blockchain; @@ -864,13 +896,6 @@ namespace tools splitted_dsts.push_back(change_dst); } //---------------------------------------------------------------------------------------------------- - inline void print_source_entry(const currency::tx_source_entry& src) - { - std::ostringstream indexes; - std::for_each(src.outputs.begin(), src.outputs.end(), [&](const currency::tx_source_entry::output_entry& s_e) { indexes << s_e.first << " "; }); - LOG_PRINT_L0("amount=" << currency::print_money(src.amount) << ", real_output=" < @@ -907,7 +932,7 @@ namespace tools #ifdef _DEBUG if (final_detinations.size() > 10) { - LOG_PRINT_L0("final_detinations.size()=" << final_detinations.size()); + WLT_LOG_L0("final_detinations.size()=" << final_detinations.size()); } #endif //@#@ @@ -1000,7 +1025,7 @@ namespace tools TIME_MEASURE_FINISH_MS(sign_ms_input_time); THROW_IF_TRUE_WALLET_EX(CURRENCY_MAX_TRANSACTION_BLOB_SIZE <= get_object_blobsize(tx), error::tx_too_big, tx, m_upper_transaction_size_limit); - LOG_PRINT_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms" + WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms" << ", prepare_tx_sources_time: " << prepare_tx_sources_time << " ms" << ", prepare_tx_destinations_time: " << prepare_tx_destinations_time << " ms" << ", construct_tx_time: " << construct_tx_time << " ms" @@ -1090,7 +1115,7 @@ namespace tools add_sent_tx_detailed_info(tx, prepared_destinations, selected_transfers); TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); - LOG_PRINT_GREEN("[wallet::transfer] prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3) + WLT_LOG_GREEN("[wallet::transfer] prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3) << ", precalculation_time: " << print_fixed_decimal_point(precalculation_time, 3) << ", send_transaction_to_network_time: " << print_fixed_decimal_point(send_transaction_to_network_time, 3) << ", mark_transfers_as_spent_time: " << print_fixed_decimal_point(mark_transfers_as_spent_time, 3) @@ -1204,6 +1229,24 @@ namespace tools } +#if !defined(KEEP_WALLET_LOG_MACROS) +#undef WLT_LOG_L0 +#undef WLT_LOG_L1 +#undef WLT_LOG_L2 +#undef WLT_LOG_L3 +#undef WLT_LOG_L4 +#undef WLT_LOG_ERROR +#undef WLT_LOG_BLUE +#undef WLT_LOG_CYAN +#undef WLT_LOG_GREEN +#undef WLT_LOG_MAGENTA +#undef WLT_LOG_RED +#undef WLT_LOG_YELLOW +#undef WLT_CHECK_AND_ASSERT_MES +#undef WLT_CHECK_AND_ASSERT_MES_NO_RET +#endif + + #undef LOG_DEFAULT_CHANNEL #define LOG_DEFAULT_CHANNEL "wallet" ENABLE_CHANNEL_BY_DEFAULT("wallet"); diff --git a/src/wallet/wallet2_escrow.cpp b/src/wallet/wallet2_escrow.cpp index abfd8f48..d50d8f87 100644 --- a/src/wallet/wallet2_escrow.cpp +++ b/src/wallet/wallet2_escrow.cpp @@ -4,6 +4,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#define KEEP_WALLET_LOG_MACROS #include "wallet2.h" #include "currency_core/currency_format_utils.h" @@ -21,7 +22,7 @@ bool wallet2::validate_escrow_proposal(const wallet_rpc::wallet_transfer_info& w bc_services::contract_private_details& cpd /* OUT */ ) { -#define LOC_CHK(cond, mes) CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow proposal: " << mes << ". tx: " << get_transaction_hash(wti.tx)); +#define LOC_CHK(cond, mes) WLT_CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow proposal: " << mes << ". tx: " << get_transaction_hash(wti.tx)); // I. validate escrow proposal tx const transaction& escrow_proposal_tx = wti.tx; @@ -123,10 +124,10 @@ bool wallet2::validate_escrow_proposal(const wallet_rpc::wallet_transfer_info& w // bool wallet2::handle_proposal(const currency::transaction& escrow_proposal_tx, wallet_rpc::wallet_transfer_info& wti, const bc_services::proposal_body& prop) //---------------------------------------------------------------------------------------------------- -bool validate_escrow_release(const transaction& tx, bool release_type_normal, const bc_services::contract_private_details& cpd, - const txout_multisig& source_ms_out, const crypto::hash& ms_id, size_t source_ms_out_index, const transaction& source_tx, const currency::account_keys& a_keys) +bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_normal, const bc_services::contract_private_details& cpd, + const txout_multisig& source_ms_out, const crypto::hash& ms_id, size_t source_ms_out_index, const transaction& source_tx, const currency::account_keys& a_keys) const { -#define LOC_CHK(cond, mes) CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow " << (release_type_normal ? "normal" : "burn") << " release template: " << mes); +#define LOC_CHK(cond, mes) WLT_CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow " << (release_type_normal ? "normal" : "burn") << " release template: " << mes); // (1/5) inputs LOC_CHK(tx.vin.size() == 1, "vin size expected to be 1, actual is " << tx.vin.size()); @@ -246,7 +247,7 @@ bool wallet2::validate_escrow_contract(const wallet_rpc::wallet_transfer_info& w crypto::hash& ms_id, /* OUT */ bc_services::escrow_relese_templates_body& rtb /* OUT */) { -#define LOC_CHK(cond, mes) CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow contract: " << mes << ". Escrow party: " << (is_a ? "A" : "B") << ". tx: " << get_transaction_hash(wti.tx)); +#define LOC_CHK(cond, mes) WLT_CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow contract: " << mes << ". Escrow party: " << (is_a ? "A" : "B") << ". tx: " << get_transaction_hash(wti.tx)); bool r = false; // TODO: validate A-part of transaction? @@ -294,7 +295,7 @@ uint64_t wallet2::get_minimum_allowed_fee_for_contract(const crypto::hash& ms_id auto it = m_multisig_transfers.find(ms_id); if (it == m_multisig_transfers.end()) { - LOG_ERROR("get_minimum_allowed_fee_for_contract called with unknown id: " << ms_id << ", assuming TX_MINIMUM_FEE=" << TX_MINIMUM_FEE); + WLT_LOG_ERROR("get_minimum_allowed_fee_for_contract called with unknown id: " << ms_id << ", assuming TX_MINIMUM_FEE=" << TX_MINIMUM_FEE); return TX_MINIMUM_FEE; } uint64_t tx_fee = get_tx_fee(it->second.m_ptx_wallet_info->m_tx); @@ -304,11 +305,11 @@ uint64_t wallet2::get_minimum_allowed_fee_for_contract(const crypto::hash& ms_id // TODO move here: // bool wallet2::handle_contract() //---------------------------------------------------------------------------------------------------- -bool validate_escrow_cancel_release(const currency::transaction& tx, const wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, +bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, const wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector& decrypted_items, crypto::hash& ms_id, bc_services::contract_private_details& cpd, const currency::transaction& source_tx, - size_t source_ms_out_index, const currency::account_keys& b_keys, uint64_t minimum_release_fee) + size_t source_ms_out_index, const currency::account_keys& b_keys, uint64_t minimum_release_fee) const { -#define LOC_CHK(cond, mes) CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow cancel release template: " << mes); +#define LOC_CHK(cond, mes) WLT_CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow cancel release template: " << mes); // (1/5) inputs LOC_CHK(tx.vin.size() == 1, "vin size expected to be 1, actual is " << tx.vin.size()); @@ -402,7 +403,7 @@ bool validate_escrow_cancel_release(const currency::transaction& tx, const walle bool wallet2::validate_escrow_cancel_proposal(const wallet_rpc::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector& decrypted_items, crypto::hash& ms_id, bc_services::contract_private_details& cpd, const currency::transaction& proposal_template_tx) { -#define LOC_CHK(cond, mes) CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow cancellation request: " << mes << ". ms id: " << ms_id << ", tx: " << get_transaction_hash(wti.tx)); +#define LOC_CHK(cond, mes) WLT_CHECK_AND_ASSERT_MES(cond, false, "Invalid escrow cancellation request: " << mes << ". ms id: " << ms_id << ", tx: " << get_transaction_hash(wti.tx)); const transaction& cancellation_request_tx = wti.tx; From 7eb6a38d234071303383df240dd4c094c7ac6801 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 21 Feb 2019 23:01:52 +0300 Subject: [PATCH 14/14] wallet2: getting rid of redundant code + compilation fix --- src/wallet/wallet2.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 29e2fe23..7c210431 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2352,25 +2352,6 @@ bool wallet2::is_transfer_unlocked(const transfer_details& td) const return true; } //---------------------------------------------------------------------------------------------------- -namespace -{ - template - T pop_random_value(std::vector& vec) - { - WLT_CHECK_AND_ASSERT_MES(!vec.empty(), T(), "Vector must be non-empty"); - - size_t idx = crypto::rand() % vec.size(); - T res = vec[idx]; - if (idx + 1 != vec.size()) - { - vec[idx] = vec.back(); - } - vec.resize(vec.size() - 1); - - return res; - } -} -//---------------------------------------------------------------------------------------------------- void wallet2::push_offer(const bc_services::offer_details_ex& od, currency::transaction& res_tx) { currency::tx_destination_entry tx_dest;