general: replace auto_scope_leave_caller with scope_guard

And replace unused inclusions of misc_language.h
This commit is contained in:
jeffro256
2026-07-15 19:54:58 -05:00
parent d9d83b0d27
commit edea8505db
57 changed files with 128 additions and 205 deletions
+1
View File
@@ -43,6 +43,7 @@
#include "common/pruning.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "crypto/crypto.h"
#include "misc_language.h"
#include "profile_tools.h"
#include "ringct/rctOps.h"
@@ -35,6 +35,7 @@
#include "common/pruning.h"
#include "cryptonote_core/cryptonote_core.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "scope_guard.h"
#include "version.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -169,7 +170,7 @@ static uint32_t get_blockchain_db_version(MDB_env *env)
MDB_val v;
uint32_t db_version = std::numeric_limits<uint32_t>::max();
const epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard txn_dtor([&](){
if (tx_active) mdb_txn_abort(txn);
});
@@ -209,7 +210,7 @@ static void copy_table(MDB_env *env0, MDB_env *env1, const char *table, unsigned
MINFO("Copying " << table);
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard txn_dtor([&](){
if (tx_active1) mdb_txn_abort(txn1);
if (tx_active0) mdb_txn_abort(txn0);
});
@@ -304,7 +305,7 @@ static void prune(MDB_env *env0, MDB_env *env1)
MGINFO("Creating pruned txs_prunable");
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard txn_dtor([&](){
if (tx_active1) mdb_txn_abort(txn1);
if (tx_active0) mdb_txn_abort(txn0);
});
+5 -6
View File
@@ -27,17 +27,17 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "common/dns_utils.h"
#include "common/threadpool.h"
#include "crypto/crypto.h"
// check local first (in the event of static or in-source compilation of libunbound)
#include "misc_language.h"
#include "misc_log_ex.h"
#include "scope_guard.h"
#include "unbound.h"
#include <deque>
#include <set>
#include <stdlib.h>
#include <cstring>
#include "include_base_utils.h"
#include "common/threadpool.h"
#include "crypto/crypto.h"
#include <boost/thread/mutex.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/optional.hpp>
@@ -271,8 +271,7 @@ std::vector<std::string> DNSResolver::get_record(const std::string& url, int rec
ub_result *result;
// Make sure we are cleaning after result.
epee::misc_utils::auto_scope_leave_caller scope_exit_handler =
epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard scope_exit_handler([&](){
ub_resolve_free(result);
});
-1
View File
@@ -46,7 +46,6 @@
#include "cryptonote_config.h"
#include "crypto/crypto.h"
#include "crypto/hash.h"
#include "misc_language.h"
#include "ringct/rctTypes.h"
#include "device/device.hpp"
#include "cryptonote_basic/fwd.h"
@@ -28,15 +28,11 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include "include_base_utils.h"
using namespace epee;
#include "cryptonote_basic_impl.h"
#include "string_tools.h"
#include "serialization/binary_utils.h"
#include "cryptonote_format_utils.h"
#include "cryptonote_config.h"
#include "misc_language.h"
#include "common/base58.h"
#include "crypto/hash.h"
#include "int-util.h"
@@ -45,6 +41,8 @@ using namespace epee;
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "cn"
using namespace epee;
namespace cryptonote {
struct integrated_address {
@@ -266,7 +266,7 @@ namespace cryptonote
//---------------------------------------------------------------
bool generate_key_image_helper(const account_keys& ack, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, const crypto::public_key& out_key, const crypto::public_key& tx_public_key, const std::vector<crypto::public_key>& additional_tx_public_keys, size_t real_output_index, keypair& in_ephemeral, crypto::key_image& ki, hw::device &hwdev)
{
crypto::key_derivation recv_derivation = AUTO_VAL_INIT(recv_derivation);
crypto::key_derivation recv_derivation{};
bool r = hwdev.generate_key_derivation(tx_public_key, ack.m_view_secret_key, recv_derivation);
if (!r)
{
@@ -277,7 +277,7 @@ namespace cryptonote
std::vector<crypto::key_derivation> additional_recv_derivations;
for (size_t i = 0; i < additional_tx_public_keys.size(); ++i)
{
crypto::key_derivation additional_recv_derivation = AUTO_VAL_INIT(additional_recv_derivation);
crypto::key_derivation additional_recv_derivation{};
r = hwdev.generate_key_derivation(additional_tx_public_keys[i], ack.m_view_secret_key, additional_recv_derivation);
if (!r)
{
-1
View File
@@ -35,7 +35,6 @@
#include "syncobj.h"
#include "cryptonote_basic_impl.h"
#include "cryptonote_format_utils.h"
#include "cryptonote_core/cryptonote_tx_utils.h"
#include "file_io_utils.h"
#include "common/command_line.h"
#include "common/util.h"
+5 -8
View File
@@ -35,28 +35,25 @@
#include <boost/range/adaptor/reversed.hpp>
#include <boost/format.hpp>
#include "include_base_utils.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "tx_pool.h"
#include "blockchain.h"
#include "blockchain_db/blockchain_db.h"
#include "cryptonote_basic/events.h"
#include "cryptonote_config.h"
#include "cryptonote_basic/miner.h"
#include "hardforks/hardforks.h"
#include "misc_language.h"
#include "profile_tools.h"
#include "file_io_utils.h"
#include "int-util.h"
#include "common/threadpool.h"
#include "warnings.h"
#include "crypto/hash.h"
#include "cryptonote_core.h"
#include "ringct/rctSigs.h"
#include "common/perf_timer.h"
#include "common/notify.h"
#include "common/varint.h"
#include "common/pruning.h"
#include "scope_guard.h"
#include "time_helper.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -1539,7 +1536,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
seed_hash = crypto::null_hash;
m_tx_pool.lock();
const auto unlock_guard = epee::misc_utils::create_scope_leave_handler([&]() { m_tx_pool.unlock(); });
const epee::scope_guard unlock_guard([&]() { m_tx_pool.unlock(); });
CRITICAL_REGION_LOCAL(m_blockchain_lock);
if (m_btc_valid && !from_block) {
// The pool cookie is atomic. The lack of locking is OK, as if it changes
@@ -4394,7 +4391,7 @@ leave:
bool Blockchain::prune_blockchain(uint32_t pruning_seed)
{
m_tx_pool.lock();
epee::misc_utils::auto_scope_leave_caller unlocker = epee::misc_utils::create_scope_leave_handler([&](){m_tx_pool.unlock();});
const epee::scope_guard unlocker([&](){m_tx_pool.unlock();});
CRITICAL_REGION_LOCAL(m_blockchain_lock);
return m_db->prune_blockchain(pruning_seed);
@@ -4403,7 +4400,7 @@ bool Blockchain::prune_blockchain(uint32_t pruning_seed)
bool Blockchain::update_blockchain_pruning()
{
m_tx_pool.lock();
epee::misc_utils::auto_scope_leave_caller unlocker = epee::misc_utils::create_scope_leave_handler([&](){m_tx_pool.unlock();});
const epee::scope_guard unlocker([&](){m_tx_pool.unlock();});
CRITICAL_REGION_LOCAL(m_blockchain_lock);
return m_db->update_pruning();
@@ -4412,7 +4409,7 @@ bool Blockchain::update_blockchain_pruning()
bool Blockchain::check_blockchain_pruning()
{
m_tx_pool.lock();
epee::misc_utils::auto_scope_leave_caller unlocker = epee::misc_utils::create_scope_leave_handler([&](){m_tx_pool.unlock();});
const epee::scope_guard unlocker([&](){m_tx_pool.unlock();});
CRITICAL_REGION_LOCAL(m_blockchain_lock);
return m_db->check_pruning();
+2 -5
View File
@@ -32,6 +32,7 @@
#include <boost/uuid/nil_generator.hpp>
#include "misc_log_ex.h"
#include "scope_guard.h"
#include "string_tools.h"
using namespace epee;
@@ -40,20 +41,16 @@ using namespace epee;
#include "common/util.h"
#include "common/updates.h"
#include "common/download.h"
#include "common/threadpool.h"
#include "common/command_line.h"
#include "cryptonote_basic/events.h"
#include "warnings.h"
#include "crypto/crypto.h"
#include "cryptonote_config.h"
#include "misc_language.h"
#include "file_io_utils.h"
#include <csignal>
#include "checkpoints/checkpoints.h"
#include "ringct/rctTypes.h"
#include "blockchain_db/blockchain_db.h"
#include "ringct/rctSigs.h"
#include "rpc/zmq_pub.h"
#include "common/notify.h"
#include "hardforks/hardforks.h"
#include "tx_verification_utils.h"
@@ -1468,7 +1465,7 @@ namespace cryptonote
// Match each call to prepare_handle_incoming_block_no_preprocess() with a call to
// cleanup_handle_incoming_blocks()
m_blockchain_storage.prepare_handle_incoming_block_no_preprocess(block_total_bytes);
const auto auto_cleanup = epee::misc_utils::create_scope_leave_handler([this](){
const epee::scope_guard auto_cleanup([this](){
this->m_blockchain_storage.cleanup_handle_incoming_blocks();
});
+3 -3
View File
@@ -30,8 +30,6 @@
#include <optional>
#include <unordered_set>
#include <random>
#include "include_base_utils.h"
#include "misc_log_ex.h"
#include "string_tools.h"
using namespace epee;
@@ -45,7 +43,9 @@ using namespace epee;
#include "crypto/crypto.h"
#include "crypto/hash.h"
#include "crypto/wire.h"
#include "misc_language.h"
#include "ringct/rctSigs.h"
#include "scope_guard.h"
#include "serialization/wire.h"
using namespace crypto;
@@ -668,7 +668,7 @@ namespace cryptonote
{
hw::device &hwdev = sender_account_keys.get_device();
hwdev.open_tx(tx_key);
const auto auto_close_tx = epee::misc_utils::create_scope_leave_handler([&hwdev](){
const epee::scope_guard auto_close_tx([&hwdev](){
hwdev.close_tx();
});
{
+1 -1
View File
@@ -79,7 +79,7 @@ namespace cryptonote
bool is_subaddress;
bool is_integrated;
tx_destination_entry() : amount(0), addr(AUTO_VAL_INIT(addr)), is_subaddress(false), is_integrated(false) { }
tx_destination_entry() : amount(0), addr(), is_subaddress(false), is_integrated(false) { }
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress) : amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false) { }
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false) { }
+3 -1
View File
@@ -32,7 +32,9 @@
#include <unordered_map>
#include <boost/uuid/nil_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_hash.hpp>
#include "string_tools.h"
#include "cryptonote_config.h"
#include "cryptonote_protocol_defs.h"
#include "common/pruning.h"
#include "block_queue.h"
@@ -488,7 +490,7 @@ bool block_queue::has_spans(const boost::uuids::uuid &connection_id) const
float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
{
boost::unique_lock<boost::recursive_mutex> lock(mutex);
std::unordered_map<boost::uuids::uuid, float, boost::hash<boost::uuids::uuid>> speeds;
std::unordered_map<boost::uuids::uuid, float> speeds;
for (const auto &span: blocks)
{
if (span.blocks.empty())
@@ -30,10 +30,12 @@
#pragma once
#include <list>
#include "serialization/keyvalue_serialization.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "crypto/hash.h"
#include "cryptonote_basic/blobdatatype.h"
#include "misc_language.h"
#include "serialization/keyvalue_serialization.h"
#include <list>
namespace cryptonote
{
@@ -30,27 +30,18 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <vector>
#include <memory>
#include "syncobj.h"
#include "net/net_utils_base.h"
#include "misc_log_ex.h"
#include <boost/chrono.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp>
#include "misc_language.h"
#include <algorithm>
#include "cryptonote_protocol_handler.h"
#include "net/network_throttle.hpp"
#include "cryptonote_core/cryptonote_core.h" // e.g. for the send_stop_signal()
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.cn"
@@ -644,7 +644,7 @@ namespace cryptonote
// validating the next block. Needs more research into if this is a DoS vector or not. Invalid
// block validation will cause disconnects and bans, so it might not be that bad.
m_core.pause_mine();
const auto resume_mine_on_leave = epee::misc_utils::create_scope_leave_handler([this](){ m_core.resume_mine(); });
const epee::scope_guard resume_mine_on_leave([this](){ m_core.resume_mine(); });
// This set allows us to quickly sanity check that the block binds all txs contained in this
// fluffy payload, which means that no extra stowaway txs can be harbored. In the case of a
@@ -1362,7 +1362,7 @@ namespace cryptonote
m_core.pause_mine();
m_add_timer.resume();
bool starting = true;
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([this, &starting]() {
const epee::scope_guard scope_exit_handler([this, &starting]() {
m_add_timer.pause();
m_core.resume_mine();
if (!starting)
+1 -1
View File
@@ -242,7 +242,7 @@ bool t_daemon::run(bool interactive)
if (shutdown)
this->stop_p2p();
});
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard scope_exit_handler([&](){
stop = true;
stop_thread.join();
});
+2 -3
View File
@@ -5,8 +5,8 @@
//
#include "daemonizer/posix_fork.h"
#include "misc_language.h"
#include "misc_log_ex.h"
#include "scope_guard.h"
#include <cerrno>
#include <cstdlib>
@@ -50,8 +50,7 @@ void fork(const std::string & pidfile)
pid_fd = -1;
}
};
epee::misc_utils::auto_scope_leave_caller pid_fd_guard =
epee::misc_utils::create_scope_leave_handler(close_pid_fd);
const epee::scope_guard pid_fd_guard(std::forward<decltype(close_pid_fd) const &&>(close_pid_fd));
if (! pidfile.empty ())
{
struct stat st;
+1 -1
View File
@@ -180,7 +180,7 @@ namespace trezor {
bool device_trezor::get_public_address_with_no_passphrase(cryptonote::account_public_address &pubkey) {
m_reply_with_empty_passphrase = true;
const auto empty_passphrase_reverter = epee::misc_utils::create_scope_leave_handler([&]() {
const epee::scope_guard empty_passphrase_reverter([&]() {
m_reply_with_empty_passphrase = false;
});
+3 -3
View File
@@ -370,7 +370,7 @@ namespace trezor {
{
require_connected();
auto initMsg = std::make_shared<messages::management::Initialize>();
const auto data_cleaner = epee::misc_utils::create_scope_leave_handler([&]() {
const epee::scope_guard data_cleaner([&]() {
if (initMsg->has_session_id())
memwipe(&(*initMsg->mutable_session_id())[0], initMsg->mutable_session_id()->size());
});
@@ -459,7 +459,7 @@ namespace trezor {
m.set_allocated_pin(new std::string(pin->data(), pin->size()));
}
const auto data_cleaner = epee::misc_utils::create_scope_leave_handler([&]() {
const epee::scope_guard data_cleaner([&]() {
if (m.has_pin())
memwipe(&(*m.mutable_pin())[0], m.mutable_pin()->size());
});
@@ -503,7 +503,7 @@ namespace trezor {
}
}
const auto data_cleaner = epee::misc_utils::create_scope_leave_handler([&]() {
const epee::scope_guard data_cleaner([&]() {
if (m.has_passphrase())
memwipe(&(*m.mutable_passphrase())[0], m.mutable_passphrase()->size());
});
+2 -1
View File
@@ -39,6 +39,7 @@
#include <typeinfo>
#include <type_traits>
#include "net/http_client.h"
#include "scope_guard.h"
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
@@ -86,7 +87,7 @@ namespace trezor {
additional_params.push_back(std::make_pair("Content-Type","application/json; charset=utf-8"));
const http::http_response_info* pri = nullptr;
const auto data_cleaner = epee::misc_utils::create_scope_leave_handler([&]() {
const epee::scope_guard data_cleaner([&]() {
if (!req_param.empty()) {
memwipe(&req_param[0], req_param.size());
}
+3 -2
View File
@@ -40,8 +40,8 @@
#include <cstdint>
#include <vector>
#include <unordered_map>
#include "scope_guard.h"
#include "wipeable_string.h"
#include "misc_language.h"
#include "int-util.h"
#include "mnemonics/electrum-words.h"
#include <boost/crc.hpp>
@@ -291,7 +291,8 @@ namespace crypto
}
std::vector<uint32_t> matched_indices;
auto wiper = epee::misc_utils::create_scope_leave_handler([&](){memwipe(matched_indices.data(), matched_indices.size() * sizeof(matched_indices[0]));});
const epee::scope_guard wiper([&](){
memwipe(matched_indices.data(), matched_indices.size() * sizeof(matched_indices[0]));});
Language::Base *language;
if (!find_seed_language(seed, has_checksum, matched_indices, &language))
{
+1 -4
View File
@@ -272,10 +272,7 @@ namespace multisig
// note: must be mul8 (cofactor), otherwise it is possible to leak to a malicious participant if the local
// base_privkey is a multiple of 8 or not
// note2: avoid making temporaries that won't be memwiped
rct::key derivation_rct;
auto a_wiper = epee::misc_utils::create_scope_leave_handler([&]{
memwipe(&derivation_rct, sizeof(rct::key));
});
tools::scrubbed<rct::key> derivation_rct;
rct::scalarmultKey(derivation_rct, rct::pk2rct(pubkey_and_origins.first), rct::sk2rct(base_privkey));
rct::scalarmultKey(derivation_rct, derivation_rct, rct::EIGHT);
+10 -22
View File
@@ -28,7 +28,6 @@
#include "multisig_tx_builder_ringct.h"
#include "int-util.h"
#include "memwipe.h"
#include "cryptonote_basic/cryptonote_basic.h"
@@ -41,6 +40,7 @@
#include "ringct/bulletproofs.h"
#include "ringct/bulletproofs_plus.h"
#include "ringct/rctSigs.h"
#include "scope_guard.h"
#include <boost/multiprecision/cpp_int.hpp>
@@ -253,7 +253,7 @@ static void make_tx_secret_key_seed(const crypto::secret_key& tx_secret_key_entr
rct::keyV hash_context;
hash_context.reserve(2 + sources.size());
auto hash_context_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard hash_context_wiper([&]{
memwipe(hash_context.data(), hash_context.size() * sizeof(rct::key));
});
hash_context.emplace_back();
@@ -281,7 +281,7 @@ static void make_tx_secret_keys(const crypto::secret_key& tx_secret_key_seed,
rct::keyV hash_context;
hash_context.resize(2);
auto hash_context_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard hash_context_wiper([&]{
memwipe(hash_context.data(), hash_context.size() * sizeof(rct::key));
});
hash_context[0] = rct::sk2rct(tx_secret_key_seed);
@@ -663,7 +663,7 @@ static bool set_tx_rct_signatures(
// make pseudo-output commitments
rct::keyV a; //pseudo-output commitment blinding factors
auto a_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard a_wiper([&]{
memwipe(static_cast<rct::key *>(a.data()), a.size() * sizeof(rct::key));
});
if (not reconstruction) {
@@ -749,10 +749,7 @@ static bool set_tx_rct_signatures(
}
rct::key D;
rct::key z;
auto z_wiper = epee::misc_utils::create_scope_leave_handler([&]{
memwipe(static_cast<rct::key *>(&z), sizeof(rct::key));
});
tools::scrubbed<rct::key> z;
if (not reconstruction) {
sc_sub(z.bytes, sources[i].mask.bytes, a[i].bytes); //commitment to zero privkey
ge_p3 H_p3;
@@ -877,7 +874,7 @@ bool tx_builder_ringct_t::init(
// get secret keys for signing input CLSAGs (multisig: or for the initial partial signature)
rct::keyV input_secret_keys;
auto input_secret_keys_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard input_secret_keys_wiper([&]{
memwipe(static_cast<rct::key *>(input_secret_keys.data()), input_secret_keys.size() * sizeof(rct::key));
});
if (not compute_keys_for_sources(account_keys, sources, subaddr_account, subaddr_minor_indices, input_secret_keys))
@@ -891,7 +888,7 @@ bool tx_builder_ringct_t::init(
rct::keyV output_public_keys;
rct::keyV output_amount_secret_keys;
std::vector<crypto::view_tag> view_tags;
auto output_amount_secret_keys_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard output_amount_secret_keys_wiper([&]{
memwipe(static_cast<rct::key *>(output_amount_secret_keys.data()), output_amount_secret_keys.size() * sizeof(rct::key));
});
if (not compute_keys_for_destinations(account_keys,
@@ -947,10 +944,7 @@ bool tx_builder_ringct_t::first_partial_sign(
if (source >= num_sources)
return false;
rct::key c;
rct::key alpha_combined;
auto alpha_combined_wiper = epee::misc_utils::create_scope_leave_handler([&]{
memwipe(static_cast<rct::key *>(&alpha_combined), sizeof(rct::key));
});
tools::scrubbed<rct::key> alpha_combined;
if (not CLSAG_contexts[source].combine_alpha_and_compute_challenge(
total_alpha_G,
total_alpha_H,
@@ -993,10 +987,7 @@ bool tx_builder_ringct_t::next_partial_sign(
return false;
for (std::size_t i = 0; i < num_sources; ++i) {
rct::key c;
rct::key alpha_combined;
auto alpha_combined_wiper = epee::misc_utils::create_scope_leave_handler([&]{
memwipe(static_cast<rct::key *>(&alpha_combined), sizeof(rct::key));
});
tools::scrubbed<rct::key> alpha_combined;
if (not CLSAG_contexts[i].combine_alpha_and_compute_challenge(
total_alpha_G[i],
total_alpha_H[i],
@@ -1011,10 +1002,7 @@ bool tx_builder_ringct_t::next_partial_sign(
rct::key mu_C;
if (not CLSAG_contexts[i].get_mu(mu_P, mu_C))
return false;
rct::key w;
auto w_wiper = epee::misc_utils::create_scope_leave_handler([&]{
memwipe(static_cast<rct::key *>(&w), sizeof(rct::key));
});
tools::scrubbed<rct::key> w;
sc_mul(w.bytes, mu_P.bytes, x.bytes);
// include local signer's response:
+1 -1
View File
@@ -1153,7 +1153,7 @@ namespace nodetool
bool r = epee::net_utils::async_invoke_remote_command2<typename COMMAND_HANDSHAKE::response>(context_, COMMAND_HANDSHAKE::ID, arg, zone.m_net_server.get_config_object(),
[this, &pi, &ev, &hsh_result, &just_take_peerlist, &context_, &timeout](int code, const typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context)
{
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ev.raise();});
const epee::scope_guard scope_exit_handler([&](){ev.raise();});
if(code < 0)
{
+3 -4
View File
@@ -33,15 +33,14 @@
#include <atomic>
#include "misc_log_ex.h"
#include "misc_language.h"
#include "common/perf_timer.h"
#include "common/threadpool.h"
#include "common/util.h"
#include "bulletproofs.h"
#include "bulletproofs_plus.h"
#include "cryptonote_config.h"
#include "device/device.hpp"
#include "fcmp_pp/fcmp_pp_crypto.h"
#include "scope_guard.h"
#include "serialization/crypto.h"
using namespace crypto;
@@ -180,7 +179,7 @@ namespace rct {
//Borromean (c.f. gmax/andytoshi's paper)
boroSig genBorromean(const key64 x, const key64 P1, const key64 P2, const bits indices) {
key64 L[2], alpha;
auto wiper = epee::misc_utils::create_scope_leave_handler([&](){memwipe(alpha, sizeof(alpha));});
const epee::scope_guard wiper([&](){memwipe(alpha, sizeof(alpha));});
key c;
int naught = 0, prime = 0, ii = 0, jj=0;
boroSig bb;
@@ -397,7 +396,7 @@ namespace rct {
vector<geDsmp> Ip(dsRows);
rv.II = keyV(dsRows);
keyV alpha(rows);
auto wiper = epee::misc_utils::create_scope_leave_handler([&](){memwipe(alpha.data(), alpha.size() * sizeof(alpha[0]));});
const epee::scope_guard wiper([&](){memwipe(alpha.data(), alpha.size() * sizeof(alpha[0]));});
keyV aG(rows);
rv.ss = keyM(cols, aG);
keyV aHP(dsRows);
-2
View File
@@ -31,7 +31,6 @@
#include <boost/preprocessor/stringize.hpp>
#include <boost/uuid/nil_generator.hpp>
#include <boost/filesystem.hpp>
#include "include_base_utils.h"
#include "string_tools.h"
using namespace epee;
@@ -48,7 +47,6 @@ using namespace epee;
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/merge_mining.h"
#include "cryptonote_core/tx_sanity_check.h"
#include "misc_language.h"
#include "net/local_ip.h"
#include "net/parse.h"
#include "storages/http_abstract_invoke.h"
+7 -7
View File
@@ -110,7 +110,7 @@ using tools::fee_priority;
m_wallet->stop(); \
boost::unique_lock<boost::mutex> lock(m_idle_mutex); \
m_idle_cond.notify_all(); \
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ \
const epee::scope_guard scope_exit_handler([&](){ \
/* m_idle_mutex is still locked here */ \
m_auto_refresh_enabled.store(auto_refresh_enabled, std::memory_order_relaxed); \
m_idle_cond.notify_one(); \
@@ -1425,7 +1425,7 @@ bool simple_wallet::import_multisig_main(const std::vector<std::string> &args, b
try
{
m_in_manual_refresh.store(true, std::memory_order_relaxed);
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
const epee::scope_guard scope_exit_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
size_t n_outputs = m_wallet->import_multisig(info);
// Clear line "Height xxx of xxx"
std::cout << "\r \r";
@@ -3851,7 +3851,7 @@ static bool datestr_to_int(const std::string &heightstr, uint16_t &year, uint8_t
//----------------------------------------------------------------------------------------------------
bool simple_wallet::init(const boost::program_options::variables_map& vm)
{
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard scope_exit_handler([&](){
m_electrum_seed.wipe();
});
@@ -5605,7 +5605,7 @@ bool simple_wallet::refresh_main(uint64_t start_height, enum ResetType reset, bo
try
{
m_in_manual_refresh.store(true, std::memory_order_relaxed);
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
const epee::scope_guard scope_exit_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
// For manual refresh don't allow incremental checking of the pool: Because we did not process the txs
// for us in the pool during automatic refresh we could miss some of them if we checked the pool
// incrementally here
@@ -6268,7 +6268,7 @@ bool simple_wallet::on_command(bool (simple_wallet::*cmd)(const std::vector<std:
m_last_activity_time = time(NULL);
m_in_command = true;
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){
const epee::scope_guard scope_exit_handler([&](){
m_last_activity_time = time(NULL);
m_in_command = false;
});
@@ -8402,7 +8402,7 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
try
{
m_in_manual_refresh.store(true, std::memory_order_relaxed);
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
const epee::scope_guard scope_exit_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> process_txs;
m_wallet->update_pool_state(process_txs);
@@ -8890,7 +8890,7 @@ bool simple_wallet::rescan_blockchain(const std::vector<std::string> &args_)
}
m_in_manual_refresh.store(true, std::memory_order_relaxed);
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
const epee::scope_guard scope_exit_handler([&](){m_in_manual_refresh.store(false, std::memory_order_relaxed);});
return refresh_main(start_height, reset_type, true);
}
//----------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -65,7 +65,7 @@ using namespace cryptonote;
m_refreshCV.notify_one(); \
boost::mutex::scoped_lock lock(m_refreshMutex); \
boost::mutex::scoped_lock lock2(m_refreshMutex2); \
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ \
const epee::scope_guard scope_exit_handler([&](){ \
/* m_refreshMutex's still locked here */ \
if (refresh_enabled) \
startRefresh(); \
+6 -6
View File
@@ -32,7 +32,7 @@
#include <boost/filesystem.hpp>
#include "common/util.h"
#include "misc_log_ex.h"
#include "misc_language.h"
#include "scope_guard.h"
#include "wallet_errors.h"
#include "ringdb.h"
#include "cryptonote_config.h"
@@ -217,7 +217,7 @@ ringdb::ringdb(std::string filename, const std::string &genesis):
dbr = mdb_txn_begin(env, NULL, 0, &txn);
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
const epee::scope_guard txn_dtor([&](){if (tx_active) mdb_txn_abort(txn);});
tx_active = true;
dbr = mdb_dbi_open(txn, ("rings-" + genesis).c_str(), MDB_CREATE, &dbi_rings);
@@ -254,7 +254,7 @@ bool ringdb::add_rings(const crypto::chacha_key &chacha_key, const cryptonote::t
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to set env map size");
dbr = mdb_txn_begin(env, NULL, 0, &txn);
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
const epee::scope_guard txn_dtor([&](){if (tx_active) mdb_txn_abort(txn);});
tx_active = true;
for (const auto &in: tx.vin)
@@ -285,7 +285,7 @@ bool ringdb::remove_rings(const crypto::chacha_key &chacha_key, const std::vecto
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to set env map size");
dbr = mdb_txn_begin(env, NULL, 0, &txn);
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
const epee::scope_guard txn_dtor([&](){if (tx_active) mdb_txn_abort(txn);});
tx_active = true;
for (const crypto::key_image &key_image: key_images)
@@ -342,7 +342,7 @@ bool ringdb::get_rings(const crypto::chacha_key &chacha_key, const std::vector<c
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to set env map size: " + std::string(mdb_strerror(dbr)));
dbr = mdb_txn_begin(env, NULL, 0, &txn);
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
const epee::scope_guard txn_dtor([&](){if (tx_active) mdb_txn_abort(txn);});
tx_active = true;
for (size_t i = 0; i < key_images.size(); ++i)
@@ -405,7 +405,7 @@ bool ringdb::set_rings(const crypto::chacha_key &chacha_key, const std::vector<s
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to set env map size: " + std::string(mdb_strerror(dbr)));
dbr = mdb_txn_begin(env, NULL, 0, &txn);
THROW_WALLET_EXCEPTION_IF(dbr, tools::error::wallet_internal_error, "Failed to create LMDB transaction: " + std::string(mdb_strerror(dbr)));
epee::misc_utils::auto_scope_leave_caller txn_dtor = epee::misc_utils::create_scope_leave_handler([&](){if (tx_active) mdb_txn_abort(txn);});
const epee::scope_guard txn_dtor([&](){if (tx_active) mdb_txn_abort(txn);});
tx_active = true;
for (const auto &e: rings)
+8 -8
View File
@@ -3779,7 +3779,7 @@ void wallet2::update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote:
MTRACE("update_pool_state_by_pool_query start");
process_txs.clear();
auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() {
const epee::scope_guard keys_reencryptor([&, this]() {
m_encrypt_keys_after_refresh.reset();
});
@@ -3853,7 +3853,7 @@ void wallet2::update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote:
void wallet2::update_pool_state_from_pool_data(bool incremental, const std::vector<crypto::hash> &removed_pool_txids, const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &added_pool_txs, std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed)
{
MTRACE("update_pool_state_from_pool_data start");
auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() {
const epee::scope_guard keys_reencryptor([&, this]() {
m_encrypt_keys_after_refresh.reset();
});
@@ -4110,11 +4110,11 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo
// subsequent pulls in this refresh.
start_height = 0;
auto keys_reencryptor = epee::misc_utils::create_scope_leave_handler([&, this]() {
const epee::scope_guard keys_reencryptor([&, this]() {
m_encrypt_keys_after_refresh.reset();
});
auto scope_exit_handler_hwdev = epee::misc_utils::create_scope_leave_handler([&](){hwdev.computing_key_images(false);});
const epee::scope_guard scope_exit_handler_hwdev([&](){hwdev.computing_key_images(false);});
std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> process_pool_txs;
// Getting and processing the pool state has moved down into method 'pull_blocks' to
@@ -8315,7 +8315,7 @@ bool wallet2::sign_multisig_tx(multisig_tx_set &exported_txs_inout, std::vector<
{
rct::keyM local_nonces_k(sd.selected_transfers.size(), rct::keyV(multisig::signing::kAlphaComponents));
rct::key skey = rct::zero();
auto wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard wiper([&]{
for (auto& e: local_nonces_k)
memwipe(e.data(), e.size() * sizeof(rct::key));
memwipe(&skey, sizeof(rct::key));
@@ -9999,7 +9999,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
// because LR nonces can only be used for one tx attempt.
for (std::size_t j = 0; j < num_sources; ++j) {
rct::keyV alpha(num_alpha_components);
auto alpha_wiper = epee::misc_utils::create_scope_leave_handler([&]{
const epee::scope_guard alpha_wiper([&]{
memwipe(static_cast<rct::key *>(alpha.data()), alpha.size() * sizeof(rct::key));
});
for (std::size_t m = 0; m < num_alpha_components; ++m) {
@@ -13552,7 +13552,7 @@ void wallet2::process_background_cache(const background_sync_data_t &background_
// We expect the spend key to be in a decrypted state while
// m_processing_background_cache is true
m_processing_background_cache = true;
auto done_processing = epee::misc_utils::create_scope_leave_handler([&, this]() {
const epee::scope_guard done_processing([&, this]() {
m_processing_background_cache = false;
});
@@ -14790,7 +14790,7 @@ T wallet2::decrypt(const std::string &ciphertext, const crypto::secret_key &skey
error::wallet_internal_error, "Failed to authenticate ciphertext");
}
std::unique_ptr<char[]> buffer{new char[ciphertext.size() - prefix_size]};
auto wiper = epee::misc_utils::create_scope_leave_handler([&]() { memwipe(buffer.get(), ciphertext.size() - prefix_size); });
const epee::scope_guard wiper([&]() { memwipe(buffer.get(), ciphertext.size() - prefix_size); });
crypto::chacha20(ciphertext.data() + sizeof(iv), ciphertext.size() - prefix_size, key, iv, buffer.get());
return T(buffer.get(), ciphertext.size() - prefix_size);
}
+3 -4
View File
@@ -35,8 +35,6 @@
#include <cstdint>
#include <chrono>
#include <cstring>
#include "include_base_utils.h"
using namespace epee;
#include "version.h"
#include "wallet_rpc_server.h"
@@ -49,7 +47,6 @@ using namespace epee;
#include "cryptonote_basic/account.h"
#include "multisig/multisig.h"
#include "wallet_rpc_server_commands_defs.h"
#include "misc_language.h"
#include "string_coding.h"
#include "string_tools.h"
#include "crypto/hash.h"
@@ -136,6 +133,8 @@ using namespace epee;
} \
} while (0)
using namespace epee;
namespace
{
const command_line::arg_descriptor<std::string, true> arg_rpc_bind_port = {"rpc-bind-port", "Sets bind port for server"};
@@ -3519,7 +3518,7 @@ namespace tools
return false;
}
cryptonote::COMMAND_RPC_START_MINING::request daemon_req = AUTO_VAL_INIT(daemon_req);
cryptonote::COMMAND_RPC_START_MINING::request daemon_req{};
daemon_req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
daemon_req.threads_count = req.threads_count;
daemon_req.do_background_mining = req.do_background_mining;