diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 5 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 15 | ||||
-rw-r--r-- | src/wallet/api/wallet.cpp | 15 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet2_api.h | 1 |
7 files changed, 34 insertions, 10 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fa617aff..dfa31aa72 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,7 @@ endfunction () function (enable_stack_trace target) if(STACK_TRACE) set_property(TARGET ${target} - APPEND PROPERTY COMPILER_DEFINITIONS "-DSTACK_TRACE") + APPEND PROPERTY COMPILE_DEFINITIONS "STACK_TRACE") if (STATIC) set_property(TARGET "${target}" APPEND PROPERTY LINK_FLAGS "-Wl,--wrap=__cxa_throw") diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 25b750b1d..26748aceb 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -957,7 +957,10 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- void core::set_target_blockchain_height(uint64_t target_blockchain_height) { - m_target_blockchain_height = target_blockchain_height; + if (target_blockchain_height > m_target_blockchain_height) + { + m_target_blockchain_height = target_blockchain_height; + } } //----------------------------------------------------------------------------------------------- uint64_t core::get_target_blockchain_height() const diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 9f0ea0e83..6f095a76f 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -263,7 +263,7 @@ namespace cryptonote if(context.m_state == cryptonote_connection_context::state_synchronizing) return true; - if(m_core.have_block(hshd.top_id)) + if(m_core.have_block(hshd.top_id) && !(hshd.current_height < m_core.get_target_blockchain_height())) { context.m_state = cryptonote_connection_context::state_normal; if(is_inital) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3f5297dfe..1840e54c9 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -76,6 +76,13 @@ typedef cryptonote::simple_wallet sw; #define DEFAULT_MIX 4 +// workaround for a suspected bug in pthread/kernel on MacOS X +#ifdef __APPLE__ +#define DEFAULT_MAX_CONCURRENCY 1 +#else +#define DEFAULT_MAX_CONCURRENCY 0 +#endif + #define LOCK_IDLE_SCOPE() \ bool auto_refresh_enabled = m_auto_refresh_enabled.load(std::memory_order_relaxed); \ m_auto_refresh_enabled.store(false, std::memory_order_relaxed); \ @@ -95,7 +102,7 @@ typedef cryptonote::simple_wallet sw; namespace { const command_line::arg_descriptor<std::string> arg_wallet_file = {"wallet-file", sw::tr("Use wallet <arg>"), ""}; - const command_line::arg_descriptor<std::string> arg_generate_new_wallet = {"generate-new-wallet", sw::tr("Generate new wallet and save it to <arg> or <address>.wallet by default"), ""}; + const command_line::arg_descriptor<std::string> arg_generate_new_wallet = {"generate-new-wallet", sw::tr("Generate new wallet and save it to <arg>"), ""}; const command_line::arg_descriptor<std::string> arg_generate_from_view_key = {"generate-from-view-key", sw::tr("Generate incoming-only wallet from view key"), ""}; const command_line::arg_descriptor<std::string> arg_generate_from_keys = {"generate-from-keys", sw::tr("Generate wallet from private keys"), ""}; const command_line::arg_descriptor<std::string> arg_generate_from_json = {"generate-from-json", sw::tr("Generate wallet from JSON format file"), ""}; @@ -108,7 +115,7 @@ namespace const command_line::arg_descriptor<bool> arg_non_deterministic = {"non-deterministic", sw::tr("Create non-deterministic view and spend keys"), false}; const command_line::arg_descriptor<int> arg_daemon_port = {"daemon-port", sw::tr("Use daemon instance at port <arg> instead of 18081"), 0}; const command_line::arg_descriptor<uint32_t> arg_log_level = {"log-level", "", LOG_LEVEL_0}; - const command_line::arg_descriptor<uint32_t> arg_max_concurrency = {"max-concurrency", "Max number of threads to use for a parallel job", 0}; + const command_line::arg_descriptor<uint32_t> arg_max_concurrency = {"max-concurrency", "Max number of threads to use for a parallel job", DEFAULT_MAX_CONCURRENCY}; const command_line::arg_descriptor<std::string> arg_log_file = {"log-file", sw::tr("Specify log file"), ""}; const command_line::arg_descriptor<bool> arg_testnet = {"testnet", sw::tr("For testnet. Daemon must also be launched with --testnet flag"), false}; const command_line::arg_descriptor<bool> arg_restricted = {"restricted-rpc", sw::tr("Restricts RPC to view-only commands"), false}; @@ -1701,7 +1708,9 @@ bool simple_wallet::open_wallet(const string &wallet_file, const std::string& pa catch (const std::exception& e) { fail_msg_writer() << tr("failed to load wallet: ") << e.what(); - fail_msg_writer() << boost::format(tr("You may want to remove the file \"%s\" and try again")) % wallet_file; + // only suggest removing cache if the password was actually correct + if (m_wallet->verify_password(password)) + fail_msg_writer() << boost::format(tr("You may want to remove the file \"%s\" and try again")) % wallet_file; return false; } diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 4b97e2f1d..b3ee4112b 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -129,7 +129,7 @@ string Wallet::displayAmount(uint64_t amount) uint64_t Wallet::amountFromString(const string &amount) { - uint64_t result; + uint64_t result = 0; cryptonote::parse_amount(result, amount); return result; } @@ -154,6 +154,11 @@ bool Wallet::paymentIdValid(const string &paiment_id) return tools::wallet2::parse_short_payment_id(paiment_id, pid); } +uint64_t Wallet::maximumAllowedAmount() +{ + return std::numeric_limits<uint64_t>::max(); +} + ///////////////////////// WalletImpl implementation //////////////////////// WalletImpl::WalletImpl(bool testnet) @@ -267,16 +272,18 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed) bool WalletImpl::close() { - clearStatus(); + bool result = false; try { - // LOG_PRINT_L0("Calling wallet::store..."); - m_wallet->store(); + // do not store wallet with invalid status + if (status() == Status_Ok) + m_wallet->store(); // LOG_PRINT_L0("wallet::store done"); // LOG_PRINT_L0("Calling wallet::stop..."); m_wallet->stop(); // LOG_PRINT_L0("wallet::stop done"); result = true; + clearStatus(); } catch (const std::exception &e) { m_status = Status_Error; m_errorString = e.what(); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 922409519..8502353ed 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -28,6 +28,7 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers +#include <random> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> @@ -3502,6 +3503,9 @@ uint64_t wallet2::import_key_images(const std::vector<std::pair<crypto::key_imag req.key_images.push_back(epee::string_tools::pod_to_hex(key_image)); } + for (size_t n = 0; n < signed_key_images.size(); ++n) + m_transfers[n].m_key_image = signed_key_images[n].first; + m_daemon_rpc_mutex.lock(); bool r = epee::net_utils::invoke_http_json_remote_command2(m_daemon_address + "/is_key_image_spent", req, daemon_resp, m_http_client, 200000); m_daemon_rpc_mutex.unlock(); diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h index 2c5836573..e880b1c68 100644 --- a/src/wallet/wallet2_api.h +++ b/src/wallet/wallet2_api.h @@ -216,6 +216,7 @@ struct Wallet static uint64_t amountFromDouble(double amount); static std::string genPaymentId(); static bool paymentIdValid(const std::string &paiment_id); + static uint64_t maximumAllowedAmount(); /** * @brief refresh - refreshes the wallet, updating transactions from daemon |