aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--external/db_drivers/liblmdb/mdb.c16
-rw-r--r--external/easylogging++/easylogging++.h4
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp9
-rw-r--r--src/common/util.cpp37
-rw-r--r--src/common/util.h2
-rw-r--r--src/cryptonote_config.h4
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp13
-rw-r--r--src/daemon/rpc_command_executor.cpp10
-rw-r--r--src/p2p/net_node.inl5
-rw-r--r--src/rpc/core_rpc_server.cpp17
-rw-r--r--src/simplewallet/simplewallet.cpp58
-rw-r--r--src/simplewallet/simplewallet.h1
-rw-r--r--src/wallet/api/utils.cpp38
-rw-r--r--src/wallet/wallet2.cpp5
-rw-r--r--src/wallet/wallet_args.cpp5
-rw-r--r--src/wallet/wallet_args.h3
-rw-r--r--src/wallet/wallet_rpc_server.cpp6
-rw-r--r--tests/core_tests/chaingen_main.cpp2
18 files changed, 140 insertions, 95 deletions
diff --git a/external/db_drivers/liblmdb/mdb.c b/external/db_drivers/liblmdb/mdb.c
index 32e225163..d778037b0 100644
--- a/external/db_drivers/liblmdb/mdb.c
+++ b/external/db_drivers/liblmdb/mdb.c
@@ -1953,13 +1953,15 @@ static void
mdb_cursor_unref(MDB_cursor *mc)
{
int i;
- if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
- return;
- for (i=0; i<mc->mc_snum; i++)
- mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
- if (mc->mc_ovpg) {
- mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
- mc->mc_ovpg = 0;
+ if (mc->mc_txn->mt_rpages[0].mid) {
+ if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
+ return;
+ for (i=0; i<mc->mc_snum; i++)
+ mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
+ if (mc->mc_ovpg) {
+ mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
+ mc->mc_ovpg = 0;
+ }
}
mc->mc_snum = mc->mc_top = 0;
mc->mc_pg[0] = NULL;
diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h
index 3395c2cb2..d28152667 100644
--- a/external/easylogging++/easylogging++.h
+++ b/external/easylogging++/easylogging++.h
@@ -1104,8 +1104,8 @@ namespace el {
ELPP_UNUSED(ms);
# endif // ELPP_ASYNC_LOGGING
}
- typedef std::mutex Mutex;
- typedef std::lock_guard<std::mutex> ScopedLock;
+ typedef std::recursive_mutex Mutex;
+ typedef std::lock_guard<std::recursive_mutex> ScopedLock;
# endif // !ELPP_USE_STD_THREADING
#else
namespace internal {
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 7d548afed..1cfcf3a9e 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1056,10 +1056,11 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
// check for existing LMDB files in base directory
boost::filesystem::path old_files = direc.parent_path();
- if (boost::filesystem::exists(old_files / "data.mdb") || boost::filesystem::exists(old_files / "lock.mdb"))
+ if (boost::filesystem::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_FILENAME)
+ || boost::filesystem::exists(old_files / CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME))
{
LOG_PRINT_L0("Found existing LMDB files in " << old_files.string());
- LOG_PRINT_L0("Move data.mdb and/or lock.mdb to " << filename << ", or delete them, and then restart");
+ LOG_PRINT_L0("Move " << CRYPTONOTE_BLOCKCHAINDATA_FILENAME << " and/or " << CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME << " to " << filename << ", or delete them, and then restart");
throw DB_ERROR("Database could not be opened");
}
@@ -1313,9 +1314,9 @@ std::vector<std::string> BlockchainLMDB::get_filenames() const
std::vector<std::string> filenames;
boost::filesystem::path datafile(m_folder);
- datafile /= "data.mdb";
+ datafile /= CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
boost::filesystem::path lockfile(m_folder);
- lockfile /= "lock.mdb";
+ lockfile /= CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME;
filenames.push_back(datafile.string());
filenames.push_back(lockfile.string());
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 6dec6af2a..bfcf86bc6 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -35,6 +35,7 @@ using namespace epee;
#include "util.h"
#include "cryptonote_config.h"
+#include "net/http_client.h" // epee::net_utils::...
#ifdef WIN32
#include <windows.h>
@@ -44,6 +45,7 @@ using namespace epee;
#include <sys/utsname.h>
#endif
#include <boost/filesystem.hpp>
+#include <boost/asio.hpp>
namespace tools
@@ -531,4 +533,39 @@ std::string get_nix_version_display_string()
boost::lock_guard<boost::mutex> lock(max_concurrency_lock);
return max_concurrency;
}
+
+ bool is_local_address(const std::string &address)
+ {
+ // extract host
+ epee::net_utils::http::url_content u_c;
+ if (!epee::net_utils::parse_url(address, u_c))
+ {
+ MWARNING("Failed to determine whether address '" << address << "' is local, assuming not");
+ return false;
+ }
+ if (u_c.host.empty())
+ {
+ MWARNING("Failed to determine whether address '" << address << "' is local, assuming not");
+ return false;
+ }
+
+ // resolve to IP
+ boost::asio::io_service io_service;
+ boost::asio::ip::tcp::resolver resolver(io_service);
+ boost::asio::ip::tcp::resolver::query query(u_c.host, "");
+ boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
+ while (i != boost::asio::ip::tcp::resolver::iterator())
+ {
+ const boost::asio::ip::tcp::endpoint &ep = *i;
+ if (ep.address().is_loopback())
+ {
+ MDEBUG("Address '" << address << "' is local");
+ return true;
+ }
+ ++i;
+ }
+
+ MDEBUG("Address '" << address << "' is not local");
+ return false;
+ }
}
diff --git a/src/common/util.h b/src/common/util.h
index 4437d821f..c2ffc44ca 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -181,4 +181,6 @@ namespace tools
void set_max_concurrency(unsigned n);
unsigned get_max_concurrency();
+
+ bool is_local_address(const std::string &address);
}
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h
index 95cbf74f0..97f2f2afc 100644
--- a/src/cryptonote_config.h
+++ b/src/cryptonote_config.h
@@ -120,8 +120,8 @@
#define CRYPTONOTE_NAME "bitmonero"
#define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
-#define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "blockchain.bin"
-#define CRYPTONOTE_BLOCKCHAINDATA_TEMP_FILENAME "blockchain.bin.tmp"
+#define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
+#define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
#define P2P_NET_DATA_FILENAME "p2pstate.bin"
#define MINER_CONFIG_FILE_NAME "miner_conf.json"
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index ef473cfba..900dc58ba 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -41,6 +41,7 @@ using namespace epee;
#include "cryptonote_format_utils.h"
#include "misc_language.h"
#include <csignal>
+#include <p2p/net_node.h>
#include "cryptonote_core/checkpoints.h"
#include "ringct/rctTypes.h"
#include "blockchain_db/blockchain_db.h"
@@ -258,8 +259,17 @@ namespace cryptonote
m_fakechain = test_options != NULL;
bool r = handle_command_line(vm);
+ bool testnet = command_line::get_arg(vm, command_line::arg_testnet_on);
+ auto p2p_bind_arg = testnet ? nodetool::arg_testnet_p2p_bind_port : nodetool::arg_p2p_bind_port;
+ std::string m_port = command_line::get_arg(vm, p2p_bind_arg);
+ std::string m_config_folder_mempool = m_config_folder;
+
+ if ((!testnet && m_port != std::to_string(::config::P2P_DEFAULT_PORT))
+ || (testnet && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
+ m_config_folder_mempool = m_config_folder_mempool + "/" + m_port;
+ }
- r = m_mempool.init(m_fakechain ? std::string() : m_config_folder);
+ r = m_mempool.init(m_fakechain ? std::string() : m_config_folder_mempool);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);
@@ -531,6 +541,7 @@ namespace cryptonote
if (rv.outPk.size() != tx.vout.size())
{
LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected");
+ tvc.m_verifivation_failed = true;
return false;
}
for (size_t n = 0; n < tx.rct_signatures.outPk.size(); ++n)
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 7bc9afbb9..2bcfd7a95 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -368,7 +368,7 @@ bool t_rpc_command_executor::show_status() {
std::time_t uptime = std::time(nullptr) - ires.start_time;
- tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u+%u connections, uptime %uh %um %us")
+ tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u+%u connections, uptime %ud %uh %um %us")
% (unsigned long long)ires.height
% (unsigned long long)(ires.target_height >= ires.height ? ires.target_height : ires.height)
% get_sync_percentage(ires)
@@ -378,9 +378,11 @@ bool t_rpc_command_executor::show_status() {
% (unsigned)hfres.version
% get_fork_extra_info(hfres.earliest_height, ires.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
- % (unsigned int)floor(uptime / 3600.0)
- % (unsigned int)floor(fmod(uptime, 3600.0) / 60.0)
+ % (unsigned)ires.outgoing_connections_count
+ % (unsigned)ires.incoming_connections_count
+ % (unsigned int)floor(uptime / 60.0 / 60.0 / 24.0)
+ % (unsigned int)floor(fmod((uptime / 60.0 / 60.0), 24.0)
+ % (unsigned int)floor(fmod((uptime / 60.0), 60.0)
% (unsigned int)fmod(uptime, 60.0)
;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index d67c5dd93..7ab6a4894 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -505,6 +505,11 @@ namespace nodetool
auto config_arg = testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir;
m_config_folder = command_line::get_arg(vm, config_arg);
+ if ((!testnet && m_port != std::to_string(::config::P2P_DEFAULT_PORT))
+ || (testnet && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
+ m_config_folder = m_config_folder + "/" + m_port;
+ }
+
res = init_config();
CHECK_AND_ASSERT_MES(res, false, "Failed to init config.");
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 63f2b7e53..b2e8e6716 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -615,6 +615,23 @@ namespace cryptonote
return true;
}
+ unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4;
+
+ // if we couldn't detect threads, set it to a ridiculously high number
+ if(concurrency_count == 0)
+ {
+ concurrency_count = 257;
+ }
+
+ // if there are more threads requested than the hardware supports
+ // then we fail and log that.
+ if(req.threads_count > concurrency_count)
+ {
+ res.status = "Failed, too many threads relative to CPU cores.";
+ LOG_PRINT_L0(res.status);
+ return true;
+ }
+
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index c7487cae8..f5e20be48 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -362,6 +362,33 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s
return true;
}
+bool simple_wallet::change_password(const std::vector<std::string> &args)
+{
+ const auto orig_pwd_container = get_and_verify_password();
+
+ if(orig_pwd_container == boost::none)
+ {
+ fail_msg_writer() << tr("Your original password was incorrect.");
+ return false;
+ }
+
+ // prompts for a new password, this is not a new wallet so pass in false.
+ const auto pwd_container = tools::wallet2::password_prompt(false);
+
+ try
+ {
+ m_wallet->rewrite(m_wallet_file, pwd_container->password());
+ m_wallet->store();
+ }
+ catch (const wallet_logic_error& e)
+ {
+ fail_msg_writer() << tr("Error with wallet rewrite: ") << e.what();
+ return false;
+ }
+
+ return true;
+}
+
bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
{
const auto pwd_container = get_and_verify_password();
@@ -865,33 +892,6 @@ void simple_wallet::print_seed(std::string seed)
//----------------------------------------------------------------------------------------------------
static bool is_local_daemon(const std::string &address)
{
- // extract host
- epee::net_utils::http::url_content u_c;
- if (!epee::net_utils::parse_url(address, u_c))
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
- if (u_c.host.empty())
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
-
- // resolve to IP
- boost::asio::io_service io_service;
- boost::asio::ip::tcp::resolver resolver(io_service);
- boost::asio::ip::tcp::resolver::query query(u_c.host, "");
- boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
- while (i != boost::asio::ip::tcp::resolver::iterator())
- {
- const boost::asio::ip::tcp::endpoint &ep = *i;
- if (ep.address().is_loopback())
- return true;
- ++i;
- }
-
- return false;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::init(const boost::program_options::variables_map& vm)
@@ -1155,9 +1155,9 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
// set --trusted-daemon if local
try
{
- if (is_local_daemon(m_wallet->get_daemon_address()))
+ if (tools::is_local_address(m_wallet->get_daemon_address()))
{
- LOG_PRINT_L1(tr("Daemon is local, assuming trusted"));
+ MINFO(tr("Daemon is local, assuming trusted"));
m_trusted_daemon = true;
}
}
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index 237c1e3e1..9918300df 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -162,6 +162,7 @@ namespace cryptonote
bool export_outputs(const std::vector<std::string> &args);
bool import_outputs(const std::vector<std::string> &args);
bool show_transfer(const std::vector<std::string> &args);
+ bool change_password(const std::vector<std::string>& args);
uint64_t get_daemon_blockchain_height(std::string& err);
bool try_connect_to_daemon(bool silent = false, uint32_t* version = nullptr);
diff --git a/src/wallet/api/utils.cpp b/src/wallet/api/utils.cpp
index 0d30b61cd..788d98f25 100644
--- a/src/wallet/api/utils.cpp
+++ b/src/wallet/api/utils.cpp
@@ -31,50 +31,16 @@
#include "include_base_utils.h" // LOG_PRINT_x
-#include "net/http_client.h" // epee::net_utils::...
-#include <boost/asio.hpp>
+#include "common/util.h"
using namespace std;
namespace Monero {
namespace Utils {
-
-// copy-pasted from simplewallet.
-
bool isAddressLocal(const std::string &address)
{
- // extract host
- epee::net_utils::http::url_content u_c;
- if (!epee::net_utils::parse_url(address, u_c))
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
- if (u_c.host.empty())
- {
- LOG_PRINT_L1("Failed to determine whether daemon is local, assuming not");
- return false;
- }
- // resolver::resolve can throw an exception
- try {
- // resolve to IP
- boost::asio::io_service io_service;
- boost::asio::ip::tcp::resolver resolver(io_service);
- boost::asio::ip::tcp::resolver::query query(u_c.host, "", boost::asio::ip::tcp::resolver::query::canonical_name);
- boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);
- while (i != boost::asio::ip::tcp::resolver::iterator())
- {
- const boost::asio::ip::tcp::endpoint &ep = *i;
- if (ep.address().is_loopback())
- return true;
- ++i;
- }
- } catch (const boost::system::system_error &e) {
- LOG_ERROR("Failed to resolve " << address << ", :" << e.what());
- }
-
- return false;
+ return tools::is_local_address(address);
}
}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 9fd98056a..148fb9d52 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -3007,7 +3007,7 @@ void wallet2::commit_tx(pending_tx& ptx)
}
//fee includes dust if dust policy specified it.
- LOG_PRINT_L0("Transaction successfully sent. <" << txid << ">" << ENDL
+ LOG_PRINT_L1("Transaction successfully sent. <" << txid << ">" << ENDL
<< "Commission: " << print_money(ptx.fee) << " (dust sent to dust addr: " << print_money((ptx.dust_added_to_fee ? 0 : ptx.dust)) << ")" << ENDL
<< "Balance: " << print_money(balance()) << ENDL
<< "Unlocked: " << print_money(unlocked_balance()) << ENDL
@@ -4112,7 +4112,8 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
THROW_WALLET_EXCEPTION_IF(needed_money == 0, error::zero_destination);
// gather all our dust and non dust outputs
- for (size_t i = 0; i < m_transfers.size(); ++i)
+ const std::vector<size_t> unused_indices = select_available_outputs_from_histogram(fake_outs_count + 1, true, true, trusted_daemon);
+ for (size_t i: unused_indices)
{
const transfer_details& td = m_transfers[i];
if (!td.m_spent && (use_rct ? true : !td.is_rct()) && is_transfer_unlocked(td))
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index b7a4532fd..12799f613 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -72,7 +72,8 @@ namespace wallet_args
int argc, char** argv,
const char* const usage,
boost::program_options::options_description desc_params,
- const boost::program_options::positional_options_description& positional_options)
+ const boost::program_options::positional_options_description& positional_options,
+ bool log_to_console)
{
namespace bf = boost::filesystem;
@@ -138,7 +139,7 @@ namespace wallet_args
log_path = command_line::get_arg(vm, arg_log_file);
else
log_path = mlog_get_default_log_path("monero-wallet-cli.log");
- mlog_configure(log_path, false);
+ mlog_configure(log_path, log_to_console);
if (!vm["log-level"].defaulted())
{
mlog_set_log(command_line::get_arg(vm, arg_log_level).c_str());
diff --git a/src/wallet/wallet_args.h b/src/wallet/wallet_args.h
index 17446abf3..e0719d203 100644
--- a/src/wallet/wallet_args.h
+++ b/src/wallet/wallet_args.h
@@ -49,5 +49,6 @@ namespace wallet_args
int argc, char** argv,
const char* const usage,
boost::program_options::options_description desc_params,
- const boost::program_options::positional_options_description& positional_options);
+ const boost::program_options::positional_options_description& positional_options,
+ bool log_to_console = false);
}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index d35e51068..dcf8f8e6d 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1324,16 +1324,14 @@ int main(int argc, char** argv) {
argc, argv,
"monero-wallet-rpc [--wallet-file=<file>|--generate-from-json=<file>] [--rpc-bind-port=<port>]",
desc_params,
- po::positional_options_description()
+ po::positional_options_description(),
+ true
);
if (!vm)
{
return 1;
}
- mlog_configure("monero-wallet-rpc.log", true);
- mlog_set_log_level(2);
-
std::unique_ptr<tools::wallet2> wal;
try
{
diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp
index 557e3f07c..5851d9c6a 100644
--- a/tests/core_tests/chaingen_main.cpp
+++ b/tests/core_tests/chaingen_main.cpp
@@ -51,7 +51,7 @@ int main(int argc, char* argv[])
//set up logging options
mlog_configure(mlog_get_default_log_path("core_tests.log"), true);
- mlog_set_log_level(3);
+ mlog_set_log_level(2);
po::options_description desc_options("Allowed options");
command_line::add_arg(desc_options, command_line::arg_help);