diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 75 | ||||
-rw-r--r-- | src/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/simplewallet/password_container.cpp | 85 | ||||
-rw-r--r-- | src/simplewallet/password_container.h | 13 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 60 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.h | 1 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 3 |
8 files changed, 155 insertions, 96 deletions
diff --git a/.travis.yml b/.travis.yml index ba4df1cc9..1e11d543c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ dist: trusty language: cpp compiler: - gcc +- clang addons: apt: packages: @@ -11,6 +12,7 @@ addons: - doxygen - g++ - gcc + - clang - graphviz - libboost1.55-all-dev - libdb++-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 63d39ca75..90d06c12d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,13 +73,14 @@ if (NOT "${ARCH}" STREQUAL "") endif() if(WIN32 OR ARM7 OR ARM6) - set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + set(OPT_FLAGS_RELEASE "-O2") else() - set(CMAKE_C_FLAGS_RELEASE "-Ofast -DNDEBUG -Wno-unused-variable") - set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -DNDEBUG -Wno-unused-variable") + set(OPT_FLAGS_RELEASE "-Ofast") endif() +set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${OPT_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${OPT_FLAGS_RELEASE}") + # set this to 0 if per-block checkpoint needs to be disabled set(PER_BLOCK_CHECKPOINT 1) @@ -261,17 +262,10 @@ option(STACK_TRACE "Install a hook that dumps stack on exception" ${DEFAULT_STAC if(STACK_TRACE) message(STATUS "Stack trace on exception enabled") - # Don't set CMAKE_*_FLAGS directly or add_definitions, because this flag must - # not be set for tests targets (TODO: per-target logic into nested CMakeLists) - set(STACK_TRACE_C_FLAG "-DSTACK_TRACE") - if (STATIC) - set(STACK_TRACE_LINK_FLAG "-Wl,--wrap=__cxa_throw") - endif() else() message(STATUS "Stack trace on exception disabled") endif() - if (UNIX AND NOT APPLE) # Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -309,8 +303,8 @@ link_directories(${LIBUNWIND_LIBRARY_DIRS}) if(MSVC) add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") - # set(COMMON_C_FLAGS "${COMMON_C_FLAGS} /Dinline=__inline") - set(COMMON_EXE_LINKER_FLAGS "${COMMON_EXE_LINKER_FLAGS} /STACK:10485760") + # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760") if(STATIC) foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE) string(REPLACE "/MD" "/MT" ${VAR} "${${VAR}}") @@ -329,7 +323,7 @@ else() set(ARCH_FLAG "-march=${ARCH}") endif() endif() - set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized") + set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized") if(NOT MINGW) set(WARNINGS_AS_ERRORS_FLAG "-Werror") endif() @@ -348,7 +342,7 @@ else() include_directories(SYSTEM src/platform/mingw) # mingw doesn't support LTO (multiple definition errors at link time) set(USE_LTO_DEFAULT false) - set(COMMON_EXE_LINKER_FLAGS "${COMMON_EXE_LINKER_FLAGS} -Wl,--stack,10485760") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,10485760") if(NOT BUILD_64) add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501) endif() @@ -362,20 +356,20 @@ else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() - set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") # With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that # is fixed in the code (Issue #847), force compiler to be conservative. - set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -fno-strict-aliasing") - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -fno-strict-aliasing") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") option(NO_AES "Explicitly disable AES support" ${NO_AES}) if(NOT NO_AES AND NOT (ARM6 OR ARM7)) message(STATUS "AES support enabled") - set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -maes") - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -maes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") elseif(ARM7 OR ARM6) message(STATUS "AES support disabled (not available on ARM)") else() @@ -384,18 +378,18 @@ else() if(ARM6) message(STATUS "Setting ARM6 C and C++ flags") - set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -mfpu=vfp -mfloat-abi=hard") - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -mfpu=vfp -mfloat-abi=hard") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp -mfloat-abi=hard") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfp -mfloat-abi=hard") endif() if(ARM7) message(STATUS "Setting ARM7 C and C++ flags") - set(COMMON_C_FLAGS "${COMMON_C_FLAGS} -O2 -mfloat-abi=hard") - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -O2 -mfloat-abi=hard") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard") endif() if(APPLE) - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0") endif() if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)) set(DEBUG_FLAGS "-g3 -Og") @@ -413,8 +407,8 @@ else() set(USE_LTO false) # explicitly define stdlib for older versions of clang if(CMAKE_C_COMPILER_VERSION VERSION_LESS 3.7) - set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -stdlib=libc++") - set(COMMON_EXE_LINKER_FLAGS "${COMMON_EXE_LINKER_FLAGS} -stdlib=libc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") endif() endif() @@ -437,7 +431,7 @@ else() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}") if(STATIC AND NOT APPLE AND NOT FREEBSD AND NOT OPENBSD) - set(COMMON_EXE_LINKER_FLAGS "${COMMON_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif() endif() @@ -477,31 +471,28 @@ endif() list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) -if(CMAKE_C_COMPILER_ID STREQUAL "Clang") - if(NOT MINGW AND NOT APPLE) - find_library(ATOMIC atomic) - list(APPEND EXTRA_LIBRARIES ${ATOMIC}) - endif() +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ARCH_WIDTH EQUAL "32") + find_library(ATOMIC atomic) + list(APPEND EXTRA_LIBRARIES ${ATOMIC}) endif() include(version.cmake) -# When building the following sources treat warnings as errors, install throw wrapper -set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} ${WARNINGS_AS_ERRORS_FLAG} ${STACK_TRACE_C_FLAG}") -set(CMAKE_CXX_FLAGS "${COMMON_CXX_FLAGS} ${WARNINGS_AS_ERRORS_FLAG} ${STACK_TRACE_C_FLAG}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_EXE_LINKER_FLAGS} ${STACK_TRACE_LINK_FLAG}") +function (treat_warnings_as_errors dirs) + foreach(dir ${ARGV}) + set_property(DIRECTORY ${dir} + APPEND PROPERTY COMPILE_FLAGS "-Werror") + endforeach() +endfunction() add_subdirectory(contrib) add_subdirectory(src) +treat_warnings_as_errors(contrib src) option(BUILD_TESTS "Build tests." OFF) if(BUILD_TESTS) - # When building tests, don't add some of the flags added to source build - set(CMAKE_C_FLAGS "${COMMON_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${COMMON_CXX_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${COMMON_CXX_FLAGS}") add_subdirectory(tests) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2349744d..8fa617aff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,17 @@ function (bitmonero_install_headers subdir) COMPONENT development) endfunction () +function (enable_stack_trace target) + if(STACK_TRACE) + set_property(TARGET ${target} + APPEND PROPERTY COMPILER_DEFINITIONS "-DSTACK_TRACE") + if (STATIC) + set_property(TARGET "${target}" + APPEND PROPERTY LINK_FLAGS "-Wl,--wrap=__cxa_throw") + endif() + endif() +endfunction() + function (bitmonero_add_executable name) source_group("${name}" FILES @@ -63,6 +74,7 @@ function (bitmonero_add_executable name) set_property(TARGET "${name}" PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + enable_stack_trace("${name}") endfunction () function (bitmonero_add_library name) diff --git a/src/simplewallet/password_container.cpp b/src/simplewallet/password_container.cpp index 638322be7..480d132e7 100644 --- a/src/simplewallet/password_container.cpp +++ b/src/simplewallet/password_container.cpp @@ -48,24 +48,33 @@ namespace tools { bool is_cin_tty(); } - + // deleted via private member password_container::password_container() - : m_empty(true) + : m_empty(true),m_verify(true) { + + } + password_container::password_container(bool verify) + : m_empty(true),m_verify(verify) + { + } password_container::password_container(std::string&& password) : m_empty(false) , m_password(std::move(password)) + , m_verify(false) { + } + password_container::password_container(password_container&& rhs) : m_empty(std::move(rhs.m_empty)) , m_password(std::move(rhs.m_password)) + , m_verify(std::move(rhs.m_verify)) { } - password_container::~password_container() { clear(); @@ -88,9 +97,7 @@ namespace tools bool r; if (is_cin_tty()) { - if (message) - std::cout << message << ": "; - r = read_from_tty(); + r = read_from_tty_double_check(message); } else { @@ -132,6 +139,43 @@ namespace tools return true; } +bool password_container::read_from_tty_double_check(const char *message) { + std::string pass1; + std::string pass2; + bool match=false; + bool doNotVerifyEntry=false; + do{ + if (message) + std::cout << message <<": "; + if (!password_container::read_from_tty(pass1)) + return false; + if (m_verify==true){//double check password; + if (message) + std::cout << message << ": "; + if (!password_container::read_from_tty(pass2)) + return false; + if(pass1!=pass2){ //new password entered did not match + + std::cout << "Passwords do not match" << std::endl; + pass1=""; + pass2=""; + match=false; + } + else{//new password matches + match=true; + } + } + else + doNotVerifyEntry=true; //do not verify + //No need to verify password entered at this point in the code + + }while(match==false && doNotVerifyEntry==false); + + m_password=pass1; + return true; + } + + #if defined(_WIN32) namespace @@ -142,7 +186,7 @@ namespace tools } } - bool password_container::read_from_tty() + bool password_container::read_from_tty(std::string & pass) { const char BACKSPACE = 8; @@ -154,8 +198,8 @@ namespace tools ::SetConsoleMode(h_cin, mode_new); bool r = true; - m_password.reserve(max_password_size); - while (m_password.size() < max_password_size) + pass.reserve(max_password_size); + while (pass.size() < max_password_size) { DWORD read; char ch; @@ -172,16 +216,16 @@ namespace tools } else if (ch == BACKSPACE) { - if (!m_password.empty()) + if (!pass.empty()) { - m_password.back() = '\0'; - m_password.resize(m_password.size() - 1); + pass.back() = '\0'; + pass.resize(pass.size() - 1); std::cout << "\b \b"; } } else { - m_password.push_back(ch); + pass.push_back(ch); std::cout << '*'; } } @@ -217,13 +261,12 @@ namespace tools return ch; } } - - bool password_container::read_from_tty() + bool password_container::read_from_tty(std::string &aPass) { const char BACKSPACE = 127; - m_password.reserve(max_password_size); - while (m_password.size() < max_password_size) + aPass.reserve(max_password_size); + while (aPass.size() < max_password_size) { int ch = getch(); if (EOF == ch) @@ -237,16 +280,16 @@ namespace tools } else if (ch == BACKSPACE) { - if (!m_password.empty()) + if (!aPass.empty()) { - m_password.back() = '\0'; - m_password.resize(m_password.size() - 1); + aPass.back() = '\0'; + aPass.resize(aPass.size() - 1); std::cout << "\b \b"; } } else { - m_password.push_back(ch); + aPass.push_back(ch); std::cout << '*'; } } diff --git a/src/simplewallet/password_container.h b/src/simplewallet/password_container.h index 64567978d..62f43aa37 100644 --- a/src/simplewallet/password_container.h +++ b/src/simplewallet/password_container.h @@ -31,6 +31,7 @@ #pragma once #include <string> +#include <boost/program_options/variables_map.hpp> namespace tools { @@ -38,10 +39,9 @@ namespace tools { public: static const size_t max_password_size = 1024; - - password_container(); - password_container(std::string&& password); + password_container(bool verify); password_container(password_container&& rhs); + password_container(std::string&& password); ~password_container(); void clear(); @@ -51,11 +51,14 @@ namespace tools bool read_password(const char *message = "password"); private: + //delete constructor with no parameters + password_container(); bool read_from_file(); - bool read_from_tty(); + bool read_from_tty(std::string & pass); + bool read_from_tty_double_check(const char *message); - private: bool m_empty; std::string m_password; + bool m_verify; }; } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 8d7fc1510..c4d0fcc56 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -33,7 +33,6 @@ * * \brief Source file that defines simple_wallet class. */ - #include <thread> #include <iostream> #include <sstream> @@ -347,7 +346,8 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s fail_msg_writer() << tr("wallet is non-deterministic and has no seed"); return true; } - tools::password_container pwd_container; + + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(); if (!success) { @@ -379,7 +379,7 @@ bool simple_wallet::set_always_confirm_transfers(const std::vector<std::string> fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); return true; } - tools::password_container pwd_container; + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(); if (!success) { @@ -408,7 +408,8 @@ bool simple_wallet::set_store_tx_info(const std::vector<std::string> &args/* = s fail_msg_writer() << tr("wallet is watch-only and cannot transfer"); return true; } - tools::password_container pwd_container; + + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(); if (!success) { @@ -452,8 +453,9 @@ bool simple_wallet::set_default_mixin(const std::vector<std::string> &args/* = s } if (mixin == 0) mixin = DEFAULT_MIX; + + tools::password_container pwd_container(m_wallet_file.empty()); - tools::password_container pwd_container; success = pwd_container.read_password(); if (!success) { @@ -514,8 +516,8 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a return true; } } - - tools::password_container pwd_container; + + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(); if (!success) { @@ -549,9 +551,10 @@ bool simple_wallet::set_default_fee_multiplier(const std::vector<std::string> &a bool simple_wallet::set_auto_refresh(const std::vector<std::string> &args/* = std::vector<std::string>()*/) { - bool success = false; - tools::password_container pwd_container; - success = pwd_container.read_password(); + + tools::password_container pwd_container(m_wallet_file.empty()); + + bool success = pwd_container.read_password(); if (!success) { fail_msg_writer() << tr("failed to read wallet password"); @@ -586,8 +589,8 @@ bool simple_wallet::set_refresh_type(const std::vector<std::string> &args/* = st { return true; } - - tools::password_container pwd_container; + + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(); if (!success) { @@ -854,7 +857,7 @@ bool simple_wallet::ask_wallet_create_if_needed() bool r; if(keys_file_exists) { - m_wallet_file = wallet_path; + m_wallet_file=wallet_path; r = true; }else { @@ -889,7 +892,7 @@ void simple_wallet::print_seed(std::string seed) } //---------------------------------------------------------------------------------------------------- -static bool get_password(const boost::program_options::variables_map& vm, bool allow_entry, tools::password_container &pwd_container) +bool simple_wallet::get_password(const boost::program_options::variables_map& vm, bool allow_entry, tools::password_container &pwd_container) { // has_arg returns true even when the parameter is not passed ?? const std::string gfj = command_line::get_arg(vm, arg_generate_from_json); @@ -930,6 +933,8 @@ static bool get_password(const boost::program_options::variables_map& vm, bool a if (allow_entry) { + //vm is already part of the password container class. just need to check vm for an already existing wallet + //here need to pass in variable map. This will indicate if the wallet already exists to the read password function bool r = pwd_container.read_password(); if (!r) { @@ -1077,7 +1082,7 @@ bool simple_wallet::generate_from_json(const boost::program_options::variables_m } } - m_wallet_file = field_filename; + m_wallet_file=field_filename; bool was_deprecated_wallet = m_restore_deterministic_wallet && ((old_language == crypto::ElectrumWords::old_language_name) || crypto::ElectrumWords::get_is_old_style_seed(m_electrum_seed)); @@ -1215,9 +1220,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) } } catch (const std::exception &e) { } - - tools::password_container pwd_container; - if (!get_password(vm, true, pwd_container)) + tools::password_container pwd_container(m_wallet_file.empty()); //m_wallet_file will be empty at this point for new wallets + if (!cryptonote::simple_wallet::get_password(vm, true, pwd_container)) return false; if (!m_generate_new.empty() || m_restore_deterministic_wallet || !m_generate_from_view_key.empty() || !m_generate_from_keys.empty() || !m_generate_from_json.empty()) @@ -1303,7 +1307,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) } crypto::secret_key viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data()); - m_wallet_file = m_generate_from_view_key; + m_wallet_file=m_generate_from_view_key; // check the view key matches the given address crypto::public_key pkey; @@ -1370,7 +1374,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) } crypto::secret_key viewkey = *reinterpret_cast<const crypto::secret_key*>(viewkey_data.data()); - m_wallet_file = m_generate_from_keys; + m_wallet_file=m_generate_from_keys; // check the spend and view keys match the given address crypto::public_key pkey; @@ -1532,7 +1536,8 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string return false; } - m_wallet_file = wallet_file; + + m_wallet_file=wallet_file; m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); @@ -1591,7 +1596,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string& password, const cryptonote::account_public_address& address, const crypto::secret_key& viewkey, bool testnet) { - m_wallet_file = wallet_file; + m_wallet_file=wallet_file; m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); @@ -1619,7 +1624,7 @@ bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string bool simple_wallet::new_wallet(const std::string &wallet_file, const std::string& password, const cryptonote::account_public_address& address, const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool testnet) { - m_wallet_file = wallet_file; + m_wallet_file=wallet_file; m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); @@ -1651,7 +1656,7 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa return false; } - m_wallet_file = wallet_file; + m_wallet_file=wallet_file; m_wallet.reset(new tools::wallet2(testnet)); m_wallet->callback(this); @@ -1757,7 +1762,7 @@ bool simple_wallet::save(const std::vector<std::string> &args) bool simple_wallet::save_watch_only(const std::vector<std::string> &args/* = std::vector<std::string>()*/) { bool success = false; - tools::password_container pwd_container; + tools::password_container pwd_container(m_wallet_file.empty()); success = pwd_container.read_password(tr("Password for the new watch-only wallet")); if (!success) @@ -3746,8 +3751,9 @@ int main(int argc, char* argv[]) bool testnet = command_line::get_arg(vm, arg_testnet); bool restricted = command_line::get_arg(vm, arg_restricted); std::string wallet_file = command_line::get_arg(vm, arg_wallet_file); - tools::password_container pwd_container; - if (!get_password(vm, false, pwd_container)) + + tools::password_container pwd_container(wallet_file.empty()); + if (!cryptonote::simple_wallet::get_password(vm, false, pwd_container)) return 1; std::string daemon_address = command_line::get_arg(vm, arg_daemon_address); std::string daemon_host = command_line::get_arg(vm, arg_daemon_host); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 038dd2b35..6c766a32d 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -58,6 +58,7 @@ namespace cryptonote class simple_wallet : public tools::i_wallet2_callback { public: + static bool get_password(const boost::program_options::variables_map& vm, bool allow_entry, tools::password_container &pwd_container); static const char *tr(const char *str) { return i18n_translate(str, "cryptonote::simple_wallet"); } public: diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 43dedaf82..892f6e4bf 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3369,7 +3369,8 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag std::vector<const crypto::public_key*> pkeys; pkeys.push_back(&pkey); THROW_WALLET_EXCEPTION_IF(!crypto::check_ring_signature((const crypto::hash&)key_image, key_image, pkeys, &signature), - error::wallet_internal_error, "Signature check failed: key image " + epee::string_tools::pod_to_hex(key_image) + error::wallet_internal_error, "Signature check failed: input " + boost::lexical_cast<std::string>(n) + "/" + + boost::lexical_cast<std::string>(signed_key_images.size()) + ", key image " + epee::string_tools::pod_to_hex(key_image) + ", signature " + epee::string_tools::pod_to_hex(signature) + ", pubkey " + epee::string_tools::pod_to_hex(*pkeys[0])); req.key_images.push_back(epee::string_tools::pod_to_hex(key_image)); |