mirror of
https://codeberg.org/nahuhh/wownero
synced 2026-11-13 09:03:58 +01:00
@@ -1346,6 +1346,7 @@ void BlockchainLMDB::sync()
|
||||
|
||||
void BlockchainLMDB::safesyncmode(const bool onoff)
|
||||
{
|
||||
MINFO("switching safe mode " << (onoff ? "on" : "off"));
|
||||
mdb_env_set_flags(m_env, MDB_NOSYNC|MDB_MAPASYNC, !onoff);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,6 +283,3 @@ bool checkpoints::load_checkpoints_from_json(const std::string &json_hashfile_fu
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4571,5 +4571,3 @@ bool Blockchain::for_all_outputs(uint64_t amount, std::function<bool(uint64_t he
|
||||
namespace cryptonote {
|
||||
template bool Blockchain::get_transactions(const std::vector<crypto::hash>&, std::list<transaction>&, std::list<crypto::hash>&) const;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -438,6 +438,7 @@ namespace cryptonote
|
||||
std::vector<std::string> options;
|
||||
boost::trim(db_sync_mode);
|
||||
boost::split(options, db_sync_mode, boost::is_any_of(" :"));
|
||||
const bool db_sync_mode_is_default = command_line::is_arg_defaulted(vm, cryptonote::arg_db_sync_mode);
|
||||
|
||||
for(const auto &option : options)
|
||||
MDEBUG("option: " << option);
|
||||
@@ -458,18 +459,18 @@ namespace cryptonote
|
||||
{
|
||||
safemode = true;
|
||||
db_flags = DBF_SAFE;
|
||||
sync_mode = db_nosync;
|
||||
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_nosync;
|
||||
}
|
||||
else if(options[0] == "fast")
|
||||
{
|
||||
db_flags = DBF_FAST;
|
||||
sync_mode = db_async;
|
||||
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
|
||||
}
|
||||
else if(options[0] == "fastest")
|
||||
{
|
||||
db_flags = DBF_FASTEST;
|
||||
blocks_per_sync = 1000; // default to fastest:async:1000
|
||||
sync_mode = db_async;
|
||||
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
|
||||
}
|
||||
else
|
||||
db_flags = DEFAULT_FLAGS;
|
||||
@@ -478,9 +479,9 @@ namespace cryptonote
|
||||
if(options.size() >= 2 && !safemode)
|
||||
{
|
||||
if(options[1] == "sync")
|
||||
sync_mode = db_sync;
|
||||
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_sync;
|
||||
else if(options[1] == "async")
|
||||
sync_mode = db_async;
|
||||
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async;
|
||||
}
|
||||
|
||||
if(options.size() >= 3 && !safemode)
|
||||
|
||||
@@ -315,9 +315,10 @@ namespace cryptonote
|
||||
tx.vin.push_back(input_to_key);
|
||||
}
|
||||
|
||||
// "Shuffle" outs
|
||||
std::vector<tx_destination_entry> shuffled_dsts(destinations);
|
||||
std::shuffle(shuffled_dsts.begin(), shuffled_dsts.end(), std::default_random_engine(crypto::rand<unsigned int>()));
|
||||
if (shuffle_outs)
|
||||
{
|
||||
std::shuffle(destinations.begin(), destinations.end(), std::default_random_engine(crypto::rand<unsigned int>()));
|
||||
}
|
||||
|
||||
// sort ins by their key image
|
||||
std::vector<size_t> ins_order(sources.size());
|
||||
@@ -364,7 +365,7 @@ namespace cryptonote
|
||||
uint64_t summary_outs_money = 0;
|
||||
//fill outputs
|
||||
size_t output_index = 0;
|
||||
for(const tx_destination_entry& dst_entr: shuffled_dsts)
|
||||
for(const tx_destination_entry& dst_entr: destinations)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount);
|
||||
crypto::key_derivation derivation;
|
||||
|
||||
@@ -308,7 +308,8 @@ namespace cryptonote
|
||||
<< " [Your node is " << abs_diff << " blocks (" << ((abs_diff - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) "
|
||||
<< (0 <= diff ? std::string("behind") : std::string("ahead"))
|
||||
<< "] " << ENDL << "SYNCHRONIZATION started");
|
||||
m_core.safesyncmode(false);
|
||||
if (hshd.current_height >= m_core.get_current_blockchain_height() + 5) // don't switch to unsafe mode just for a few blocks
|
||||
m_core.safesyncmode(false);
|
||||
}
|
||||
LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id);
|
||||
context.m_state = cryptonote_connection_context::state_synchronizing;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace hw {
|
||||
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override;
|
||||
crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false) override;
|
||||
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override;
|
||||
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) override;
|
||||
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations);
|
||||
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override;
|
||||
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override;
|
||||
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override;
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace hw {
|
||||
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override;
|
||||
crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false) override;
|
||||
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override;
|
||||
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) override;
|
||||
bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations);
|
||||
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override;
|
||||
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override;
|
||||
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// Copyright (c) 2017-2018, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
|
||||
@@ -380,7 +380,6 @@ namespace nodetool
|
||||
|
||||
}
|
||||
return full_addrs;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
@@ -2047,4 +2046,3 @@ namespace nodetool
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2100,6 +2100,13 @@ namespace cryptonote
|
||||
if (d.cached && amount == 0 && d.cached_from == req.from_height && d.cached_to == req.to_height)
|
||||
{
|
||||
res.distributions.push_back({amount, d.cached_start_height, d.cached_distribution, d.cached_base});
|
||||
if (req.cumulative)
|
||||
{
|
||||
auto &distribution = res.distributions.back().distribution;
|
||||
distribution[0] += d.cached_base;
|
||||
for (size_t n = 1; n < distribution.size(); ++n)
|
||||
distribution[n] += distribution[n-1];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2117,12 +2124,6 @@ namespace cryptonote
|
||||
if (offset <= req.to_height && req.to_height - offset + 1 < distribution.size())
|
||||
distribution.resize(req.to_height - offset + 1);
|
||||
}
|
||||
if (req.cumulative)
|
||||
{
|
||||
distribution[0] += base;
|
||||
for (size_t n = 1; n < distribution.size(); ++n)
|
||||
distribution[n] += distribution[n-1];
|
||||
}
|
||||
|
||||
if (amount == 0)
|
||||
{
|
||||
@@ -2134,6 +2135,13 @@ namespace cryptonote
|
||||
d.cached = true;
|
||||
}
|
||||
|
||||
if (req.cumulative)
|
||||
{
|
||||
distribution[0] += base;
|
||||
for (size_t n = 1; n < distribution.size(); ++n)
|
||||
distribution[n] += distribution[n-1];
|
||||
}
|
||||
|
||||
res.distributions.push_back({amount, start_height, std::move(distribution), base});
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -1007,7 +1007,7 @@ void wallet2::set_unspent(size_t idx)
|
||||
void wallet2::check_acc_out_precomp(const tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const
|
||||
{
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
std::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
hwdev.set_mode(hw::device::TRANSACTION_PARSE);
|
||||
if (o.target.type() != typeid(txout_to_key))
|
||||
{
|
||||
@@ -1085,7 +1085,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
//ensure device is let in NONE mode in any case
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
|
||||
std::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
hw::reset_mode rst(hwdev);
|
||||
hwdev_lock.unlock();
|
||||
|
||||
@@ -1180,7 +1180,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys());
|
||||
if (tx_scan_info[i].received)
|
||||
{
|
||||
hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation);
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
}
|
||||
}
|
||||
@@ -1203,7 +1203,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys());
|
||||
if (tx_scan_info[i].received)
|
||||
{
|
||||
hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation);
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
}
|
||||
}
|
||||
@@ -1219,7 +1219,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||
{
|
||||
hwdev_lock.lock();
|
||||
hwdev.set_mode(hw::device::NONE);
|
||||
hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation);
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations);
|
||||
scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs);
|
||||
hwdev_lock.unlock();
|
||||
}
|
||||
@@ -2698,6 +2698,8 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
|
||||
m_segregate_pre_fork_outputs = true;
|
||||
m_key_reuse_mitigation2 = true;
|
||||
m_segregation_height = 0;
|
||||
m_subaddress_lookahead_major = SUBADDRESS_LOOKAHEAD_MAJOR;
|
||||
m_subaddress_lookahead_minor = SUBADDRESS_LOOKAHEAD_MINOR;
|
||||
m_key_on_device = false;
|
||||
}
|
||||
else if(json.IsObject())
|
||||
@@ -2818,6 +2820,10 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
|
||||
m_key_reuse_mitigation2 = field_key_reuse_mitigation2;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, segregation_height, int, Uint, false, 0);
|
||||
m_segregation_height = field_segregation_height;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, subaddress_lookahead_major, uint32_t, Uint, false, SUBADDRESS_LOOKAHEAD_MAJOR);
|
||||
m_subaddress_lookahead_major = field_subaddress_lookahead_major;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, subaddress_lookahead_minor, uint32_t, Uint, false, SUBADDRESS_LOOKAHEAD_MINOR);
|
||||
m_subaddress_lookahead_minor = field_subaddress_lookahead_minor;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5523,7 +5529,7 @@ bool wallet2::set_ring_database(const std::string &filename)
|
||||
bool wallet2::add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx)
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try { return m_ringdb->add_rings(key, tx); }
|
||||
catch (const std::exception &e) { return false; }
|
||||
}
|
||||
@@ -5549,7 +5555,7 @@ bool wallet2::remove_rings(const cryptonote::transaction_prefix &tx)
|
||||
bool wallet2::get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs)
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try { return m_ringdb->get_ring(key, key_image, outs); }
|
||||
catch (const std::exception &e) { return false; }
|
||||
}
|
||||
@@ -5673,7 +5679,7 @@ bool wallet2::find_and_save_rings(bool force)
|
||||
bool wallet2::blackball_output(const crypto::public_key &output)
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try { return m_ringdb->blackball(output); }
|
||||
catch (const std::exception &e) { return false; }
|
||||
}
|
||||
@@ -5681,7 +5687,7 @@ bool wallet2::blackball_output(const crypto::public_key &output)
|
||||
bool wallet2::set_blackballed_outputs(const std::vector<crypto::public_key> &outputs, bool add)
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try
|
||||
{
|
||||
bool ret = true;
|
||||
@@ -5697,7 +5703,7 @@ bool wallet2::set_blackballed_outputs(const std::vector<crypto::public_key> &out
|
||||
bool wallet2::unblackball_output(const crypto::public_key &output)
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try { return m_ringdb->unblackball(output); }
|
||||
catch (const std::exception &e) { return false; }
|
||||
}
|
||||
@@ -5705,7 +5711,7 @@ bool wallet2::unblackball_output(const crypto::public_key &output)
|
||||
bool wallet2::is_output_blackballed(const crypto::public_key &output) const
|
||||
{
|
||||
if (!m_ringdb)
|
||||
return true;
|
||||
return false;
|
||||
try { return m_ringdb->blackballed(output); }
|
||||
catch (const std::exception &e) { return false; }
|
||||
}
|
||||
@@ -5882,6 +5888,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||
auto end = std::unique(req_t.amounts.begin(), req_t.amounts.end());
|
||||
req_t.amounts.resize(std::distance(req_t.amounts.begin(), end));
|
||||
req_t.from_height = std::max<uint64_t>(segregation_fork_height, RECENT_OUTPUT_BLOCKS) - RECENT_OUTPUT_BLOCKS;
|
||||
req_t.to_height = segregation_fork_height + 1;
|
||||
req_t.cumulative = true;
|
||||
m_daemon_rpc_mutex.lock();
|
||||
bool r = net_utils::invoke_http_json_rpc("/json_rpc", "get_output_distribution", req_t, resp_t, m_http_client, rpc_timeout * 1000);
|
||||
@@ -7294,7 +7301,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||
{
|
||||
//ensure device is let in NONE mode in any case
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
std::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
hw::reset_mode rst(hwdev);
|
||||
|
||||
if(m_light_wallet) {
|
||||
@@ -7877,7 +7884,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton
|
||||
{
|
||||
//ensure device is let in NONE mode in any case
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
std::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
hw::reset_mode rst(hwdev);
|
||||
|
||||
uint64_t accumulated_fee, accumulated_outputs, accumulated_change;
|
||||
|
||||
Reference in New Issue
Block a user