aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/epee/src/memwipe.c1
-rw-r--r--src/blockchain_utilities/blockchain_export.cpp7
-rw-r--r--src/blockchain_utilities/blockchain_import.cpp3
-rw-r--r--src/common/command_line.h47
-rw-r--r--src/common/password.cpp15
-rw-r--r--src/common/password.h2
-rw-r--r--src/common/util.h6
-rw-r--r--src/crypto/random.c1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp37
-rw-r--r--src/cryptonote_core/cryptonote_core.h3
-rw-r--r--src/cryptonote_core/tx_pool.cpp4
-rw-r--r--src/daemon/command_line_args.h41
-rw-r--r--src/daemon/core.h3
-rw-r--r--src/daemon/daemon.cpp14
-rw-r--r--src/daemon/main.cpp20
-rw-r--r--src/p2p/net_node.cpp13
-rw-r--r--src/p2p/net_node.h3
-rw-r--r--src/p2p/net_node.inl10
-rw-r--r--src/rpc/core_rpc_server.cpp22
-rw-r--r--src/rpc/core_rpc_server.h4
-rw-r--r--src/simplewallet/simplewallet.cpp7
-rw-r--r--tests/core_proxy/core_proxy.cpp3
22 files changed, 151 insertions, 115 deletions
diff --git a/contrib/epee/src/memwipe.c b/contrib/epee/src/memwipe.c
index 9a83e67e8..e3a2f76c8 100644
--- a/contrib/epee/src/memwipe.c
+++ b/contrib/epee/src/memwipe.c
@@ -31,6 +31,7 @@
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_EXPLICIT_BZERO
#include <strings.h>
diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp
index fcf020057..b3e11605d 100644
--- a/src/blockchain_utilities/blockchain_export.cpp
+++ b/src/blockchain_utilities/blockchain_export.cpp
@@ -59,7 +59,6 @@ int main(int argc, char* argv[])
tools::on_startup();
boost::filesystem::path default_data_path {tools::get_default_data_dir()};
- boost::filesystem::path default_testnet_data_path {default_data_path / "testnet"};
boost::filesystem::path output_file_path;
po::options_description desc_cmd_only("Command line options");
@@ -73,8 +72,7 @@ int main(int argc, char* argv[])
const command_line::arg_descriptor<bool> arg_blocks_dat = {"blocksdat", "Output in blocks.dat format", blocks_dat};
- command_line::add_arg(desc_cmd_sett, cryptonote::arg_data_dir, default_data_path.string());
- command_line::add_arg(desc_cmd_sett, cryptonote::arg_testnet_data_dir, default_testnet_data_path.string());
+ command_line::add_arg(desc_cmd_sett, cryptonote::arg_data_dir);
command_line::add_arg(desc_cmd_sett, arg_output_file);
command_line::add_arg(desc_cmd_sett, cryptonote::arg_testnet_on);
command_line::add_arg(desc_cmd_sett, arg_log_level);
@@ -118,8 +116,7 @@ int main(int argc, char* argv[])
std::string m_config_folder;
- auto data_dir_arg = opt_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir;
- m_config_folder = command_line::get_arg(vm, data_dir_arg);
+ m_config_folder = command_line::get_arg(vm, cryptonote::arg_data_dir);
std::string db_type = command_line::get_arg(vm, arg_database);
if (!cryptonote::blockchain_valid_db_type(db_type))
diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp
index ce08022fc..6195e47e7 100644
--- a/src/blockchain_utilities/blockchain_import.cpp
+++ b/src/blockchain_utilities/blockchain_import.cpp
@@ -671,8 +671,7 @@ int main(int argc, char* argv[])
}
opt_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
- auto data_dir_arg = opt_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir;
- m_config_folder = command_line::get_arg(vm, data_dir_arg);
+ m_config_folder = command_line::get_arg(vm, cryptonote::arg_data_dir);
db_arg_str = command_line::get_arg(vm, arg_database);
mlog_configure(mlog_get_default_log_path("monero-blockchain-import.log"), true);
diff --git a/src/common/command_line.h b/src/common/command_line.h
index 7b183d86b..f67efcf86 100644
--- a/src/common/command_line.h
+++ b/src/common/command_line.h
@@ -30,7 +30,9 @@
#pragma once
+#include <functional>
#include <iostream>
+#include <sstream>
#include <type_traits>
#include <boost/program_options/parsers.hpp>
@@ -46,7 +48,7 @@ namespace command_line
//! \return True if `str` is `is_iequal("n" || "no" || `tr("no"))`.
bool is_no(const std::string& str);
- template<typename T, bool required = false>
+ template<typename T, bool required = false, bool dependent = false>
struct arg_descriptor;
template<typename T>
@@ -81,6 +83,22 @@ namespace command_line
};
template<typename T>
+ struct arg_descriptor<T, false, true>
+ {
+ typedef T value_type;
+
+ const char* name;
+ const char* description;
+
+ T default_value;
+
+ const arg_descriptor<bool, false>& ref;
+ std::function<T(bool, bool, T)> depf;
+
+ bool not_use_default;
+ };
+
+ template<typename T>
boost::program_options::typed_value<T, char>* make_semantic(const arg_descriptor<T, true>& /*arg*/)
{
return boost::program_options::value<T>()->required();
@@ -96,6 +114,20 @@ namespace command_line
}
template<typename T>
+ boost::program_options::typed_value<T, char>* make_semantic(const arg_descriptor<T, false, true>& arg)
+ {
+ auto semantic = boost::program_options::value<T>();
+ if (!arg.not_use_default) {
+ std::ostringstream format;
+ format << arg.depf(false, true, arg.default_value) << ", "
+ << arg.depf(true, true, arg.default_value) << " if '"
+ << arg.ref.name << "'";
+ semantic->default_value(arg.depf(arg.ref.default_value, true, arg.default_value), format.str());
+ }
+ return semantic;
+ }
+
+ template<typename T>
boost::program_options::typed_value<T, char>* make_semantic(const arg_descriptor<T, false>& arg, const T& def)
{
auto semantic = boost::program_options::value<T>();
@@ -112,8 +144,8 @@ namespace command_line
return semantic;
}
- template<typename T, bool required>
- void add_arg(boost::program_options::options_description& description, const arg_descriptor<T, required>& arg, bool unique = true)
+ template<typename T, bool required, bool dependent>
+ void add_arg(boost::program_options::options_description& description, const arg_descriptor<T, required, dependent>& arg, bool unique = true)
{
if (0 != description.find_nothrow(arg.name, false))
{
@@ -189,12 +221,17 @@ namespace command_line
return !value.empty();
}
- template<typename T, bool required>
- bool is_arg_defaulted(const boost::program_options::variables_map& vm, const arg_descriptor<T, required>& arg)
+ template<typename T, bool required, bool dependent>
+ bool is_arg_defaulted(const boost::program_options::variables_map& vm, const arg_descriptor<T, required, dependent>& arg)
{
return vm[arg.name].defaulted();
}
+ template<typename T, bool required>
+ T get_arg(const boost::program_options::variables_map& vm, const arg_descriptor<T, required, true>& arg)
+ {
+ return arg.depf(get_arg(vm, arg.ref), is_arg_defaulted(vm, arg), vm[arg.name].template as<T>());
+ }
template<typename T, bool required>
T get_arg(const boost::program_options::variables_map& vm, const arg_descriptor<T, required>& arg)
diff --git a/src/common/password.cpp b/src/common/password.cpp
index ef026c979..9336a14fc 100644
--- a/src/common/password.cpp
+++ b/src/common/password.cpp
@@ -42,12 +42,10 @@
#include <unistd.h>
#endif
-#ifdef HAVE_READLINE
- #include "readline_buffer.h"
-#endif
-
#include "memwipe.h"
+#define EOT 0x4
+
namespace
{
#if defined(_WIN32)
@@ -134,7 +132,7 @@ namespace
while (aPass.size() < tools::password_container::max_password_size)
{
int ch = getch();
- if (EOF == ch)
+ if (EOF == ch || ch == EOT)
{
return false;
}
@@ -229,13 +227,20 @@ namespace tools
m_password.clear();
}
+ std::atomic<bool> password_container::is_prompting(false);
+
boost::optional<password_container> password_container::prompt(const bool verify, const char *message)
{
+ is_prompting = true;
password_container pass1{};
password_container pass2{};
if (is_cin_tty() ? read_from_tty(verify, message, pass1.m_password, pass2.m_password) : read_from_file(pass1.m_password))
+ {
+ is_prompting = false;
return {std::move(pass1)};
+ }
+ is_prompting = false;
return boost::none;
}
diff --git a/src/common/password.h b/src/common/password.h
index 7c29effe4..61937b93a 100644
--- a/src/common/password.h
+++ b/src/common/password.h
@@ -31,6 +31,7 @@
#pragma once
#include <string>
+#include <atomic>
#include <boost/optional/optional.hpp>
#include "wipeable_string.h"
@@ -49,6 +50,7 @@ namespace tools
//! \return A password from stdin TTY prompt or `std::cin` pipe.
static boost::optional<password_container> prompt(bool verify, const char *mesage = "Password");
+ static std::atomic<bool> is_prompting;
password_container(const password_container&) = delete;
password_container(password_container&& rhs) = default;
diff --git a/src/common/util.h b/src/common/util.h
index 5afb42c97..d3ba47a4f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -153,8 +153,12 @@ namespace tools
}
return r;
#else
+ static struct sigaction sa;
+ memset(&sa, 0, sizeof(struct sigaction));
+ sa.sa_handler = posix_handler;
+ sa.sa_flags = 0;
/* Only blocks SIGINT, SIGTERM and SIGPIPE */
- signal(SIGINT, posix_handler);
+ sigaction(SIGINT, &sa, NULL);
signal(SIGTERM, posix_handler);
signal(SIGPIPE, SIG_IGN);
m_handler = t;
diff --git a/src/crypto/random.c b/src/crypto/random.c
index 929377943..9e1a70a2d 100644
--- a/src/crypto/random.c
+++ b/src/crypto/random.c
@@ -42,6 +42,7 @@ static void generate_system_random_bytes(size_t n, void *result);
#include <windows.h>
#include <wincrypt.h>
+#include <stdio.h>
static void generate_system_random_bytes(size_t n, void *result) {
HCRYPTPROV prov;
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index aaa5ccdbc..e0430a18a 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -66,19 +66,22 @@ DISABLE_VS_WARNINGS(4355)
namespace cryptonote
{
- const command_line::arg_descriptor<std::string> arg_data_dir = {
- "data-dir"
- , "Specify data directory"
- };
- const command_line::arg_descriptor<std::string> arg_testnet_data_dir = {
- "testnet-data-dir"
- , "Specify testnet data directory"
- };
const command_line::arg_descriptor<bool, false> arg_testnet_on = {
"testnet"
, "Run on testnet. The wallet must be launched with --testnet flag."
, false
};
+ const command_line::arg_descriptor<std::string, false, true> arg_data_dir = {
+ "data-dir"
+ , "Specify data directory"
+ , tools::get_default_data_dir()
+ , arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet)
+ return (boost::filesystem::path(val) / "testnet").string();
+ return val;
+ }
+ };
const command_line::arg_descriptor<bool> arg_offline = {
"offline"
, "Do not listen for peers, nor connect to any"
@@ -134,7 +137,12 @@ namespace cryptonote
};
static const command_line::arg_descriptor<bool> arg_fluffy_blocks = {
"fluffy-blocks"
- , "Relay blocks as fluffy blocks where possible (automatic on testnet)"
+ , "Relay blocks as fluffy blocks (obsolete, now default)"
+ , true
+ };
+ static const command_line::arg_descriptor<bool> arg_no_fluffy_blocks = {
+ "no-fluffy-blocks"
+ , "Relay blocks as normal blocks"
, false
};
static const command_line::arg_descriptor<size_t> arg_max_txpool_size = {
@@ -229,8 +237,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------
void core::init_options(boost::program_options::options_description& desc)
{
- command_line::add_arg(desc, arg_data_dir, tools::get_default_data_dir());
- command_line::add_arg(desc, arg_testnet_data_dir, (boost::filesystem::path(tools::get_default_data_dir()) / "testnet").string());
+ command_line::add_arg(desc, arg_data_dir);
command_line::add_arg(desc, arg_test_drop_download);
command_line::add_arg(desc, arg_test_drop_download_height);
@@ -243,6 +250,7 @@ namespace cryptonote
command_line::add_arg(desc, arg_block_sync_size);
command_line::add_arg(desc, arg_check_updates);
command_line::add_arg(desc, arg_fluffy_blocks);
+ command_line::add_arg(desc, arg_no_fluffy_blocks);
command_line::add_arg(desc, arg_test_dbg_lock_sleep);
command_line::add_arg(desc, arg_offline);
command_line::add_arg(desc, arg_disable_dns_checkpoints);
@@ -256,8 +264,7 @@ namespace cryptonote
{
m_testnet = command_line::get_arg(vm, arg_testnet_on);
- auto data_dir_arg = m_testnet ? arg_testnet_data_dir : arg_data_dir;
- m_config_folder = command_line::get_arg(vm, data_dir_arg);
+ m_config_folder = command_line::get_arg(vm, arg_data_dir);
auto data_dir = boost::filesystem::path(m_config_folder);
@@ -279,9 +286,11 @@ namespace cryptonote
set_enforce_dns_checkpoints(command_line::get_arg(vm, arg_dns_checkpoints));
test_drop_download_height(command_line::get_arg(vm, arg_test_drop_download_height));
- m_fluffy_blocks_enabled = m_testnet || get_arg(vm, arg_fluffy_blocks);
+ m_fluffy_blocks_enabled = !get_arg(vm, arg_no_fluffy_blocks);
m_offline = get_arg(vm, arg_offline);
m_disable_dns_checkpoints = get_arg(vm, arg_disable_dns_checkpoints);
+ if (!command_line::is_arg_defaulted(vm, arg_fluffy_blocks))
+ MWARNING(arg_fluffy_blocks.name << " is obsolete, it is now default");
if (command_line::get_arg(vm, arg_test_drop_download) == true)
test_drop_download();
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 429f6b820..ce39aaddf 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -58,8 +58,7 @@ namespace cryptonote
const std::pair<uint8_t, uint64_t> *hard_forks;
};
- extern const command_line::arg_descriptor<std::string> arg_data_dir;
- extern const command_line::arg_descriptor<std::string> arg_testnet_data_dir;
+ extern const command_line::arg_descriptor<std::string, false, true> arg_data_dir;
extern const command_line::arg_descriptor<bool, false> arg_testnet_on;
extern const command_line::arg_descriptor<bool> arg_offline;
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 5f54e93f1..762feb5ee 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -181,7 +181,7 @@ namespace cryptonote
}
size_t tx_size_limit = get_transaction_size_limit(version);
- if (!kept_by_block && blob_size >= tx_size_limit)
+ if (!kept_by_block && blob_size > tx_size_limit)
{
LOG_PRINT_L1("transaction is too big: " << blob_size << " bytes, maximum size: " << tx_size_limit);
tvc.m_verifivation_failed = true;
@@ -1207,7 +1207,7 @@ namespace cryptonote
m_txpool_size = 0;
m_blockchain.for_all_txpool_txes([this, &remove, tx_size_limit](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata*) {
m_txpool_size += meta.blob_size;
- if (meta.blob_size >= tx_size_limit) {
+ if (meta.blob_size > tx_size_limit) {
LOG_PRINT_L1("Transaction " << txid << " is too big (" << meta.blob_size << " bytes), removing it from pool");
remove.insert(txid);
}
diff --git a/src/daemon/command_line_args.h b/src/daemon/command_line_args.h
index ee6167b6a..efbae488c 100644
--- a/src/daemon/command_line_args.h
+++ b/src/daemon/command_line_args.h
@@ -31,20 +31,35 @@
#include "common/command_line.h"
#include "cryptonote_config.h"
+#include "daemonizer/daemonizer.h"
namespace daemon_args
{
std::string const WINDOWS_SERVICE_NAME = "Monero Daemon";
- const command_line::arg_descriptor<std::string> arg_config_file = {
+ const command_line::arg_descriptor<std::string, false, true> arg_config_file = {
"config-file"
, "Specify configuration file"
- , std::string(CRYPTONOTE_NAME ".conf")
+ , (daemonizer::get_default_data_dir() / std::string(CRYPTONOTE_NAME ".conf")).string()
+ , cryptonote::arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet && defaulted)
+ return (daemonizer::get_default_data_dir() / "testnet" /
+ std::string(CRYPTONOTE_NAME ".conf")).string();
+ return val;
+ }
};
- const command_line::arg_descriptor<std::string> arg_log_file = {
+ const command_line::arg_descriptor<std::string, false, true> arg_log_file = {
"log-file"
, "Specify log file"
- , ""
+ , (daemonizer::get_default_data_dir() / std::string(CRYPTONOTE_NAME ".log")).string()
+ , cryptonote::arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet && defaulted)
+ return (daemonizer::get_default_data_dir() / "testnet" /
+ std::string(CRYPTONOTE_NAME ".log")).string();
+ return val;
+ }
};
const command_line::arg_descriptor<std::size_t> arg_max_log_file_size = {
"max-log-file-size"
@@ -76,16 +91,16 @@ namespace daemon_args
, "127.0.0.1"
};
- const command_line::arg_descriptor<std::string> arg_zmq_rpc_bind_port = {
+ const command_line::arg_descriptor<std::string, false, true> arg_zmq_rpc_bind_port = {
"zmq-rpc-bind-port"
- , "Port for ZMQ RPC server to listen on"
- , std::to_string(config::ZMQ_RPC_DEFAULT_PORT)
- };
-
- const command_line::arg_descriptor<std::string> arg_zmq_testnet_rpc_bind_port = {
- "zmq-testnet-rpc-bind-port"
- , "Port for testnet ZMQ RPC server to listen on"
- , std::to_string(config::testnet::ZMQ_RPC_DEFAULT_PORT)
+ , "Port for ZMQ RPC server to listen on"
+ , std::to_string(config::ZMQ_RPC_DEFAULT_PORT)
+ , cryptonote::arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet && defaulted)
+ return std::to_string(config::testnet::ZMQ_RPC_DEFAULT_PORT);
+ return val;
+ }
};
} // namespace daemon_args
diff --git a/src/daemon/core.h b/src/daemon/core.h
index f00dffccc..1ff696bef 100644
--- a/src/daemon/core.h
+++ b/src/daemon/core.h
@@ -69,8 +69,7 @@ public:
std::string get_config_subdir() const
{
bool testnet = command_line::get_arg(m_vm_HACK, cryptonote::arg_testnet_on);
- auto p2p_bind_arg = testnet ? nodetool::arg_testnet_p2p_bind_port : nodetool::arg_p2p_bind_port;
- std::string port = command_line::get_arg(m_vm_HACK, p2p_bind_arg);
+ std::string port = command_line::get_arg(m_vm_HACK, nodetool::arg_p2p_bind_port);
if ((!testnet && port != std::to_string(::config::P2P_DEFAULT_PORT))
|| (testnet && port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
return port;
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp
index 9b15e62ca..8053932fe 100644
--- a/src/daemon/daemon.cpp
+++ b/src/daemon/daemon.cpp
@@ -77,10 +77,10 @@ public:
const auto testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
const auto restricted = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_restricted_rpc);
- const auto main_rpc_port = command_line::get_arg(vm, testnet ? cryptonote::core_rpc_server::arg_testnet_rpc_bind_port : cryptonote::core_rpc_server::arg_rpc_bind_port);
+ const auto main_rpc_port = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
rpcs.emplace_back(new t_rpc{vm, core, p2p, restricted, testnet, main_rpc_port, "core"});
- auto restricted_rpc_port_arg = testnet ? cryptonote::core_rpc_server::arg_testnet_rpc_restricted_bind_port : cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
+ auto restricted_rpc_port_arg = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
if(!command_line::is_arg_defaulted(vm, restricted_rpc_port_arg))
{
auto restricted_rpc_port = command_line::get_arg(vm, restricted_rpc_port_arg);
@@ -101,15 +101,7 @@ t_daemon::t_daemon(
)
: mp_internals{new t_internals{vm}}
{
- bool testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
- if (testnet)
- {
- zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_testnet_rpc_bind_port);
- }
- else
- {
- zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_port);
- }
+ zmq_rpc_bind_port = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_port);
zmq_rpc_bind_address = command_line::get_arg(vm, daemon_args::arg_zmq_rpc_bind_ip);
}
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index 7bac2d3d8..752a92ba4 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -73,26 +73,20 @@ int main(int argc, char const * argv[])
po::options_description core_settings("Settings");
po::positional_options_description positional_options;
{
- bf::path default_data_dir = daemonizer::get_default_data_dir();
- bf::path default_testnet_data_dir = {default_data_dir / "testnet"};
-
// Misc Options
command_line::add_arg(visible_options, command_line::arg_help);
command_line::add_arg(visible_options, command_line::arg_version);
command_line::add_arg(visible_options, daemon_args::arg_os_version);
- bf::path default_conf = default_data_dir / std::string(CRYPTONOTE_NAME ".conf");
- command_line::add_arg(visible_options, daemon_args::arg_config_file, default_conf.string());
+ command_line::add_arg(visible_options, daemon_args::arg_config_file);
// Settings
- bf::path default_log = default_data_dir / std::string(CRYPTONOTE_NAME ".log");
- command_line::add_arg(core_settings, daemon_args::arg_log_file, default_log.string());
+ command_line::add_arg(core_settings, daemon_args::arg_log_file);
command_line::add_arg(core_settings, daemon_args::arg_log_level);
command_line::add_arg(core_settings, daemon_args::arg_max_log_file_size);
command_line::add_arg(core_settings, daemon_args::arg_max_concurrency);
command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_ip);
command_line::add_arg(core_settings, daemon_args::arg_zmq_rpc_bind_port);
- command_line::add_arg(core_settings, daemon_args::arg_zmq_testnet_rpc_bind_port);
daemonizer::init_options(hidden_options, visible_options);
daemonize::t_executor::init_options(core_settings);
@@ -154,10 +148,6 @@ int main(int argc, char const * argv[])
return 0;
}
- bool testnet_mode = command_line::get_arg(vm, cryptonote::arg_testnet_on);
-
- auto data_dir_arg = testnet_mode ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir;
-
// data_dir
// default: e.g. ~/.bitmonero/ or ~/.bitmonero/testnet
// if data-dir argument given:
@@ -166,7 +156,7 @@ int main(int argc, char const * argv[])
// Create data dir if it doesn't exist
boost::filesystem::path data_dir = boost::filesystem::absolute(
- command_line::get_arg(vm, data_dir_arg));
+ command_line::get_arg(vm, cryptonote::arg_data_dir));
// FIXME: not sure on windows implementation default, needs further review
//bf::path relative_path_base = daemonizer::get_relative_path_base(vm);
@@ -226,10 +216,6 @@ int main(int argc, char const * argv[])
const cryptonote::rpc_args::descriptors arg{};
auto rpc_ip_str = command_line::get_arg(vm, arg.rpc_bind_ip);
auto rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
- if (testnet_mode)
- {
- rpc_port_str = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_testnet_rpc_bind_port);
- }
uint32_t rpc_ip;
uint16_t rpc_port;
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp
index 994941168..170b79984 100644
--- a/src/p2p/net_node.cpp
+++ b/src/p2p/net_node.cpp
@@ -34,15 +34,16 @@
namespace nodetool
{
const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"};
- const command_line::arg_descriptor<std::string> arg_p2p_bind_port = {
+ const command_line::arg_descriptor<std::string, false, true> arg_p2p_bind_port = {
"p2p-bind-port"
, "Port for p2p network protocol"
, std::to_string(config::P2P_DEFAULT_PORT)
- };
- const command_line::arg_descriptor<std::string> arg_testnet_p2p_bind_port = {
- "testnet-p2p-bind-port"
- , "Port for testnet p2p network protocol"
- , std::to_string(config::testnet::P2P_DEFAULT_PORT)
+ , cryptonote::arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet && defaulted)
+ return std::to_string(config::testnet::P2P_DEFAULT_PORT);
+ return val;
+ }
};
const command_line::arg_descriptor<uint32_t> arg_p2p_external_port = {"p2p-external-port", "External port for p2p network protocol (if port forwarding used with NAT)", 0};
const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip = {"allow-local-ip", "Allow local ip add to peer list, mostly in debug purposes"};
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 9ebefbca6..54c474665 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -337,8 +337,7 @@ namespace nodetool
const int64_t default_limit_up = 2048;
const int64_t default_limit_down = 8192;
extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ip;
- extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port;
- extern const command_line::arg_descriptor<std::string> arg_testnet_p2p_bind_port;
+ extern const command_line::arg_descriptor<std::string, false, true> arg_p2p_bind_port;
extern const command_line::arg_descriptor<uint32_t> arg_p2p_external_port;
extern const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip;
extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_peer;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index d60f0a13e..c1de21f22 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -75,7 +75,6 @@ namespace nodetool
{
command_line::add_arg(desc, arg_p2p_bind_ip);
command_line::add_arg(desc, arg_p2p_bind_port, false);
- command_line::add_arg(desc, arg_testnet_p2p_bind_port, false);
command_line::add_arg(desc, arg_p2p_external_port);
command_line::add_arg(desc, arg_p2p_allow_local_ip);
command_line::add_arg(desc, arg_p2p_add_peer);
@@ -263,12 +262,8 @@ namespace nodetool
const boost::program_options::variables_map& vm
)
{
- m_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on);
-
- auto p2p_bind_arg = m_testnet ? arg_testnet_p2p_bind_port : arg_p2p_bind_port;
-
m_bind_ip = command_line::get_arg(vm, arg_p2p_bind_ip);
- m_port = command_line::get_arg(vm, p2p_bind_arg);
+ m_port = command_line::get_arg(vm, arg_p2p_bind_port);
m_external_port = command_line::get_arg(vm, arg_p2p_external_port);
m_allow_local_ip = command_line::get_arg(vm, arg_p2p_allow_local_ip);
m_no_igd = command_line::get_arg(vm, arg_no_igd);
@@ -504,8 +499,7 @@ namespace nodetool
}
MDEBUG("Number of seed nodes: " << m_seed_nodes.size());
- auto config_arg = m_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir;
- m_config_folder = command_line::get_arg(vm, config_arg);
+ m_config_folder = command_line::get_arg(vm, cryptonote::arg_data_dir);
if ((!m_testnet && m_port != std::to_string(::config::P2P_DEFAULT_PORT))
|| (m_testnet && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index da2e79dfa..a8d801ac7 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -73,8 +73,6 @@ namespace cryptonote
{
command_line::add_arg(desc, arg_rpc_bind_port);
command_line::add_arg(desc, arg_rpc_restricted_bind_port);
- command_line::add_arg(desc, arg_testnet_rpc_bind_port);
- command_line::add_arg(desc, arg_testnet_rpc_restricted_bind_port);
command_line::add_arg(desc, arg_restricted_rpc);
command_line::add_arg(desc, arg_bootstrap_daemon_address);
command_line::add_arg(desc, arg_bootstrap_daemon_login);
@@ -2075,10 +2073,16 @@ namespace cryptonote
}
//------------------------------------------------------------------------------------------------------------------------------
- const command_line::arg_descriptor<std::string> core_rpc_server::arg_rpc_bind_port = {
+ const command_line::arg_descriptor<std::string, false, true> core_rpc_server::arg_rpc_bind_port = {
"rpc-bind-port"
, "Port for RPC server"
, std::to_string(config::RPC_DEFAULT_PORT)
+ , cryptonote::arg_testnet_on
+ , [](bool testnet, bool defaulted, std::string val) {
+ if (testnet && defaulted)
+ return std::to_string(config::testnet::RPC_DEFAULT_PORT);
+ return val;
+ }
};
const command_line::arg_descriptor<std::string> core_rpc_server::arg_rpc_restricted_bind_port = {
@@ -2087,18 +2091,6 @@ namespace cryptonote
, ""
};
- const command_line::arg_descriptor<std::string> core_rpc_server::arg_testnet_rpc_bind_port = {
- "testnet-rpc-bind-port"
- , "Port for testnet RPC server"
- , std::to_string(config::testnet::RPC_DEFAULT_PORT)
- };
-
- const command_line::arg_descriptor<std::string> core_rpc_server::arg_testnet_rpc_restricted_bind_port = {
- "testnet-rpc-restricted-bind-port"
- , "Port for testnet restricted RPC server"
- , ""
- };
-
const command_line::arg_descriptor<bool> core_rpc_server::arg_restricted_rpc = {
"restricted-rpc"
, "Restrict RPC to view only commands and do not return privacy sensitive data in RPC calls"
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 650e738bd..3c57a6016 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -53,10 +53,8 @@ namespace cryptonote
{
public:
- static const command_line::arg_descriptor<std::string> arg_rpc_bind_port;
+ static const command_line::arg_descriptor<std::string, false, true> arg_rpc_bind_port;
static const command_line::arg_descriptor<std::string> arg_rpc_restricted_bind_port;
- static const command_line::arg_descriptor<std::string> arg_testnet_rpc_bind_port;
- static const command_line::arg_descriptor<std::string> arg_testnet_rpc_restricted_bind_port;
static const command_line::arg_descriptor<bool> arg_restricted_rpc;
static const command_line::arg_descriptor<std::string> arg_bootstrap_daemon_address;
static const command_line::arg_descriptor<std::string> arg_bootstrap_daemon_login;
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 2d8eb97e0..150c6333c 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -639,6 +639,8 @@ bool simple_wallet::change_password(const std::vector<std::string> &args)
// prompts for a new password, pass true to verify the password
const auto pwd_container = default_password_prompter(true);
+ if(!pwd_container)
+ return true;
try
{
@@ -6811,6 +6813,11 @@ int main(int argc, char* argv[])
else
{
tools::signal_handler::install([&w](int type) {
+ if (tools::password_container::is_prompting.load())
+ {
+ // must be prompting for password so return and let the signal stop prompt
+ return;
+ }
#ifdef WIN32
if (type == CTRL_C_EVENT)
#else
diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp
index 8c9340318..f0a1eb5ce 100644
--- a/tests/core_proxy/core_proxy.cpp
+++ b/tests/core_proxy/core_proxy.cpp
@@ -80,8 +80,7 @@ int main(int argc, char* argv[])
po::options_description desc("Allowed options");
- // tools::get_default_data_dir() can't be called during static initialization
- command_line::add_arg(desc, cryptonote::arg_data_dir, tools::get_default_data_dir());
+ command_line::add_arg(desc, cryptonote::arg_data_dir);
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >::init_options(desc);
po::variables_map vm;