aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--README.i18n2
-rw-r--r--README.md52
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp5
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl2
-rw-r--r--src/simplewallet/simplewallet.cpp15
-rw-r--r--src/wallet/api/wallet.cpp15
-rw-r--r--src/wallet/wallet2.cpp4
-rw-r--r--src/wallet/wallet2_api.h1
-rw-r--r--tests/libwallet_api_tests/main.cpp92
11 files changed, 171 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb5e4b1ad..5ac4a2f95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -448,15 +448,11 @@ if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
-find_package(Boost 1.53 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
+find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND)
- die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (1.53 or 1.55+) or the equivalent")
-endif()
-
-if((Boost_MAJOR_VERSION EQUAL 1) AND (Boost_MINOR_VERSION EQUAL 54))
- die("Boost version 1.54 is unsupported due to a bug (see: http://goo.gl/RrCFmA), please install Boost 1.53 or 1.55 and above")
+ die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (1.58) or the equivalent")
endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
diff --git a/README.i18n b/README.i18n
index 2b913f7d8..0c7a010ef 100644
--- a/README.i18n
+++ b/README.i18n
@@ -13,7 +13,7 @@ To update ts files after changing source code:
To add a new language, eg Spanish (ISO code es):
- cp transations/monero.ts transations/monero_es.ts
+ cp translations/monero.ts translations/monero_es.ts
To edit translations for Spanish:
diff --git a/README.md b/README.md
index 14652d0eb..394bee2d6 100644
--- a/README.md
+++ b/README.md
@@ -36,13 +36,19 @@ Monero development can be supported directly through donations.
Both Monero and Bitcoin donations can be made to donate.getmonero.org if using a client that supports the [OpenAlias](https://openalias.org) standard
-The Monero donation address is: 44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A (viewkey: f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501)
+The Monero donation address is: `44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A` (viewkey: `f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501`)
-The Bitcoin donation address is: 1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H
+The Bitcoin donation address is: `1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H`
Core development funding and/or some supporting services are also graciously provided by sponsors:
-[![MyMonero](https://static.getmonero.org/images/sponsors/mymonero.png)](https://mymonero.com) [![Kitware](https://static.getmonero.org/images/sponsors/kitware.png?1)](http://kitware.com) [![Dome9](https://static.getmonero.org/images/sponsors/dome9.png)](http://dome9.com) [![Araxis](https://static.getmonero.org/images/sponsors/araxis.png)](http://araxis.com) [![JetBrains](https://static.getmonero.org/images/sponsors/jetbrains.png)](http://www.jetbrains.com/) [![Navicat](https://static.getmonero.org/images/sponsors/navicat.png)](http://www.navicat.com/)
+[<img width="80" src="https://static.getmonero.org/images/sponsors/mymonero.png"/>](https://mymonero.com)
+[<img width="150" src="https://static.getmonero.org/images/sponsors/kitware.png?1"/>](http://kitware.com)
+[<img width="100" src="https://static.getmonero.org/images/sponsors/dome9.png"/>](http://dome9.com)
+[<img width="150" src="https://static.getmonero.org/images/sponsors/araxis.png"/>](http://araxis.com)
+[<img width="150" src="https://static.getmonero.org/images/sponsors/jetbrains.png"/>](http://www.jetbrains.com/)
+[<img width="150" src="https://static.getmonero.org/images/sponsors/navicat.png"/>](http://www.navicat.com/)
+[<img width="150" src="https://static.getmonero.org/images/sponsors/symas.png"/>](http://www.symas.com/)
There are also several mining pools that kindly donate a portion of their fees, [a list of them can be found on our Bitcointalk post](https://bitcointalk.org/index.php?topic=583449.0).
@@ -54,8 +60,29 @@ See [LICENSE](LICENSE).
### Overview:
-Dependencies: GCC 4.7.3 or later, CMake 3.0.0 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), libevent 2.0 or later, libgtest 1.5 or later, and Boost 1.53 or later (except 1.54, [more details here](http://goo.gl/RrCFmA)), BerkeleyDB 4.8 or later (note: on Ubuntu this means installing libdb-dev and libdb++-dev).
-Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later, bison or yacc
+Dependencies:
+
+* GCC `>=4.7.3`
+* CMake `>=3.0.0`
+* pkg-config
+* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is)
+* libevent `>=2.0`
+* libgtest `>=1.5`
+* Boost `>=1.58`
+* BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev)
+* libunwind (optional, for stack trace on exception)
+* miniupnpc (optional, for NAT punching)
+
+Additional dependencies for statically-linked build:
+
+* ldns `>=1.6.17`
+* expat `>=1.1`
+* bison or yacc
+
+Additional dependencies for building documentation:
+
+* Doxygen
+* graphviz
**Basic Process:**
@@ -100,7 +127,14 @@ Alternatively, it can be built in an easier and more automated fashion using Hom
### On Windows:
-Dependencies: mingw-w64, msys2, CMake 3.0.0 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA)), BerkeleyDB 4.8 or later (note: on Ubuntu this means installing libdb-dev and libdb++-dev).
+Dependencies:
+
+* mingw-w64
+* msys2
+* CMake `>=3.0.0`
+* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is)
+* Boost `>=1.58`
+* BerkeleyDB `>=4.8`
**Preparing the Build Environment**
@@ -189,7 +223,7 @@ To list all available options, run `./bin/bitmonerod --help`. Options can be
specified either on the command line or in a configuration file passed by the
`--config-file` argument. To specify an option in the configuration file, add
a line with the syntax `argumentname=value`, where `argumentname` is the name
-of the argument without any dashes, for example `log-level=1`.
+of the argument without the leading dashes, for example `log-level=1`.
## Internationalization
@@ -211,6 +245,6 @@ TAILS ships with a very restrictive set of firewall rules. Therefore, you need t
## Using readline
-While bitmonerod and simplewallet do not use readline directly, most of the functionality can be obtained by running them via rlwrap. This allows command recall, edit capabilities, etc. It does not give autocompletion without an extra completion file, however. To use rlwrap, simply prepend "rlwrap " to the command line, eg:
-rlwrap bin/simplewallet --wallet-file /path/to/wallet
+While bitmonerod and simplewallet do not use readline directly, most of the functionality can be obtained by running them via rlwrap. This allows command recall, edit capabilities, etc. It does not give autocompletion without an extra completion file, however. To use rlwrap, simply prepend `rlwrap` to the command line, eg:
+`rlwrap bin/simplewallet --wallet-file /path/to/wallet`
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
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index d642534b0..b4bc86f91 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -31,6 +31,7 @@
#include "gtest/gtest.h"
#include "wallet/wallet2_api.h"
+#include "wallet/wallet2.h"
#include "include_base_utils.h"
#include <boost/filesystem.hpp>
@@ -41,6 +42,7 @@
#include <mutex>
#include <thread>
#include <atomic>
+#include <functional>
#include <condition_variable>
@@ -210,6 +212,94 @@ TEST_F(WalletManagerTest, WalletManagerOpensWallet)
std::cout << "** seed: " << wallet2->seed() << std::endl;
}
+
+TEST_F(WalletManagerTest, WalletMaxAmountAsString)
+{
+ LOG_PRINT_L3("max amount: " << Bitmonero::Wallet::displayAmount(
+ Bitmonero::Wallet::maximumAllowedAmount()));
+
+}
+
+TEST_F(WalletManagerTest, WalletAmountFromString)
+{
+ uint64_t amount = Bitmonero::Wallet::amountFromString("18446740");
+ ASSERT_TRUE(amount > 0);
+ amount = Bitmonero::Wallet::amountFromString("11000000000000");
+ ASSERT_FALSE(amount > 0);
+ amount = Bitmonero::Wallet::amountFromString("0.0");
+ ASSERT_FALSE(amount > 0);
+ amount = Bitmonero::Wallet::amountFromString("10.1");
+ ASSERT_TRUE(amount > 0);
+
+}
+
+void open_wallet_helper(Bitmonero::WalletManager *wmgr, Bitmonero::Wallet **wallet, const std::string &pass, std::mutex *mutex)
+{
+ if (mutex)
+ mutex->lock();
+ LOG_PRINT_L3("opening wallet in thread: " << std::this_thread::get_id());
+ *wallet = wmgr->openWallet(WALLET_NAME, pass, true);
+ LOG_PRINT_L3("wallet address: " << (*wallet)->address());
+ LOG_PRINT_L3("wallet status: " << (*wallet)->status());
+ LOG_PRINT_L3("closing wallet in thread: " << std::this_thread::get_id());
+ if (mutex)
+ mutex->unlock();
+}
+
+
+
+
+//TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopenMultiThreaded)
+//{
+// // create password protected wallet
+// std::string wallet_pass = "password";
+// std::string wrong_wallet_pass = "1111";
+// Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, true);
+// std::string seed1 = wallet1->seed();
+// ASSERT_TRUE(wmgr->closeWallet(wallet1));
+
+// Bitmonero::Wallet *wallet2 = nullptr;
+// Bitmonero::Wallet *wallet3 = nullptr;
+
+// std::mutex mutex;
+// std::thread thread1(open_wallet, wmgr, &wallet2, wrong_wallet_pass, &mutex);
+// thread1.join();
+// ASSERT_TRUE(wallet2->status() != Bitmonero::Wallet::Status_Ok);
+// ASSERT_TRUE(wmgr->closeWallet(wallet2));
+
+// std::thread thread2(open_wallet, wmgr, &wallet3, wallet_pass, &mutex);
+// thread2.join();
+
+// ASSERT_TRUE(wallet3->status() == Bitmonero::Wallet::Status_Ok);
+// ASSERT_TRUE(wmgr->closeWallet(wallet3));
+//}
+
+
+TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
+{
+ // create password protected wallet
+ std::string wallet_pass = "password";
+ std::string wrong_wallet_pass = "1111";
+ Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, wallet_pass, WALLET_LANG, true);
+ std::string seed1 = wallet1->seed();
+ ASSERT_TRUE(wmgr->closeWallet(wallet1));
+
+ Bitmonero::Wallet *wallet2 = nullptr;
+ Bitmonero::Wallet *wallet3 = nullptr;
+ std::mutex mutex;
+
+ open_wallet_helper(wmgr, &wallet2, wrong_wallet_pass, nullptr);
+ ASSERT_TRUE(wallet2 != nullptr);
+ ASSERT_TRUE(wallet2->status() != Bitmonero::Wallet::Status_Ok);
+ ASSERT_TRUE(wmgr->closeWallet(wallet2));
+
+ open_wallet_helper(wmgr, &wallet3, wallet_pass, nullptr);
+ ASSERT_TRUE(wallet3 != nullptr);
+ ASSERT_TRUE(wallet3->status() == Bitmonero::Wallet::Status_Ok);
+ ASSERT_TRUE(wmgr->closeWallet(wallet3));
+}
+
+
TEST_F(WalletManagerTest, WalletManagerStoresWallet)
{
@@ -239,7 +329,6 @@ TEST_F(WalletManagerTest, WalletManagerMovesWallet)
}
-
TEST_F(WalletManagerTest, WalletManagerChangesPassword)
{
Bitmonero::Wallet * wallet1 = wmgr->createWallet(WALLET_NAME, WALLET_PASS, WALLET_LANG);
@@ -819,6 +908,7 @@ TEST_F(WalletTest2, WalletCallbackReceived)
}
+
int main(int argc, char** argv)
{