From d9939ce2faeb4aae2ae99e4e82e9af1dcedee8e9 Mon Sep 17 00:00:00 2001 From: Denis Smirnov Date: Mon, 25 May 2020 03:39:54 +0700 Subject: [PATCH 01/14] fix typo in pick_preferred_rct_inputs --- src/wallet/wallet2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 9ede4c9cd..427f24553 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -9032,7 +9032,7 @@ std::vector wallet2::pick_preferred_rct_inputs(uint64_t needed_money, ui MDEBUG("Ignoring output " << j << " of amount " << print_money(td2.amount()) << " which is outside prescribed range [" << print_money(m_ignore_outputs_below) << ", " << print_money(m_ignore_outputs_above) << "]"); continue; } - if (!is_spent(td2, false) && !td2.m_frozen && !td.m_key_image_partial && td2.is_rct() && td.amount() + td2.amount() >= needed_money && is_transfer_unlocked(td2) && td2.m_subaddr_index == td.m_subaddr_index) + if (!is_spent(td2, false) && !td2.m_frozen && !td2.m_key_image_partial && td2.is_rct() && td.amount() + td2.amount() >= needed_money && is_transfer_unlocked(td2) && td2.m_subaddr_index == td.m_subaddr_index) { // update our picks if those outputs are less related than any we // already found. If the same, don't update, and oldest suitable outputs From 5df0ffb57caf27521dbe976e3c10a3e8a637fe96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Colas?= Date: Wed, 27 May 2020 14:57:05 +0200 Subject: [PATCH 02/14] Fix incorrect lenght of command INS_PREFIX_HASH buffer_send[4] (LC) is an unsigned char, len should not exceed 254 (255 - 1 for the option). --- src/device/device_ledger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index 0173b6ef7..b91388b51 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -1468,8 +1468,8 @@ namespace hw { offset = set_command_header(INS_PREFIX_HASH,2,cnt); len = pref_length - pref_offset; //options - if (len > (BUFFER_SEND_SIZE-7)) { - len = BUFFER_SEND_SIZE-7; + if (len > (BUFFER_SEND_SIZE-offset-3)) { + len = BUFFER_SEND_SIZE-offset-3; this->buffer_send[offset] = 0x80; } else { this->buffer_send[offset] = 0x00; From e592a515dbccbb8aec84238df2c2c3ae2cd0a34e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 28 Apr 2020 14:05:41 +0000 Subject: [PATCH 03/14] rpc: don't display invalid json errors on default log level It's not something the user needs to know, and will display attacker controlled data --- contrib/epee/src/mlog.cpp | 2 +- src/rpc/core_rpc_server.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index e96bf627f..bcde215be 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -100,7 +100,7 @@ static const char *get_default_categories(int level) switch (level) { case 0: - categories = "*:WARNING,net:FATAL,net.http:FATAL,net.ssl:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,serialization:FATAL,daemon.rpc.payment:ERROR,stacktrace:INFO,logging:INFO,msgwriter:INFO"; + categories = "*:WARNING,net:FATAL,net.http:FATAL,net.ssl:FATAL,net.p2p:FATAL,net.cn:FATAL,daemon.rpc:FATAL,global:INFO,verify:FATAL,serialization:FATAL,daemon.rpc.payment:ERROR,stacktrace:INFO,logging:INFO,msgwriter:INFO"; break; case 1: categories = "*:INFO,global:INFO,stacktrace:INFO,logging:INFO,msgwriter:INFO,perf.*:DEBUG"; diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 83ae1e0f0..730d9ebd8 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -270,25 +270,25 @@ namespace cryptonote { if (!m_restricted && nettype() != FAKECHAIN) { - MERROR("RPC payment enabled, but server is not restricted, anyone can adjust their balance to bypass payment"); + MFATAL("RPC payment enabled, but server is not restricted, anyone can adjust their balance to bypass payment"); return false; } cryptonote::address_parse_info info; if (!get_account_address_from_str(info, nettype(), address)) { - MERROR("Invalid payment address: " << address); + MFATAL("Invalid payment address: " << address); return false; } if (info.is_subaddress) { - MERROR("Payment address may not be a subaddress: " << address); + MFATAL("Payment address may not be a subaddress: " << address); return false; } uint64_t diff = command_line::get_arg(vm, arg_rpc_payment_difficulty); uint64_t credits = command_line::get_arg(vm, arg_rpc_payment_credits); if (diff == 0 || credits == 0) { - MERROR("Payments difficulty and/or payments credits are 0, but a payment address was given"); + MFATAL("Payments difficulty and/or payments credits are 0, but a payment address was given"); return false; } m_rpc_payment_allow_free_loopback = command_line::get_arg(vm, arg_rpc_payment_allow_free_loopback); @@ -308,7 +308,7 @@ namespace cryptonote if (!set_bootstrap_daemon(command_line::get_arg(vm, arg_bootstrap_daemon_address), command_line::get_arg(vm, arg_bootstrap_daemon_login))) { - MERROR("Failed to parse bootstrap daemon address"); + MFATAL("Failed to parse bootstrap daemon address"); return false; } From 6c652ef1ad028391703f2a206b383556732bdfc2 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 24 May 2020 20:17:03 +0000 Subject: [PATCH 04/14] daemon: remove time based "update needed" status string --- src/daemon/rpc_command_executor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index f8108e343..734b235c4 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -511,7 +511,7 @@ bool t_rpc_command_executor::show_status() { } std::stringstream str; - str << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections") + str << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %u(out)+%u(in) connections") % (unsigned long long)ires.height % (unsigned long long)net_height % get_sync_percentage(ires) @@ -521,7 +521,6 @@ bool t_rpc_command_executor::show_status() { % get_mining_speed(cryptonote::difficulty_type(ires.wide_difficulty) / ires.target) % (unsigned)hfres.version % get_fork_extra_info(hfres.earliest_height, net_height, ires.target) - % (hfres.state == cryptonote::HardFork::Ready ? "up to date" : hfres.state == cryptonote::HardFork::UpdateNeeded ? "update needed" : "out of date, likely forked") % (unsigned)ires.outgoing_connections_count % (unsigned)ires.incoming_connections_count ; From da1720ec3092e6bac059071131438c2629b28e38 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 28 May 2020 11:32:47 +0000 Subject: [PATCH 05/14] rpc: fix relay_tx error return mixup --- 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 730d9ebd8..fad579b0d 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -2817,7 +2817,7 @@ namespace cryptonote crypto::hash txid = *reinterpret_cast(txid_data.data()); cryptonote::blobdata txblob; - if (!m_core.get_pool_transaction(txid, txblob, relay_category::legacy)) + if (m_core.get_pool_transaction(txid, txblob, relay_category::legacy)) { NOTIFY_NEW_TRANSACTIONS::request r; r.txs.push_back(std::move(txblob)); From fd83d71bc7d9eb3eae5e82cbd2217be2f3ee1568 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 28 May 2020 12:48:38 +0000 Subject: [PATCH 06/14] functional_tests: add simple relay_tx test --- tests/functional_tests/txpool.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/functional_tests/txpool.py b/tests/functional_tests/txpool.py index 27ae89764..9b64ef994 100755 --- a/tests/functional_tests/txpool.py +++ b/tests/functional_tests/txpool.py @@ -241,6 +241,17 @@ class TransferTest(): assert x.fee == txes[txid].fee assert x.tx_blob == txes[txid].tx_blob + print('Checking relaying txes') + res = daemon.get_transaction_pool_hashes() + assert len(res.tx_hashes) > 0 + txid = res.tx_hashes[0] + daemon.relay_tx([txid]) + res = daemon.get_transactions([txid]) + assert len(res.txs) == 1 + assert res.txs[0].tx_hash == txid + assert res.txs[0].in_pool + assert res.txs[0].relayed + daemon.flush_txpool() self.check_empty_pool() From eb49cb728ea4300996451e0251176093f88225a9 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 22 May 2020 22:01:50 +0000 Subject: [PATCH 07/14] rpc: fix comparison of seconds vs microseconds --- src/rpc/rpc_payment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rpc_payment.cpp b/src/rpc/rpc_payment.cpp index 1d0d1aa8d..b2353a29d 100644 --- a/src/rpc/rpc_payment.cpp +++ b/src/rpc/rpc_payment.cpp @@ -366,7 +366,7 @@ namespace cryptonote for (std::unordered_map::iterator i = m_client_info.begin(); i != m_client_info.end(); ) { std::unordered_map::iterator j = i++; - const time_t t = std::max(j->second.last_request_timestamp, j->second.update_time); + const time_t t = std::max(j->second.last_request_timestamp / 1000000, j->second.update_time); const bool erase = t < ((j->second.credits == 0) ? threshold0 : threshold); if (erase) { From c573ee65f6ddcb4aeea90531f9c5271fadefedf8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 5 Jun 2020 11:20:38 +0000 Subject: [PATCH 08/14] rpc: fix loading rpc payment data from file Got broken after making one of those micro optimizations requested on review.. --- src/rpc/rpc_payment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/rpc_payment.cpp b/src/rpc/rpc_payment.cpp index b2353a29d..b09594351 100644 --- a/src/rpc/rpc_payment.cpp +++ b/src/rpc/rpc_payment.cpp @@ -290,7 +290,7 @@ namespace cryptonote TRY_ENTRY(); boost::lock_guard lock(mutex); m_directory = std::move(directory); - std::string state_file_path = directory + "/" + RPC_PAYMENTS_DATA_FILENAME; + std::string state_file_path = m_directory + "/" + RPC_PAYMENTS_DATA_FILENAME; MINFO("loading rpc payments data from " << state_file_path); std::ifstream data; data.open(state_file_path, std::ios_base::binary | std::ios_base::in); From b3847bc194d0c2e7a4859044fcf904df89f548e5 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 5 Jun 2020 15:26:39 +0000 Subject: [PATCH 09/14] blockchain: fix total_height in getblocks.bin response --- src/cryptonote_core/blockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 830d45259..bb2f5262d 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2609,6 +2609,7 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons } db_rtxn_guard rtxn_guard(m_db); + total_height = get_current_blockchain_height(); blocks.reserve(std::min(std::min(max_count, (size_t)10000), (size_t)(total_height - start_height))); CHECK_AND_ASSERT_MES(m_db->get_blocks_from(start_height, 3, max_count, FIND_BLOCKCHAIN_SUPPLEMENT_MAX_SIZE, blocks, pruned, true, get_miner_tx_hash), false, "Error getting blocks"); From 4be84b7753739253eed9032fe25ba6fa1219cbe7 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Fri, 12 Jun 2020 22:42:17 -0400 Subject: [PATCH 10/14] Fix D++ block template check --- src/cryptonote_core/tx_pool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 0d69d67c8..1661669d7 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -1351,7 +1351,7 @@ namespace cryptonote for (; sorted_it != m_txs_by_fee_and_receive_time.end(); ++sorted_it) { txpool_tx_meta_t meta; - if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta) && !meta.matches(relay_category::legacy)) + if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta) || !meta.matches(relay_category::legacy)) { MERROR(" failed to find tx meta"); continue; From 72655f78fc461126ee249f5d27c421af92f7ea11 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 13 Jun 2020 14:20:20 +0000 Subject: [PATCH 11/14] blockchain: fix timestamp/difficulty cache getting out of sync The cache is discarded when a block is popped, but then gets rebuilt when the difficulty for next block is requested. While this is all properly locked, it does not take into account the delay caused by a database transaction being only committed (and thus its effects made visible to other threads) later on, which means another thread could request difficulty between the pop and the commit, which would end up using stale database view to build the cache, but that cache would not be invalidated again when the transaction gets committed, which would cause the cache to not match the new database data. To fix this, we now keep track of when the cache is invalidated so we can invalidate it again upon database transaction commit to ensure it gets calculated again with fresh data next time it is nedeed. --- src/cryptonote_core/blockchain.cpp | 17 ++++++++++++++++- src/cryptonote_core/blockchain.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index bb2f5262d..ef9856daa 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -86,7 +86,7 @@ DISABLE_VS_WARNINGS(4267) //------------------------------------------------------------------ Blockchain::Blockchain(tx_memory_pool& tx_pool) : - m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_weight_limit(0), m_current_block_cumul_weight_median(0), + m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_reset_timestamps_and_difficulties_height(true), m_current_block_cumul_weight_limit(0), m_current_block_cumul_weight_median(0), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_sync_on_blocks(true), m_db_sync_threshold(1), m_db_sync_mode(db_async), m_db_default_sync(false), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0), m_bytes_to_sync(0), m_cancel(false), m_long_term_block_weights_window(CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE), m_long_term_effective_median_block_weight(0), @@ -427,6 +427,7 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline if (num_popped_blocks > 0) { m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; m_hardfork->reorganize_from_chain_height(get_current_blockchain_height()); uint64_t top_block_height; crypto::hash top_block_hash = get_tail_id(top_block_height); @@ -567,6 +568,7 @@ block Blockchain::pop_block_from_blockchain() CRITICAL_REGION_LOCAL(m_blockchain_lock); m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; block popped_block; std::vector popped_txs; @@ -644,6 +646,7 @@ bool Blockchain::reset_and_set_genesis_block(const block& b) LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; invalidate_block_template_cache(); m_db->reset(); m_db->drop_alt_blocks(); @@ -860,6 +863,8 @@ start: // pop the oldest one from the list. This only requires 1x read per height instead // of doing 735 (DIFFICULTY_BLOCKS_COUNT). bool check = false; + if (m_reset_timestamps_and_difficulties_height) + m_timestamps_and_difficulties_height = 0; if (m_timestamps_and_difficulties_height != 0 && ((height - m_timestamps_and_difficulties_height) == 1) && m_timestamps.size() >= difficulty_blocks_count) { uint64_t index = height - 1; @@ -1006,6 +1011,7 @@ bool Blockchain::rollback_blockchain_switching(std::list& original_chain, } m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; // remove blocks from blockchain until we get back to where we should be. while (m_db->height() != rollback_height) @@ -1042,6 +1048,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list CRITICAL_REGION_LOCAL(m_blockchain_lock); m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; // if empty alt chain passed (not sure how that could happen), return false CHECK_AND_ASSERT_MES(alt_chain.size(), false, "switch_to_alternative_blockchain: empty chain passed"); @@ -1755,6 +1762,7 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = true; uint64_t block_height = get_block_height(b); if(0 == block_height) { @@ -4454,7 +4462,14 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync) try { if (m_batch_success) + { m_db->batch_stop(); + if (m_reset_timestamps_and_difficulties_height) + { + m_timestamps_and_difficulties_height = 0; + m_reset_timestamps_and_difficulties_height = false; + } + } else m_db->batch_abort(); success = true; diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 3a89cc5df..82051ecd4 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -1067,6 +1067,7 @@ namespace cryptonote std::vector m_timestamps; std::vector m_difficulties; uint64_t m_timestamps_and_difficulties_height; + bool m_reset_timestamps_and_difficulties_height; uint64_t m_long_term_block_weights_window; uint64_t m_long_term_effective_median_block_weight; mutable crypto::hash m_long_term_block_weights_cache_tip_hash; From 6da460a8df9254c77ee93ec64dacb4890bc21a2e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 20 Jun 2020 15:32:45 +0000 Subject: [PATCH 12/14] tx_pool: mine stem txes in fake chain mode This fixes the functional tests, since txes would not be mined after being sent to the daemon (they'd be waiting for the dandelion timeout first) --- src/cryptonote_core/cryptonote_core.cpp | 2 +- src/cryptonote_core/tx_pool.cpp | 14 ++++++++++---- src/cryptonote_core/tx_pool.h | 4 +++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index f4c51078b..fdf5c31a6 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -650,7 +650,7 @@ namespace cryptonote r = m_blockchain_storage.init(db.release(), m_nettype, m_offline, regtest ? ®test_test_options : test_options, fixed_difficulty, get_checkpoints); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage"); - r = m_mempool.init(max_txpool_weight); + r = m_mempool.init(max_txpool_weight, m_nettype == FAKECHAIN); CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool"); // now that we have a valid m_blockchain_storage, we can clean out any diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 1661669d7..99e7d7dba 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -116,7 +116,7 @@ namespace cryptonote } //--------------------------------------------------------------------------------- //--------------------------------------------------------------------------------- - tx_memory_pool::tx_memory_pool(Blockchain& bchs): m_blockchain(bchs), m_txpool_max_weight(DEFAULT_TXPOOL_MAX_WEIGHT), m_txpool_weight(0), m_cookie(0) + tx_memory_pool::tx_memory_pool(Blockchain& bchs): m_blockchain(bchs), m_cookie(0), m_txpool_max_weight(DEFAULT_TXPOOL_MAX_WEIGHT), m_txpool_weight(0), m_mine_stem_txes(false) { } @@ -1351,13 +1351,18 @@ namespace cryptonote for (; sorted_it != m_txs_by_fee_and_receive_time.end(); ++sorted_it) { txpool_tx_meta_t meta; - if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta) || !meta.matches(relay_category::legacy)) + if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta)) { MERROR(" failed to find tx meta"); continue; } - LOG_PRINT_L2("Considering " << sorted_it->second << ", weight " << meta.weight << ", current block weight " << total_weight << "/" << max_total_weight << ", current coinbase " << print_money(best_coinbase)); + LOG_PRINT_L2("Considering " << sorted_it->second << ", weight " << meta.weight << ", current block weight " << total_weight << "/" << max_total_weight << ", current coinbase " << print_money(best_coinbase) << ", relay method " << (unsigned)meta.get_relay_method()); + if (!meta.matches(relay_category::legacy) && !(m_mine_stem_txes && meta.get_relay_method() == relay_method::stem)) + { + LOG_PRINT_L2(" tx relay method is " << (unsigned)meta.get_relay_method()); + continue; + } if (meta.pruned) { LOG_PRINT_L2(" tx is pruned"); @@ -1522,7 +1527,7 @@ namespace cryptonote return n_removed; } //--------------------------------------------------------------------------------- - bool tx_memory_pool::init(size_t max_txpool_weight) + bool tx_memory_pool::init(size_t max_txpool_weight, bool mine_stem_txes) { CRITICAL_REGION_LOCAL(m_transactions_lock); CRITICAL_REGION_LOCAL1(m_blockchain); @@ -1578,6 +1583,7 @@ namespace cryptonote lock.commit(); } + m_mine_stem_txes = mine_stem_txes; m_cookie = 0; // Ignore deserialization error diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h index 292d427e2..18ef0340b 100644 --- a/src/cryptonote_core/tx_pool.h +++ b/src/cryptonote_core/tx_pool.h @@ -205,10 +205,11 @@ namespace cryptonote * @brief loads pool state (if any) from disk, and initializes pool * * @param max_txpool_weight the max weight in bytes + * @param mine_stem_txes whether to mine txes in stem relay mode * * @return true */ - bool init(size_t max_txpool_weight = 0); + bool init(size_t max_txpool_weight = 0, bool mine_stem_txes = false); /** * @brief attempts to save the transaction pool state to disk @@ -603,6 +604,7 @@ private: size_t m_txpool_max_weight; size_t m_txpool_weight; + bool m_mine_stem_txes; mutable std::unordered_map> m_input_cache; From ae60c289f91b4f698530f45447bc3fb294979760 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 23 Apr 2020 14:39:54 +0000 Subject: [PATCH 13/14] epee: fix array underflow in unicode parsing Reported by minerscan Also independently found by OSS-Fuzz just recently --- contrib/epee/include/storages/parserse_base_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/epee/include/storages/parserse_base_utils.h b/contrib/epee/include/storages/parserse_base_utils.h index 2256f6b83..5a6cc0b51 100644 --- a/contrib/epee/include/storages/parserse_base_utils.h +++ b/contrib/epee/include/storages/parserse_base_utils.h @@ -196,7 +196,7 @@ namespace misc_utils uint32_t dst = 0; for (int i = 0; i < 4; ++i) { - const unsigned char tmp = isx[(int)*++it]; + const unsigned char tmp = isx[(unsigned char)*++it]; CHECK_AND_ASSERT_THROW_MES(tmp != 0xff, "Bad Unicode encoding"); dst = dst << 4 | tmp; } From b5b14634878457f6e7733dc1a09b0ad837dde8d2 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Sun, 21 Jun 2020 23:17:58 +0200 Subject: [PATCH 14/14] add trezor support to sweep_single --- src/simplewallet/simplewallet.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index f63b2e83a..9cbe6dcde 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -7384,6 +7384,32 @@ bool simple_wallet::sweep_single(const std::vector &args_) success_msg_writer(true) << tr("Unsigned transaction(s) successfully written to file: ") << "multisig_wownero_tx"; } } + else if (m_wallet->get_account().get_device().has_tx_cold_sign()) + { + try + { + tools::wallet2::signed_tx_set signed_tx; + std::vector dsts_info; + dsts_info.push_back(info); + + if (!cold_sign_tx(ptx_vector, signed_tx, dsts_info, [&](const tools::wallet2::signed_tx_set &tx){ return accept_loaded_tx(tx); })){ + fail_msg_writer() << tr("Failed to cold sign transaction with HW wallet"); + return true; + } + + commit_or_save(signed_tx.ptx, m_do_not_relay); + success_msg_writer(true) << tr("Money successfully sent, transaction: ") << get_transaction_hash(ptx_vector[0].tx); + } + catch (const std::exception& e) + { + handle_transfer_exception(std::current_exception(), m_wallet->is_trusted_daemon()); + } + catch (...) + { + LOG_ERROR("Unknown error"); + fail_msg_writer() << tr("unknown error"); + } + } else if (m_wallet->watch_only()) { bool r = m_wallet->save_tx(ptx_vector, "unsigned_wownero_tx");