diff options
476 files changed, 2041 insertions, 897 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a0508adfd..730a0f875 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/CMakeLists_IOS.txt b/CMakeLists_IOS.txt index 4dab94cb3..9273af19f 100644 --- a/CMakeLists_IOS.txt +++ b/CMakeLists_IOS.txt @@ -1,4 +1,4 @@ -# Portions Copyright (c) 2017, The Monero Project +# Portions Copyright (c) 2017-2018, The Monero Project # This file is based off of the https://code.google.com/archive/p/ios-cmake/ # It has been altered for Monero iOS development # diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 78537f775..f794c0d5e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ the previous paragraph is here. ## License Copyright (c) 2009-2015 Pieter Hintjens. -Copyright (c) 2017 The Monero Project. +Copyright (c) 2017-2018 The Monero Project. This Specification is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -1,4 +1,4 @@ -Copyright (c) 2014-2017, The Monero Project +Copyright (c) 2014-2018, The Monero Project All rights reserved. @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # @@ -1,6 +1,6 @@ # Monero -Copyright (c) 2014-2017 The Monero Project. +Copyright (c) 2014-2018 The Monero Project. Portions Copyright (c) 2012-2013 The Cryptonote developers. ## Development resources @@ -251,7 +251,7 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch ( ``` git clone https://github.com/monero-project/monero.git cd monero - git checkout tags/v0.11.0.0 + git checkout tags/v0.11.1.0 ``` * Build: ``` diff --git a/cmake/32-bit-toolchain.cmake b/cmake/32-bit-toolchain.cmake index 2f5b87402..fe9aa483f 100644 --- a/cmake/32-bit-toolchain.cmake +++ b/cmake/32-bit-toolchain.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/cmake/64-bit-toolchain.cmake b/cmake/64-bit-toolchain.cmake index 0334aef73..20b568c71 100644 --- a/cmake/64-bit-toolchain.cmake +++ b/cmake/64-bit-toolchain.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index 2e8b444fb..a392d59ca 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are diff --git a/cmake/GenVersion.cmake b/cmake/GenVersion.cmake index 45a97cd20..289115175 100644 --- a/cmake/GenVersion.cmake +++ b/cmake/GenVersion.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/cmake/Version.cmake b/cmake/Version.cmake index fb636c4ff..63b2a6790 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/cmake/test-static-assert.c b/cmake/test-static-assert.c index 2ae34757a..28a80a972 100644 --- a/cmake/test-static-assert.c +++ b/cmake/test-static-assert.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/cmake/test-static-assert.cpp b/cmake/test-static-assert.cpp index 2ae34757a..28a80a972 100644 --- a/cmake/test-static-assert.cpp +++ b/cmake/test-static-assert.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index e7c501ed2..990a05c08 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/contrib/epee/CMakeLists.txt b/contrib/epee/CMakeLists.txt index e7ff6001b..035b24b36 100644 --- a/contrib/epee/CMakeLists.txt +++ b/contrib/epee/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/contrib/epee/include/hex.h b/contrib/epee/include/hex.h index f8d6be048..e960da1d2 100644 --- a/contrib/epee/include/hex.h +++ b/contrib/epee/include/hex.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/include/memwipe.h b/contrib/epee/include/memwipe.h index c3b4ce8ab..0d8f491b7 100644 --- a/contrib/epee/include/memwipe.h +++ b/contrib/epee/include/memwipe.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // @@ -67,18 +67,14 @@ namespace tools { } }; + template<typename T> + T& unwrap(scrubbed<T>& src) { return src; } + + template<typename T> + const T& unwrap(scrubbed<T> const& src) { return src; } + template <class T, size_t N> using scrubbed_arr = scrubbed<std::array<T, N>>; } // namespace tools -// Partial specialization for std::is_pod<tools::scrubbed<T>> so that it can -// pretend to be the containted type in those contexts. -namespace std -{ - template<class t_scrubbee> - struct is_pod<tools::scrubbed<t_scrubbee>> { - static const bool value = is_pod<t_scrubbee>::value; - }; -} - #endif // __cplusplus diff --git a/contrib/epee/include/net/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp index 16de469a7..095e747a5 100644 --- a/contrib/epee/include/net/connection_basic.hpp +++ b/contrib/epee/include/net/connection_basic.hpp @@ -8,7 +8,7 @@ // ! (how ever if in some wonderful juristdictions that is not the case, then why not make another sub-class withat that members and licence it as epee part) // ! Working on above premise, IF this is valid in your juristdictions, then consider this code as released as: -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/include/net/http_auth.h b/contrib/epee/include/net/http_auth.h index 71f56b570..4324c41fd 100644 --- a/contrib/epee/include/net/http_auth.h +++ b/contrib/epee/include/net/http_auth.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index 5b825cef9..de270bfd0 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -77,6 +77,8 @@ class async_protocol_handler_config levin_commands_handler<t_connection_context>* m_pcommands_handler; void (*m_pcommands_handler_destroy)(levin_commands_handler<t_connection_context>*); + void delete_connections (size_t count, bool incoming); + public: typedef t_connection_context connection_context; uint64_t m_max_packet_size; @@ -101,6 +103,7 @@ public: {} ~async_protocol_handler_config() { set_handler(NULL, NULL); } void del_out_connections(size_t count); + void del_in_connections(size_t count); }; @@ -731,41 +734,50 @@ void async_protocol_handler_config<t_connection_context>::del_connection(async_p } //------------------------------------------------------------------------------------------ template<class t_connection_context> +void async_protocol_handler_config<t_connection_context>::delete_connections(size_t count, bool incoming) +{ + std::vector <boost::uuids::uuid> connections; + CRITICAL_REGION_BEGIN(m_connects_lock); + for (auto& c: m_connects) + { + if (c.second->m_connection_context.m_is_income == incoming) + connections.push_back(c.first); + } + + // close random connections from the provided set + // TODO or better just keep removing random elements (performance) + unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); + shuffle(connections.begin(), connections.end(), std::default_random_engine(seed)); + while (count > 0 && connections.size() > 0) + { + try + { + auto i = connections.end() - 1; + async_protocol_handler<t_connection_context> *conn = m_connects.at(*i); + del_connection(conn); + close(*i); + connections.erase(i); + } + catch (const std::out_of_range &e) + { + MWARNING("Connection not found in m_connects, continuing"); + } + --count; + } + + CRITICAL_REGION_END(); +} +//------------------------------------------------------------------------------------------ +template<class t_connection_context> void async_protocol_handler_config<t_connection_context>::del_out_connections(size_t count) { - std::vector <boost::uuids::uuid> out_connections; - CRITICAL_REGION_BEGIN(m_connects_lock); - for (auto& c: m_connects) - { - if (!c.second->m_connection_context.m_is_income) - out_connections.push_back(c.first); - } - - if (out_connections.size() == 0) - return; - - // close random out connections - // TODO or better just keep removing random elements (performance) - unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); - shuffle(out_connections.begin(), out_connections.end(), std::default_random_engine(seed)); - while (count > 0 && out_connections.size() > 0) - { - try - { - auto i = out_connections.begin(); - async_protocol_handler<t_connection_context> *conn = m_connects.at(*i); - del_connection(conn); - close(*i); - out_connections.erase(i); - } - catch (const std::out_of_range &e) - { - MWARNING("Connection not found in m_connects, continuing"); - } - --count; - } - - CRITICAL_REGION_END(); + delete_connections(count, false); +} +//------------------------------------------------------------------------------------------ +template<class t_connection_context> +void async_protocol_handler_config<t_connection_context>::del_in_connections(size_t count) +{ + delete_connections(count, true); } //------------------------------------------------------------------------------------------ template<class t_connection_context> diff --git a/contrib/epee/include/net/network_throttle-detail.hpp b/contrib/epee/include/net/network_throttle-detail.hpp index dba15a5ed..955668d62 100644 --- a/contrib/epee/include/net/network_throttle-detail.hpp +++ b/contrib/epee/include/net/network_throttle-detail.hpp @@ -2,7 +2,7 @@ /// @author rfree (current maintainer in monero.cc project) /// @brief implementaion for throttling of connection (count and rate-limit speed etc) -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/include/net/network_throttle.hpp b/contrib/epee/include/net/network_throttle.hpp index 225ffee04..7df79a908 100644 --- a/contrib/epee/include/net/network_throttle.hpp +++ b/contrib/epee/include/net/network_throttle.hpp @@ -2,7 +2,7 @@ /// @author rfree (current maintainer in monero.cc project) /// @brief interface for throttling of connection (count and rate-limit speed etc) -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/include/span.h b/contrib/epee/include/span.h index 5660c09d1..452cc088f 100644 --- a/contrib/epee/include/span.h +++ b/contrib/epee/include/span.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // @@ -108,7 +108,7 @@ namespace epee template<typename T> constexpr bool has_padding() noexcept { - return !std::is_pod<T>::value || alignof(T) != 1; + return !std::is_standard_layout<T>() || alignof(T) != 1; } //! \return Cast data from `src` as `span<const std::uint8_t>`. diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h index 6517f1253..d93084ab0 100644 --- a/contrib/epee/include/storages/http_abstract_invoke.h +++ b/contrib/epee/include/storages/http_abstract_invoke.h @@ -115,7 +115,7 @@ namespace epee } if(resp_t.error.code || resp_t.error.message.size()) { - LOG_ERROR("RPC call of \"" << method_name << "\" returned error: " << resp_t.error.code << ", message: " << resp_t.error.message); + LOG_ERROR("RPC call of \"" << req_t.method << "\" returned error: " << resp_t.error.code << ", message: " << resp_t.error.message); return false; } result_struct = resp_t.result; diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index 5a1ef0743..63705e401 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -45,6 +45,7 @@ #include <boost/lexical_cast.hpp> #include <boost/algorithm/string/predicate.hpp> #include "hex.h" +#include "memwipe.h" #include "span.h" #include "warnings.h" @@ -330,7 +331,7 @@ POP_WARNINGS template<class t_pod_type> std::string pod_to_hex(const t_pod_type& s) { - static_assert(std::is_pod<t_pod_type>::value, "expected pod type"); + static_assert(std::is_standard_layout<t_pod_type>(), "expected standard layout type"); return to_hex::string(as_byte_span(s)); } //---------------------------------------------------------------------------- @@ -351,6 +352,12 @@ POP_WARNINGS return true; } //---------------------------------------------------------------------------- + template<class t_pod_type> + bool hex_to_pod(const std::string& hex_str, tools::scrubbed<t_pod_type>& s) + { + return hex_to_pod(hex_str, unwrap(s)); + } + //---------------------------------------------------------------------------- bool validate_hex(uint64_t length, const std::string& str); //---------------------------------------------------------------------------- inline std::string get_extension(const std::string& str) diff --git a/contrib/epee/include/wipeable_string.h b/contrib/epee/include/wipeable_string.h index 66d3e8e2b..d120112a6 100644 --- a/contrib/epee/include/wipeable_string.h +++ b/contrib/epee/include/wipeable_string.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index 538c7ce91..c4750cea0 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp index 5848d1268..dea1928a7 100644 --- a/contrib/epee/src/connection_basic.cpp +++ b/contrib/epee/src/connection_basic.cpp @@ -2,7 +2,7 @@ /// @author rfree (current maintainer in monero.cc project) /// @brief base for connection, contains e.g. the ratelimit hooks -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/hex.cpp b/contrib/epee/src/hex.cpp index cfbd3cf87..c143b2dc2 100644 --- a/contrib/epee/src/hex.cpp +++ b/contrib/epee/src/hex.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp index 5b8d892ff..dc968d971 100644 --- a/contrib/epee/src/http_auth.cpp +++ b/contrib/epee/src/http_auth.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/memwipe.c b/contrib/epee/src/memwipe.c index 423eb89fb..9a83e67e8 100644 --- a/contrib/epee/src/memwipe.c +++ b/contrib/epee/src/memwipe.c @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp index ed6bc07ed..7eeade3a1 100644 --- a/contrib/epee/src/network_throttle-detail.cpp +++ b/contrib/epee/src/network_throttle-detail.cpp @@ -2,7 +2,7 @@ /// @author rfree (current maintainer in monero.cc project) /// @brief implementaion for throttling of connection (count and rate-limit speed etc) -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/network_throttle.cpp b/contrib/epee/src/network_throttle.cpp index dd1640a2e..167738855 100644 --- a/contrib/epee/src/network_throttle.cpp +++ b/contrib/epee/src/network_throttle.cpp @@ -26,7 +26,7 @@ Throttling work by: */ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp index 08a975e58..5671ed9d9 100644 --- a/contrib/epee/src/wipeable_string.cpp +++ b/contrib/epee/src/wipeable_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 93366a4fa..69dc84e87 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/external/db_drivers/CMakeLists.txt b/external/db_drivers/CMakeLists.txt index b00bd8c22..13f70aa40 100644 --- a/external/db_drivers/CMakeLists.txt +++ b/external/db_drivers/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/external/db_drivers/liblmdb/CMakeLists.txt b/external/db_drivers/liblmdb/CMakeLists.txt index 3a09712de..3ca489a4a 100644 --- a/external/db_drivers/liblmdb/CMakeLists.txt +++ b/external/db_drivers/liblmdb/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/external/easylogging++/CMakeLists.txt b/external/easylogging++/CMakeLists.txt index 8fe3fa487..78795d54b 100644 --- a/external/easylogging++/CMakeLists.txt +++ b/external/easylogging++/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/external/unbound/CMakeLists.txt b/external/unbound/CMakeLists.txt index 7d4da33e2..32e9116d7 100644 --- a/external/unbound/CMakeLists.txt +++ b/external/unbound/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/include/INode.h b/include/INode.h index e4a9def06..21be0b2f3 100644 --- a/include/INode.h +++ b/include/INode.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/include/IWallet.h b/include/IWallet.h index 862cdcd35..98110a9d6 100644 --- a/include/IWallet.h +++ b/include/IWallet.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79d2a232d..357495960 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/blockchain_db/CMakeLists.txt b/src/blockchain_db/CMakeLists.txt index 041d9568f..277f4458e 100644 --- a/src/blockchain_db/CMakeLists.txt +++ b/src/blockchain_db/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index c954a7751..f540ce133 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index dd78d951f..238a90686 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp index 7e77953c8..9f760dc0d 100644 --- a/src/blockchain_db/blockchain_db.cpp +++ b/src/blockchain_db/blockchain_db.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 33c3341fa..227169614 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_db/db_types.h b/src/blockchain_db/db_types.h index 8e2f58a61..b8c7fa3e3 100644 --- a/src/blockchain_db/db_types.h +++ b/src/blockchain_db/db_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index d19399bec..6b81a4c90 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index ecd14f11b..ceae2f084 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index 6c55e8d2d..a701bc605 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/blockchain_utilities/README.md b/src/blockchain_utilities/README.md index d18dcba8c..5d968cd75 100644 --- a/src/blockchain_utilities/README.md +++ b/src/blockchain_utilities/README.md @@ -1,6 +1,6 @@ # Monero Blockchain Utilities -Copyright (c) 2014-2017, The Monero Project +Copyright (c) 2014-2018, The Monero Project ## Introduction diff --git a/src/blockchain_utilities/blockchain_export.cpp b/src/blockchain_utilities/blockchain_export.cpp index 78bb51ab6..fcf020057 100644 --- a/src/blockchain_utilities/blockchain_export.cpp +++ b/src/blockchain_utilities/blockchain_export.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index edb8881e0..ce08022fc 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/blockchain_utilities.h b/src/blockchain_utilities/blockchain_utilities.h index 6fb5e1131..e690305c4 100644 --- a/src/blockchain_utilities/blockchain_utilities.h +++ b/src/blockchain_utilities/blockchain_utilities.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/blocksdat_file.cpp b/src/blockchain_utilities/blocksdat_file.cpp index 32e93345e..2bad86dfd 100644 --- a/src/blockchain_utilities/blocksdat_file.cpp +++ b/src/blockchain_utilities/blocksdat_file.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/blocksdat_file.h b/src/blockchain_utilities/blocksdat_file.h index 3fa3ee29e..70a1f30a7 100644 --- a/src/blockchain_utilities/blocksdat_file.h +++ b/src/blockchain_utilities/blocksdat_file.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/bootstrap_file.cpp b/src/blockchain_utilities/bootstrap_file.cpp index 50b56eab9..aa85e5e53 100644 --- a/src/blockchain_utilities/bootstrap_file.cpp +++ b/src/blockchain_utilities/bootstrap_file.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/bootstrap_file.h b/src/blockchain_utilities/bootstrap_file.h index 63914dc26..187db0938 100644 --- a/src/blockchain_utilities/bootstrap_file.h +++ b/src/blockchain_utilities/bootstrap_file.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blockchain_utilities/bootstrap_serialization.h b/src/blockchain_utilities/bootstrap_serialization.h index f9f50f00b..8755d3fe3 100644 --- a/src/blockchain_utilities/bootstrap_serialization.h +++ b/src/blockchain_utilities/bootstrap_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/blocks/CMakeLists.txt b/src/blocks/CMakeLists.txt index 9317d585b..079c59fb5 100644 --- a/src/blocks/CMakeLists.txt +++ b/src/blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/checkpoints/CMakeLists.txt b/src/checkpoints/CMakeLists.txt index bc7a27e36..02bb2891a 100644 --- a/src/checkpoints/CMakeLists.txt +++ b/src/checkpoints/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/checkpoints/checkpoints.cpp b/src/checkpoints/checkpoints.cpp index 67a313bc2..eadfb4df7 100644 --- a/src/checkpoints/checkpoints.cpp +++ b/src/checkpoints/checkpoints.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/checkpoints/checkpoints.h b/src/checkpoints/checkpoints.h index 83969f7b8..e71861c44 100644 --- a/src/checkpoints/checkpoints.h +++ b/src/checkpoints/checkpoints.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7ce0229da..66fd8d7ad 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/common/apply_permutation.h b/src/common/apply_permutation.h index 8684f14ce..ff346bab1 100644 --- a/src/common/apply_permutation.h +++ b/src/common/apply_permutation.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/base58.cpp b/src/common/base58.cpp index 941373443..75556cad9 100644 --- a/src/common/base58.cpp +++ b/src/common/base58.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/base58.h b/src/common/base58.h index 6dd850c03..02ca96956 100644 --- a/src/common/base58.h +++ b/src/common/base58.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h index f8b21c52e..3f5c623f8 100644 --- a/src/common/boost_serialization_helper.h +++ b/src/common/boost_serialization_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index 4b9ca9559..7980b381f 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/command_line.h b/src/common/command_line.h index c2bac9cc8..7b183d86b 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/common_fwd.h b/src/common/common_fwd.h index f33e185b5..2924d9cbe 100644 --- a/src/common/common_fwd.h +++ b/src/common/common_fwd.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index d942ae9d0..06f127c25 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/dns_utils.h b/src/common/dns_utils.h index c0a2dbf2b..d5dc03283 100644 --- a/src/common/dns_utils.h +++ b/src/common/dns_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/download.cpp b/src/common/download.cpp index 87814fa5e..6698a5abf 100644 --- a/src/common/download.cpp +++ b/src/common/download.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/download.h b/src/common/download.h index 917cb2278..3097394bc 100644 --- a/src/common/download.h +++ b/src/common/download.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/http_connection.h b/src/common/http_connection.h index 0357a90a0..9fc6be261 100644 --- a/src/common/http_connection.h +++ b/src/common/http_connection.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/i18n.cpp b/src/common/i18n.cpp index 28a186bf0..4a89876fb 100644 --- a/src/common/i18n.cpp +++ b/src/common/i18n.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/i18n.h b/src/common/i18n.h index 5169cf9f7..d21d00275 100644 --- a/src/common/i18n.h +++ b/src/common/i18n.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/int-util.h b/src/common/int-util.h index 7cec571ad..3bcc085e2 100644 --- a/src/common/int-util.h +++ b/src/common/int-util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -34,7 +34,10 @@ #include <stdbool.h> #include <stdint.h> #include <string.h> + +#ifndef _MSC_VER #include <sys/param.h> +#endif #if defined(__ANDROID__) #include <byteswap.h> @@ -206,6 +209,12 @@ static inline void memcpy_swap64(void *dst, const void *src, size_t n) { } } +#ifdef _MSC_VER +# define LITTLE_ENDIAN 1234 +# define BIG_ENDIAN 4321 +# define BYTE_ORDER LITTLE_ENDIAN +#endif + #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled"); #endif diff --git a/src/common/json_util.h b/src/common/json_util.h index 45046a4fb..661022a6f 100644 --- a/src/common/json_util.h +++ b/src/common/json_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/password.cpp b/src/common/password.cpp index 011123300..ef026c979 100644 --- a/src/common/password.cpp +++ b/src/common/password.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/password.h b/src/common/password.h index 01c6bf05a..7c29effe4 100644 --- a/src/common/password.h +++ b/src/common/password.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp index 4947058d3..41e23130d 100644 --- a/src/common/perf_timer.cpp +++ b/src/common/perf_timer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // @@ -33,6 +33,52 @@ #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "perf" +namespace +{ + uint64_t get_tick_count() + { +#if defined(__x86_64__) + uint32_t hi, lo; + __asm__ volatile("rdtsc" : "=a"(lo), "=d"(hi)); + return (((uint64_t)hi) << 32) | (uint64_t)lo; +#else + return epee::misc_utils::get_ns_count(); +#endif + } + +#ifdef __x86_64__ + uint64_t get_ticks_per_ns() + { + uint64_t t0 = epee::misc_utils::get_ns_count(); + uint64_t r0 = get_tick_count(); + + while (1) + { + uint64_t t = epee::misc_utils::get_ns_count(); + if (t - t0 > 1*1000000000) break; // work one second + } + + uint64_t t1 = epee::misc_utils::get_ns_count(); + uint64_t r1 = get_tick_count(); + uint64_t tpns256 = 256 * (r1 - r0) / (t1 - t0); + return tpns256 ? tpns256 : 1; + } +#endif + +#ifdef __x86_64__ + uint64_t ticks_per_ns = get_ticks_per_ns(); +#endif + + uint64_t ticks_to_ns(uint64_t ticks) + { +#if defined(__x86_64__) + return 256 * ticks / ticks_per_ns; +#else + return ticks; +#endif + } +} + namespace tools { @@ -51,9 +97,9 @@ void set_performance_timer_log_level(el::Level level) performance_timer_log_level = level; } -PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Level l): name(s), unit(unit), level(l), started(false) +PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Level l): name(s), unit(unit), level(l), started(false), paused(false) { - ticks = epee::misc_utils::get_ns_count(); + ticks = get_tick_count(); if (!performance_timers) { MLOG(level, "PERF ----------"); @@ -62,9 +108,10 @@ PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Leve else { PerformanceTimer *pt = performance_timers->back(); - if (!pt->started) + if (!pt->started && !pt->paused) { - MLOG(pt->level, "PERF " << std::string((performance_timers->size()-1) * 2, ' ') << " " << pt->name); + size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused) ++size; + MLOG(pt->level, "PERF " << std::string((size-1) * 2, ' ') << " " << pt->name); pt->started = true; } } @@ -74,10 +121,12 @@ PerformanceTimer::PerformanceTimer(const std::string &s, uint64_t unit, el::Leve PerformanceTimer::~PerformanceTimer() { performance_timers->pop_back(); - ticks = epee::misc_utils::get_ns_count() - ticks; + if (!paused) + ticks = get_tick_count() - ticks; char s[12]; - snprintf(s, sizeof(s), "%8llu ", (unsigned long long)ticks / (1000000000 / unit)); - MLOG(level, "PERF " << s << std::string(performance_timers->size() * 2, ' ') << " " << name); + snprintf(s, sizeof(s), "%8llu ", (unsigned long long)(ticks_to_ns(ticks) / (1000000000 / unit))); + size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused || tmp==this) ++size; + MLOG(level, "PERF " << s << std::string(size * 2, ' ') << " " << name); if (performance_timers->empty()) { delete performance_timers; @@ -85,4 +134,20 @@ PerformanceTimer::~PerformanceTimer() } } +void PerformanceTimer::pause() +{ + if (paused) + return; + ticks = get_tick_count() - ticks; + paused = true; +} + +void PerformanceTimer::resume() +{ + if (!paused) + return; + ticks = get_tick_count() - ticks; + paused = false; +} + } diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h index a1d71609c..0e910caf9 100644 --- a/src/common/perf_timer.h +++ b/src/common/perf_timer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // @@ -30,6 +30,7 @@ #include <string> #include <stdio.h> +#include <memory> #include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -47,6 +48,8 @@ class PerformanceTimer public: PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug); ~PerformanceTimer(); + void pause(); + void resume(); private: std::string name; @@ -54,6 +57,7 @@ private: el::Level level; uint64_t ticks; bool started; + bool paused; }; void set_performance_timer_log_level(el::Level level); @@ -62,8 +66,10 @@ void set_performance_timer_log_level(el::Level level); #define PERF_TIMER_UNIT_L(name, unit, l) tools::PerformanceTimer pt_##name(#name, unit, l) #define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000) #define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000, l) -#define PERF_TIMER_START_UNIT(name, unit) tools::PerformanceTimer *pt_##name = new tools::PerformanceTimer(#name, unit, el::Level::Info) +#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::PerformanceTimer> pt_##name(new tools::PerformanceTimer(#name, unit, el::Level::Info)) #define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000) -#define PERF_TIMER_STOP(name) do { delete pt_##name; pt_##name = NULL; } while(0) +#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0) +#define PERF_TIMER_PAUSE(name) pt_##name->pause() +#define PERF_TIMER_RESUME(name) pt_##name->resume() } diff --git a/src/common/pod-class.h b/src/common/pod-class.h index 3896d5c29..5f6709eef 100644 --- a/src/common/pod-class.h +++ b/src/common/pod-class.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h index 297020ef2..9665966ae 100644 --- a/src/common/rpc_client.h +++ b/src/common/rpc_client.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -72,10 +72,10 @@ namespace tools fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } - ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); + ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); if (!ok) { - fail_msg_writer() << "Daemon request failed"; + fail_msg_writer() << "basic_json_rpc_request: Daemon request failed"; return false; } else @@ -95,15 +95,15 @@ namespace tools t_http_connection connection(&m_http_client); bool ok = connection.is_open(); - ok = ok && epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); if (!ok) { fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } - else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ? + ok = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client, t_http_connection::TIMEOUT()); + if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ? { - fail_msg_writer() << fail_msg << " -- " << res.status; + fail_msg_writer() << fail_msg << " -- json_rpc_request: " << res.status; return false; } else @@ -123,15 +123,15 @@ namespace tools t_http_connection connection(&m_http_client); bool ok = connection.is_open(); - ok = ok && epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT()); if (!ok) { fail_msg_writer() << "Couldn't connect to daemon: " << m_http_client.get_host() << ":" << m_http_client.get_port(); return false; } - else if (res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ? + ok = epee::net_utils::invoke_http_json(relative_url, req, res, m_http_client, t_http_connection::TIMEOUT()); + if (!ok || res.status != CORE_RPC_STATUS_OK) // TODO - handle CORE_RPC_STATUS_BUSY ? { - fail_msg_writer() << fail_msg << " -- " << res.status; + fail_msg_writer() << fail_msg << "-- rpc_request: " << res.status; return false; } else diff --git a/src/common/scoped_message_writer.h b/src/common/scoped_message_writer.h index 8fc98d2b0..d7517babb 100644 --- a/src/common/scoped_message_writer.h +++ b/src/common/scoped_message_writer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/sfinae_helpers.h b/src/common/sfinae_helpers.h index ddd456dd2..fa5052a2e 100644 --- a/src/common/sfinae_helpers.h +++ b/src/common/sfinae_helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/stack_trace.cpp b/src/common/stack_trace.cpp index ed1093309..9c2bf4b53 100644 --- a/src/common/stack_trace.cpp +++ b/src/common/stack_trace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/stack_trace.h b/src/common/stack_trace.h index 0f6bdc08b..272fb89ae 100644 --- a/src/common/stack_trace.h +++ b/src/common/stack_trace.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp index 5d749e08e..7fd16ceaf 100644 --- a/src/common/threadpool.cpp +++ b/src/common/threadpool.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/threadpool.h b/src/common/threadpool.h index 1d56d7605..a0e53b011 100644 --- a/src/common/threadpool.h +++ b/src/common/threadpool.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/unordered_containers_boost_serialization.h b/src/common/unordered_containers_boost_serialization.h index 4d82a1364..d78dc6a30 100644 --- a/src/common/unordered_containers_boost_serialization.h +++ b/src/common/unordered_containers_boost_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/updates.cpp b/src/common/updates.cpp index 2d9c2d89c..9eb402e0b 100644 --- a/src/common/updates.cpp +++ b/src/common/updates.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/updates.h b/src/common/updates.h index e494ed7ac..6ec22f183 100644 --- a/src/common/updates.h +++ b/src/common/updates.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/util.cpp b/src/common/util.cpp index bcea70558..659ea31b8 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/util.h b/src/common/util.h index 53ff78af8..5afb42c97 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/common/varint.h b/src/common/varint.h index cb785e61a..262bd1360 100644 --- a/src/common/varint.h +++ b/src/common/varint.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index 764b30273..71dcedcab 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/crypto/blake256.c b/src/crypto/blake256.c index 95b2a6927..d503c47e0 100644 --- a/src/crypto/blake256.c +++ b/src/crypto/blake256.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/blake256.h b/src/crypto/blake256.h index 921fcd2fd..073772289 100644 --- a/src/crypto/blake256.h +++ b/src/crypto/blake256.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/chacha.c b/src/crypto/chacha.c index f573083be..5d3edb98d 100644 --- a/src/crypto/chacha.c +++ b/src/crypto/chacha.c @@ -6,7 +6,9 @@ Public domain. #include <memory.h> #include <stdio.h> +#ifndef _MSC_VER #include <sys/param.h> +#endif #include "chacha.h" #include "common/int-util.h" diff --git a/src/crypto/chacha.h b/src/crypto/chacha.h index c11e4aa2f..f74d0c352 100644 --- a/src/crypto/chacha.h +++ b/src/crypto/chacha.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto-ops-data.c b/src/crypto/crypto-ops-data.c index 4bd75b77c..4ff4310de 100644 --- a/src/crypto/crypto-ops-data.c +++ b/src/crypto/crypto-ops-data.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -870,3 +870,4 @@ const fe fe_fffb1 = {-31702527, -2466483, -26106795, -12203692, -12169197, -3210 const fe fe_fffb2 = {8166131, -6741800, -17040804, 3154616, 21461005, 1466302, -30876704, -6368709, 10503587, -13363080}; /* sqrt(2 * A * (A + 2)) */ const fe fe_fffb3 = {-13620103, 14639558, 4532995, 7679154, 16815101, -15883539, -22863840, -14813421, 13716513, -6477756}; /* sqrt(-sqrt(-1) * A * (A + 2)) */ const fe fe_fffb4 = {-21786234, -12173074, 21573800, 4524538, -4645904, 16204591, 8012863, -8444712, 3212926, 6885324}; /* sqrt(sqrt(-1) * A * (A + 2)) */ +const ge_p3 ge_p3_identity = { {0}, {1, 0}, {1, 0}, {0} }; diff --git a/src/crypto/crypto-ops.c b/src/crypto/crypto-ops.c index b5c62bce4..45d412ac6 100644 --- a/src/crypto/crypto-ops.c +++ b/src/crypto/crypto-ops.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -1234,6 +1234,51 @@ void ge_double_scalarmult_base_vartime(ge_p2 *r, const unsigned char *a, const g } } +void ge_double_scalarmult_base_vartime_p3(ge_p3 *r3, const unsigned char *a, const ge_p3 *A, const unsigned char *b) { + signed char aslide[256]; + signed char bslide[256]; + ge_dsmp Ai; /* A, 3A, 5A, 7A, 9A, 11A, 13A, 15A */ + ge_p1p1 t; + ge_p3 u; + ge_p2 r; + int i; + + slide(aslide, a); + slide(bslide, b); + ge_dsm_precomp(Ai, A); + + ge_p2_0(&r); + + for (i = 255; i >= 0; --i) { + if (aslide[i] || bslide[i]) break; + } + + for (; i >= 0; --i) { + ge_p2_dbl(&t, &r); + + if (aslide[i] > 0) { + ge_p1p1_to_p3(&u, &t); + ge_add(&t, &u, &Ai[aslide[i]/2]); + } else if (aslide[i] < 0) { + ge_p1p1_to_p3(&u, &t); + ge_sub(&t, &u, &Ai[(-aslide[i])/2]); + } + + if (bslide[i] > 0) { + ge_p1p1_to_p3(&u, &t); + ge_madd(&t, &u, &ge_Bi[bslide[i]/2]); + } else if (bslide[i] < 0) { + ge_p1p1_to_p3(&u, &t); + ge_msub(&t, &u, &ge_Bi[(-bslide[i])/2]); + } + + if (i == 0) + ge_p1p1_to_p3(r3, &t); + else + ge_p1p1_to_p2(&r, &t); + } +} + /* From ge_frombytes.c, modified */ int ge_frombytes_vartime(ge_p3 *h, const unsigned char *s) { @@ -2000,6 +2045,70 @@ void ge_scalarmult(ge_p2 *r, const unsigned char *a, const ge_p3 *A) { } } +void ge_scalarmult_p3(ge_p3 *r3, const unsigned char *a, const ge_p3 *A) { + signed char e[64]; + int carry, carry2, i; + ge_cached Ai[8]; /* 1 * A, 2 * A, ..., 8 * A */ + ge_p1p1 t; + ge_p3 u; + ge_p2 r; + + carry = 0; /* 0..1 */ + for (i = 0; i < 31; i++) { + carry += a[i]; /* 0..256 */ + carry2 = (carry + 8) >> 4; /* 0..16 */ + e[2 * i] = carry - (carry2 << 4); /* -8..7 */ + carry = (carry2 + 8) >> 4; /* 0..1 */ + e[2 * i + 1] = carry2 - (carry << 4); /* -8..7 */ + } + carry += a[31]; /* 0..128 */ + carry2 = (carry + 8) >> 4; /* 0..8 */ + e[62] = carry - (carry2 << 4); /* -8..7 */ + e[63] = carry2; /* 0..8 */ + + ge_p3_to_cached(&Ai[0], A); + for (i = 0; i < 7; i++) { + ge_add(&t, A, &Ai[i]); + ge_p1p1_to_p3(&u, &t); + ge_p3_to_cached(&Ai[i + 1], &u); + } + + ge_p2_0(&r); + for (i = 63; i >= 0; i--) { + signed char b = e[i]; + unsigned char bnegative = negative(b); + unsigned char babs = b - (((-bnegative) & b) << 1); + ge_cached cur, minuscur; + ge_p2_dbl(&t, &r); + ge_p1p1_to_p2(&r, &t); + ge_p2_dbl(&t, &r); + ge_p1p1_to_p2(&r, &t); + ge_p2_dbl(&t, &r); + ge_p1p1_to_p2(&r, &t); + ge_p2_dbl(&t, &r); + ge_p1p1_to_p3(&u, &t); + ge_cached_0(&cur); + ge_cached_cmov(&cur, &Ai[0], equal(babs, 1)); + ge_cached_cmov(&cur, &Ai[1], equal(babs, 2)); + ge_cached_cmov(&cur, &Ai[2], equal(babs, 3)); + ge_cached_cmov(&cur, &Ai[3], equal(babs, 4)); + ge_cached_cmov(&cur, &Ai[4], equal(babs, 5)); + ge_cached_cmov(&cur, &Ai[5], equal(babs, 6)); + ge_cached_cmov(&cur, &Ai[6], equal(babs, 7)); + ge_cached_cmov(&cur, &Ai[7], equal(babs, 8)); + fe_copy(minuscur.YplusX, cur.YminusX); + fe_copy(minuscur.YminusX, cur.YplusX); + fe_copy(minuscur.Z, cur.Z); + fe_neg(minuscur.T2d, cur.T2d); + ge_cached_cmov(&cur, &minuscur, bnegative); + ge_add(&t, &u, &cur); + if (i == 0) + ge_p1p1_to_p3(r3, &t); + else + ge_p1p1_to_p2(&r, &t); + } +} + void ge_double_scalarmult_precomp_vartime2(ge_p2 *r, const unsigned char *a, const ge_dsmp Ai, const unsigned char *b, const ge_dsmp Bi) { signed char aslide[256]; signed char bslide[256]; @@ -2039,6 +2148,49 @@ void ge_double_scalarmult_precomp_vartime2(ge_p2 *r, const unsigned char *a, con } } +void ge_double_scalarmult_precomp_vartime2_p3(ge_p3 *r3, const unsigned char *a, const ge_dsmp Ai, const unsigned char *b, const ge_dsmp Bi) { + signed char aslide[256]; + signed char bslide[256]; + ge_p1p1 t; + ge_p3 u; + ge_p2 r; + int i; + + slide(aslide, a); + slide(bslide, b); + + ge_p2_0(&r); + + for (i = 255; i >= 0; --i) { + if (aslide[i] || bslide[i]) break; + } + + for (; i >= 0; --i) { + ge_p2_dbl(&t, &r); + + if (aslide[i] > 0) { + ge_p1p1_to_p3(&u, &t); + ge_add(&t, &u, &Ai[aslide[i]/2]); + } else if (aslide[i] < 0) { + ge_p1p1_to_p3(&u, &t); + ge_sub(&t, &u, &Ai[(-aslide[i])/2]); + } + + if (bslide[i] > 0) { + ge_p1p1_to_p3(&u, &t); + ge_add(&t, &u, &Bi[bslide[i]/2]); + } else if (bslide[i] < 0) { + ge_p1p1_to_p3(&u, &t); + ge_sub(&t, &u, &Bi[(-bslide[i])/2]); + } + + if (i == 0) + ge_p1p1_to_p3(r3, &t); + else + ge_p1p1_to_p2(&r, &t); + } +} + void ge_double_scalarmult_precomp_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b, const ge_dsmp Bi) { ge_dsmp Ai; /* A, 3A, 5A, 7A, 9A, 11A, 13A, 15A */ diff --git a/src/crypto/crypto-ops.h b/src/crypto/crypto-ops.h index c76455551..dc3c60794 100644 --- a/src/crypto/crypto-ops.h +++ b/src/crypto/crypto-ops.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -79,6 +79,7 @@ typedef ge_cached ge_dsmp[8]; extern const ge_precomp ge_Bi[8]; void ge_dsm_precomp(ge_dsmp r, const ge_p3 *s); void ge_double_scalarmult_base_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *); +void ge_double_scalarmult_base_vartime_p3(ge_p3 *, const unsigned char *, const ge_p3 *, const unsigned char *); /* From ge_frombytes.c, modified */ @@ -127,8 +128,10 @@ void sc_reduce(unsigned char *); /* New code */ void ge_scalarmult(ge_p2 *, const unsigned char *, const ge_p3 *); +void ge_scalarmult_p3(ge_p3 *, const unsigned char *, const ge_p3 *); void ge_double_scalarmult_precomp_vartime(ge_p2 *, const unsigned char *, const ge_p3 *, const unsigned char *, const ge_dsmp); void ge_double_scalarmult_precomp_vartime2(ge_p2 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp); +void ge_double_scalarmult_precomp_vartime2_p3(ge_p3 *, const unsigned char *, const ge_dsmp, const unsigned char *, const ge_dsmp); void ge_mul8(ge_p1p1 *, const ge_p2 *); extern const fe fe_ma2; extern const fe fe_ma; @@ -136,6 +139,7 @@ extern const fe fe_fffb1; extern const fe fe_fffb2; extern const fe fe_fffb3; extern const fe fe_fffb4; +extern const ge_p3 ge_p3_identity; void ge_fromfe_frombytes_vartime(ge_p2 *, const unsigned char *); void sc_0(unsigned char *); void sc_reduce32(unsigned char *); diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index 10ef25ec7..d9b8b6787 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index a929302c1..81ebfb9e2 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto_ops_builder/README.md b/src/crypto/crypto_ops_builder/README.md index 3b87966f5..326d2ca6e 100644 --- a/src/crypto/crypto_ops_builder/README.md +++ b/src/crypto/crypto_ops_builder/README.md @@ -1,6 +1,6 @@ # Monero -Copyright (c) 2014-2017, The Monero Project +Copyright (c) 2014-2018, The Monero Project ## Crypto Ops Builder diff --git a/src/crypto/crypto_ops_builder/crypto-ops-data.c b/src/crypto/crypto_ops_builder/crypto-ops-data.c index 4bd75b77c..127e3e17b 100644 --- a/src/crypto/crypto_ops_builder/crypto-ops-data.c +++ b/src/crypto/crypto_ops_builder/crypto-ops-data.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto_ops_builder/crypto-ops-old.c b/src/crypto/crypto_ops_builder/crypto-ops-old.c index b7a290b4a..9097bf95b 100644 --- a/src/crypto/crypto_ops_builder/crypto-ops-old.c +++ b/src/crypto/crypto_ops_builder/crypto-ops-old.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto_ops_builder/crypto-ops.h b/src/crypto/crypto_ops_builder/crypto-ops.h index 47d5b46ae..9337b56b7 100644 --- a/src/crypto/crypto_ops_builder/crypto-ops.h +++ b/src/crypto/crypto_ops_builder/crypto-ops.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py b/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py index 5f8776a49..9b55d260d 100644 --- a/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py +++ b/src/crypto/crypto_ops_builder/ref10CommentedCombined/MakeCryptoOps.py @@ -15,7 +15,7 @@ print("maybe someone smart can replace the sed with perl..") a = "" license = textwrap.dedent("""\ - // Copyright (c) 2014-2017, The Monero Project + // Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h b/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h index b432efade..c06af035f 100644 --- a/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h +++ b/src/crypto/crypto_ops_builder/ref10CommentedCombined/crypto-ops.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/generic-ops.h b/src/crypto/generic-ops.h index 1a135ffcf..62bc758c9 100644 --- a/src/crypto/generic-ops.h +++ b/src/crypto/generic-ops.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/groestl.h b/src/crypto/groestl.h index 89a073a4c..19837f309 100644 --- a/src/crypto/groestl.h +++ b/src/crypto/groestl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/groestl_tables.h b/src/crypto/groestl_tables.h index 8fa6d7a83..c4b368584 100644 --- a/src/crypto/groestl_tables.h +++ b/src/crypto/groestl_tables.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash-extra-blake.c b/src/crypto/hash-extra-blake.c index 236479880..d33103c97 100644 --- a/src/crypto/hash-extra-blake.c +++ b/src/crypto/hash-extra-blake.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash-extra-groestl.c b/src/crypto/hash-extra-groestl.c index b15075306..228853a44 100644 --- a/src/crypto/hash-extra-groestl.c +++ b/src/crypto/hash-extra-groestl.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash-extra-jh.c b/src/crypto/hash-extra-jh.c index 8950687d3..e765a18f3 100644 --- a/src/crypto/hash-extra-jh.c +++ b/src/crypto/hash-extra-jh.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash-extra-skein.c b/src/crypto/hash-extra-skein.c index e63e7da20..06d8f87cc 100644 --- a/src/crypto/hash-extra-skein.c +++ b/src/crypto/hash-extra-skein.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash-ops.h b/src/crypto/hash-ops.h index 6e3a5c6c9..47c6f6425 100644 --- a/src/crypto/hash-ops.h +++ b/src/crypto/hash-ops.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash.c b/src/crypto/hash.c index ed95391d8..42f272e34 100644 --- a/src/crypto/hash.c +++ b/src/crypto/hash.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/hash.h b/src/crypto/hash.h index 610b4502f..14104699b 100644 --- a/src/crypto/hash.h +++ b/src/crypto/hash.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/initializer.h b/src/crypto/initializer.h index eb1d1c069..afbace726 100644 --- a/src/crypto/initializer.h +++ b/src/crypto/initializer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 0afec6212..9e31ebf46 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -53,6 +53,12 @@ #include <unistd.h> #endif +#ifdef _MSC_VER +#define GETPID() _getpid() +#else +#define GETPID() getpid() +#endif + #include "oaes_config.h" #include "oaes_lib.h" @@ -478,7 +484,7 @@ static void oaes_get_seed( char buf[RANDSIZ + 1] ) sprintf( buf, "%04d%02d%02d%02d%02d%02d%03d%p%d", gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday, gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.millitm, - _test + timer.millitm, getpid() ); + _test + timer.millitm, GETPID() ); #else struct timeval timer; struct tm *gmTimer; @@ -490,7 +496,7 @@ static void oaes_get_seed( char buf[RANDSIZ + 1] ) sprintf( buf, "%04d%02d%02d%02d%02d%02d%03d%p%d", gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday, gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.tv_usec/1000, - _test + timer.tv_usec/1000, getpid() ); + _test + timer.tv_usec/1000, GETPID() ); #endif if( _test ) @@ -510,7 +516,7 @@ static uint32_t oaes_get_seed(void) _test = (char *) calloc( sizeof( char ), timer.millitm ); _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday + gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm + - (uintptr_t) ( _test + timer.millitm ) + getpid(); + (uintptr_t) ( _test + timer.millitm ) + GETPID(); #else struct timeval timer; struct tm *gmTimer; @@ -522,7 +528,7 @@ static uint32_t oaes_get_seed(void) _test = (char *) calloc( sizeof( char ), timer.tv_usec/1000 ); _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday + gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.tv_usec/1000 + - (uintptr_t) ( _test + timer.tv_usec/1000 ) + getpid(); + (uintptr_t) ( _test + timer.tv_usec/1000 ) + GETPID(); #endif if( _test ) diff --git a/src/crypto/random.c b/src/crypto/random.c index 14a028fc9..929377943 100644 --- a/src/crypto/random.c +++ b/src/crypto/random.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/random.h b/src/crypto/random.h index 75d23fd04..6468136cc 100644 --- a/src/crypto/random.h +++ b/src/crypto/random.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/skein_port.h b/src/crypto/skein_port.h index a06ef30a2..a50a28e6b 100644 --- a/src/crypto/skein_port.h +++ b/src/crypto/skein_port.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index cc234713b..f921b2455 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c index eb98c31b7..e6d6a267c 100644 --- a/src/crypto/tree-hash.c +++ b/src/crypto/tree-hash.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -34,7 +34,9 @@ #include "hash-ops.h" -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) +#ifdef _MSC_VER +#include <malloc.h> +#elif !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) #include <alloca.h> #else #include <stdlib.h> diff --git a/src/cryptonote_basic/CMakeLists.txt b/src/cryptonote_basic/CMakeLists.txt index 750be69f1..de986b6aa 100644 --- a/src/cryptonote_basic/CMakeLists.txt +++ b/src/cryptonote_basic/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/cryptonote_basic/account.cpp b/src/cryptonote_basic/account.cpp index ddc1fc7fc..1b38d99b3 100644 --- a/src/cryptonote_basic/account.cpp +++ b/src/cryptonote_basic/account.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/account.h b/src/cryptonote_basic/account.h index 50af36a9d..79601f99c 100644 --- a/src/cryptonote_basic/account.h +++ b/src/cryptonote_basic/account.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/account_boost_serialization.h b/src/cryptonote_basic/account_boost_serialization.h index d2f541638..7379d787f 100644 --- a/src/cryptonote_basic/account_boost_serialization.h +++ b/src/cryptonote_basic/account_boost_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/blobdatatype.h b/src/cryptonote_basic/blobdatatype.h index 2d12a84af..7d6ff0187 100644 --- a/src/cryptonote_basic/blobdatatype.h +++ b/src/cryptonote_basic/blobdatatype.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/connection_context.h b/src/cryptonote_basic/connection_context.h index e173348db..705af978a 100644 --- a/src/cryptonote_basic/connection_context.h +++ b/src/cryptonote_basic/connection_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h index c81901f4e..54227ad92 100644 --- a/src/cryptonote_basic/cryptonote_basic.h +++ b/src/cryptonote_basic/cryptonote_basic.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_basic_impl.cpp b/src/cryptonote_basic/cryptonote_basic_impl.cpp index 929be0d5a..dbf4d4045 100644 --- a/src/cryptonote_basic/cryptonote_basic_impl.cpp +++ b/src/cryptonote_basic/cryptonote_basic_impl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_basic_impl.h b/src/cryptonote_basic/cryptonote_basic_impl.h index 08d966fed..8943d93ea 100644 --- a/src/cryptonote_basic/cryptonote_basic_impl.h +++ b/src/cryptonote_basic/cryptonote_basic_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_boost_serialization.h b/src/cryptonote_basic/cryptonote_boost_serialization.h index ed8239176..143133163 100644 --- a/src/cryptonote_basic/cryptonote_boost_serialization.h +++ b/src/cryptonote_basic/cryptonote_boost_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -299,7 +299,7 @@ namespace boost throw boost::archive::archive_exception(boost::archive::archive_exception::other_exception, "Unsupported rct type"); // a & x.message; message is not serialized, as it can be reconstructed from the tx data // a & x.mixRing; mixRing is not serialized, as it can be reconstructed from the offsets - if (x.type == rct::RCTTypeSimple || x.type == rct::RCTTypeSimpleBulletproof) + if (x.type == rct::RCTTypeSimple) // moved to prunable with bulletproofs a & x.pseudoOuts; a & x.ecdhInfo; serializeOutPk(a, x.outPk, ver); @@ -313,6 +313,8 @@ namespace boost if (x.rangeSigs.empty()) a & x.bulletproofs; a & x.MGs; + if (x.rangeSigs.empty()) + a & x.pseudoOuts; } template <class Archive> @@ -325,7 +327,7 @@ namespace boost throw boost::archive::archive_exception(boost::archive::archive_exception::other_exception, "Unsupported rct type"); // a & x.message; message is not serialized, as it can be reconstructed from the tx data // a & x.mixRing; mixRing is not serialized, as it can be reconstructed from the offsets - if (x.type == rct::RCTTypeSimple || x.type == rct::RCTTypeSimpleBulletproof) + if (x.type == rct::RCTTypeSimple) a & x.pseudoOuts; a & x.ecdhInfo; serializeOutPk(a, x.outPk, ver); @@ -335,6 +337,8 @@ namespace boost if (x.p.rangeSigs.empty()) a & x.p.bulletproofs; a & x.p.MGs; + if (x.type == rct::RCTTypeSimpleBulletproof) + a & x.p.pseudoOuts; } } } diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 5f6dc3bd6..aab4f380c 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h index cabdb1f5c..29e180c41 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.h +++ b/src/cryptonote_basic/cryptonote_format_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/cryptonote_stat_info.h b/src/cryptonote_basic/cryptonote_stat_info.h index 7ebf86878..c0be2144e 100644 --- a/src/cryptonote_basic/cryptonote_stat_info.h +++ b/src/cryptonote_basic/cryptonote_stat_info.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/difficulty.cpp b/src/cryptonote_basic/difficulty.cpp index 863aa4359..cb2a00a12 100644 --- a/src/cryptonote_basic/difficulty.cpp +++ b/src/cryptonote_basic/difficulty.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/difficulty.h b/src/cryptonote_basic/difficulty.h index aeb1c030d..b06538467 100644 --- a/src/cryptonote_basic/difficulty.h +++ b/src/cryptonote_basic/difficulty.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/hardfork.cpp b/src/cryptonote_basic/hardfork.cpp index 546af2076..95f1ecab9 100644 --- a/src/cryptonote_basic/hardfork.cpp +++ b/src/cryptonote_basic/hardfork.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/hardfork.h b/src/cryptonote_basic/hardfork.h index 6c6fbcb84..1ec601660 100644 --- a/src/cryptonote_basic/hardfork.h +++ b/src/cryptonote_basic/hardfork.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp index 670baea50..6c4ecf58c 100644 --- a/src/cryptonote_basic/miner.cpp +++ b/src/cryptonote_basic/miner.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/miner.h b/src/cryptonote_basic/miner.h index 964ee6a36..7bf5dc372 100644 --- a/src/cryptonote_basic/miner.h +++ b/src/cryptonote_basic/miner.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/subaddress_index.h b/src/cryptonote_basic/subaddress_index.h index 07d13c503..9b71448f9 100644 --- a/src/cryptonote_basic/subaddress_index.h +++ b/src/cryptonote_basic/subaddress_index.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/tx_extra.h b/src/cryptonote_basic/tx_extra.h index e12828a9f..009e35ebe 100644 --- a/src/cryptonote_basic/tx_extra.h +++ b/src/cryptonote_basic/tx_extra.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_basic/verification_context.h b/src/cryptonote_basic/verification_context.h index ce885ec1d..8d2b633a2 100644 --- a/src/cryptonote_basic/verification_context.h +++ b/src/cryptonote_basic/verification_context.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index e38e15cb2..0ece65028 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt index eeed881da..d8a21ae31 100644 --- a/src/cryptonote_core/CMakeLists.txt +++ b/src/cryptonote_core/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 69288a2b7..7ee9ade80 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -127,13 +127,14 @@ static const struct { { 5, 802660, 0, 1472415036 + 86400*180 }, // add 5 months on testnet to shut the update warning up since there's a large gap to v6 { 6, 971400, 0, 1501709789 }, - { 7, 1057028, 0, 1512211236 }, + { 7, 1057027, 0, 1512211236 }, + { 8, 1057058, 0, 1515967497 }, }; static const uint64_t testnet_hard_fork_version_1_till = 624633; //------------------------------------------------------------------ Blockchain::Blockchain(tx_memory_pool& tx_pool) : - m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_sz_limit(0), + m_db(), m_tx_pool(tx_pool), m_hardfork(NULL), m_timestamps_and_difficulties_height(0), m_current_block_cumul_sz_limit(0), m_current_block_cumul_sz_median(0), m_enforce_dns_checkpoints(false), m_max_prepare_blocks_threads(4), m_db_blocks_per_sync(1), m_db_sync_mode(db_async), m_db_default_sync(false), m_fast_sync(true), m_show_time_stats(false), m_sync_counter(0), m_cancel(false) { LOG_PRINT_L3("Blockchain::" << __func__); @@ -1101,6 +1102,12 @@ uint64_t Blockchain::get_current_cumulative_blocksize_limit() const return m_current_block_cumul_sz_limit; } //------------------------------------------------------------------ +uint64_t Blockchain::get_current_cumulative_blocksize_median() const +{ + LOG_PRINT_L3("Blockchain::" << __func__); + return m_current_block_cumul_sz_median; +} +//------------------------------------------------------------------ //TODO: This function only needed minor modification to work with BlockchainDB, // and *works*. As such, to reduce the number of things that might break // in moving to BlockchainDB, this function will remain otherwise @@ -2389,11 +2396,11 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context } } - // from v7, allow bulletproofs - if (hf_version < 7 || !m_testnet) { + // from v8, allow bulletproofs + if (hf_version < 8) { if (!tx.rct_signatures.p.bulletproofs.empty()) { - MERROR("Bulletproofs are not allowed before v7 or on mainnet"); + MERROR("Bulletproofs are not allowed before v8"); tvc.m_invalid_output = true; return false; } @@ -3518,6 +3525,7 @@ bool Blockchain::update_next_cumulative_size_limit() get_last_n_blocks_sizes(sz, CRYPTONOTE_REWARD_BLOCKS_WINDOW); uint64_t median = epee::misc_utils::median(sz); + m_current_block_cumul_sz_median = median; if(median <= full_reward_zone) median = full_reward_zone; diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 25e573a2c..b2bbff488 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -637,6 +637,13 @@ namespace cryptonote uint64_t get_current_cumulative_blocksize_limit() const; /** + * @brief gets the blocksize median based on recent blocks (same window as for the limit) + * + * @return the median + */ + uint64_t get_current_cumulative_blocksize_median() const; + + /** * @brief gets the difficulty of the block with a given height * * @param i the height @@ -962,6 +969,7 @@ namespace cryptonote // main chain transactions_container m_transactions; size_t m_current_block_cumul_sz_limit; + size_t m_current_block_cumul_sz_median; // metadata containers std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, std::vector<output_data_t>>> m_scan_table; diff --git a/src/cryptonote_core/blockchain_storage_boost_serialization.h b/src/cryptonote_core/blockchain_storage_boost_serialization.h index e87a51f10..f4f9f20ca 100644 --- a/src/cryptonote_core/blockchain_storage_boost_serialization.h +++ b/src/cryptonote_core/blockchain_storage_boost_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index adbc727b0..81a7b4724 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -83,6 +83,10 @@ namespace cryptonote "offline" , "Do not listen for peers, nor connect to any" }; + const command_line::arg_descriptor<bool> arg_disable_dns_checkpoints = { + "disable-dns-checkpoints" + , "Do not retrieve checkpoints from DNS" + }; static const command_line::arg_descriptor<bool> arg_test_drop_download = { "test-drop-download" @@ -236,6 +240,7 @@ namespace cryptonote command_line::add_arg(desc, arg_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); miner::init_options(desc); BlockchainDB::init_options(desc); @@ -270,6 +275,7 @@ namespace cryptonote 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_offline = get_arg(vm, arg_offline); + m_disable_dns_checkpoints = get_arg(vm, arg_disable_dns_checkpoints); 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 adc201fb5..429f6b820 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 916b1e05a..4a10f7133 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -172,20 +172,24 @@ namespace cryptonote return true; } //--------------------------------------------------------------- - crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const account_keys &sender_keys) + crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const boost::optional<cryptonote::account_public_address>& change_addr) { - if (destinations.empty()) - return null_pkey; - for (size_t n = 1; n < destinations.size(); ++n) + account_public_address addr = {null_pkey, null_pkey}; + size_t count = 0; + for (const auto &i : destinations) { - if (!memcmp(&destinations[n].addr, &sender_keys.m_account_address, sizeof(destinations[0].addr))) + if (i.amount == 0) continue; - if (destinations[n].amount == 0) + if (change_addr && i.addr == *change_addr) continue; - if (memcmp(&destinations[n].addr, &destinations[0].addr, sizeof(destinations[0].addr))) + if (i.addr == addr) + continue; + if (count > 0) return null_pkey; + addr = i.addr; + ++count; } - return destinations[0].addr.m_view_public_key; + return addr.m_view_public_key; } //--------------------------------------------------------------- bool construct_tx_with_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, bool rct, bool bulletproof, rct::multisig_out *msout) @@ -221,7 +225,7 @@ namespace cryptonote if (get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id)) { LOG_PRINT_L2("Encrypting payment id " << payment_id); - crypto::public_key view_key_pub = get_destination_view_key_pub(destinations, sender_account_keys); + crypto::public_key view_key_pub = get_destination_view_key_pub(destinations, change_addr); if (view_key_pub == null_pkey) { LOG_ERROR("Destinations have to have exactly one output to support encrypted payment ids"); diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h index 5947522e2..1c390078d 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.h +++ b/src/cryptonote_core/cryptonote_tx_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -88,7 +88,7 @@ namespace cryptonote }; //--------------------------------------------------------------- - crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const account_keys &sender_keys); + crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const boost::optional<cryptonote::account_public_address>& change_addr); bool construct_tx(const account_keys& sender_account_keys, std::vector<tx_source_entry> &sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time); bool construct_tx_with_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, bool bulletproof = false, rct::multisig_out *msout = NULL); bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, bool bulletproof = false, rct::multisig_out *msout = NULL); diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 8773c1f74..e75584bce 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h index d657c6554..b4ea5a8f4 100644 --- a/src/cryptonote_core/tx_pool.h +++ b/src/cryptonote_core/tx_pool.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_protocol/CMakeLists.txt b/src/cryptonote_protocol/CMakeLists.txt index 347e48eee..1189ccf22 100644 --- a/src/cryptonote_protocol/CMakeLists.txt +++ b/src/cryptonote_protocol/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp index 3844d3751..9ae33d540 100644 --- a/src/cryptonote_protocol/block_queue.cpp +++ b/src/cryptonote_protocol/block_queue.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_protocol/block_queue.h b/src/cryptonote_protocol/block_queue.h index 13d4619bf..69ddaa435 100644 --- a/src/cryptonote_protocol/block_queue.h +++ b/src/cryptonote_protocol/block_queue.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_protocol/cryptonote_protocol_defs.h b/src/cryptonote_protocol/cryptonote_protocol_defs.h index a1682ef8c..cf0043287 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_defs.h +++ b/src/cryptonote_protocol/cryptonote_protocol_defs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp index 578abd20c..c9fd40d88 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp +++ b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp @@ -2,7 +2,7 @@ /// @author rfree (current maintainer in monero.cc project) /// @brief This is the place to implement our handlers for protocol network actions, e.g. for ratelimit for download-requests -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h index f61caf69b..e24c964a5 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.h +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h @@ -2,7 +2,7 @@ /// @author rfree (current maintainer/user in monero.cc project - most of code is from CryptoNote) /// @brief This is the orginal cryptonote protocol network-events handler, modified by us -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -79,7 +79,7 @@ namespace cryptonote typedef t_cryptonote_protocol_handler<t_core> cryptonote_protocol_handler; typedef CORE_SYNC_DATA payload_type; - t_cryptonote_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout); + t_cryptonote_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout, bool offline = false); BEGIN_INVOKE_MAP2(cryptonote_protocol_handler) HANDLE_NOTIFY_T2(NOTIFY_NEW_BLOCK, &cryptonote_protocol_handler::handle_notify_new_block) diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 700eceff3..9475bcaa8 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -2,7 +2,7 @@ /// @author rfree (current maintainer/user in monero.cc project - most of code is from CryptoNote) /// @brief This is the orginal cryptonote protocol network-events handler, modified by us -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -61,10 +61,10 @@ namespace cryptonote //----------------------------------------------------------------------------------------------------------------------- template<class t_core> - t_cryptonote_protocol_handler<t_core>::t_cryptonote_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout):m_core(rcore), + t_cryptonote_protocol_handler<t_core>::t_cryptonote_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout, bool offline):m_core(rcore), m_p2p(p_net_layout), m_syncronized_connections_count(0), - m_synchronized(false), + m_synchronized(offline), m_stopping(false) { @@ -445,7 +445,7 @@ namespace cryptonote // // Also, remember to pepper some whitespace changes around to bother // moneromooo ... only because I <3 him. - std::vector<size_t> need_tx_indices; + std::vector<uint64_t> need_tx_indices; transaction tx; crypto::hash tx_hash; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler_common.h b/src/cryptonote_protocol/cryptonote_protocol_handler_common.h index 1163a0fe8..2b9f201ec 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler_common.h +++ b/src/cryptonote_protocol/cryptonote_protocol_handler_common.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 237105d06..3b1d0d826 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/daemon/command_line_args.h b/src/daemon/command_line_args.h index 7fa58f9d8..ee6167b6a 100644 --- a/src/daemon/command_line_args.h +++ b/src/daemon/command_line_args.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 8970f9407..09e425dd1 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -428,6 +428,23 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args) return m_executor.out_peers(limit); } +bool t_command_parser_executor::in_peers(const std::vector<std::string>& args) +{ + if (args.empty()) return false; + + unsigned int limit; + try { + limit = std::stoi(args[0]); + } + + catch(const std::exception& ex) { + _erro("stoi exception"); + return false; + } + + return m_executor.in_peers(limit); +} + bool t_command_parser_executor::start_save_graph(const std::vector<std::string>& args) { if (!args.empty()) return false; diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 6443d9be0..2c09a4748 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -6,7 +6,7 @@ */ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -108,7 +108,9 @@ public: bool set_limit_down(const std::vector<std::string>& args); bool out_peers(const std::vector<std::string>& args); - + + bool in_peers(const std::vector<std::string>& args); + bool start_save_graph(const std::vector<std::string>& args); bool stop_save_graph(const std::vector<std::string>& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index ecf58e22c..a50dbea69 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -197,6 +197,12 @@ t_command_server::t_command_server( , "Set the <max_number> of out peers." ); m_command_lookup.set_handler( + "in_peers" + , std::bind(&t_command_parser_executor::in_peers, &m_parser, p::_1) + , "in_peers <max_number>" + , "Set the <max_number> of in peers." + ); + m_command_lookup.set_handler( "start_save_graph" , std::bind(&t_command_parser_executor::start_save_graph, &m_parser, p::_1) , "Start saving data for dr monero." diff --git a/src/daemon/command_server.h b/src/daemon/command_server.h index 2ad277f4a..aff74da45 100644 --- a/src/daemon/command_server.h +++ b/src/daemon/command_server.h @@ -9,7 +9,7 @@ Passing RPC commands: */ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/core.h b/src/daemon/core.h index bf4f9bb3d..f00dffccc 100644 --- a/src/daemon/core.h +++ b/src/daemon/core.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 55d868a3c..9b15e62ca 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -68,7 +68,7 @@ public: boost::program_options::variables_map const & vm ) : core{vm} - , protocol{vm, core} + , protocol{vm, core, command_line::get_arg(vm, cryptonote::arg_offline)} , p2p{vm, protocol} { // Handle circular dependencies diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 8c7547f62..1e356ef5f 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/executor.cpp b/src/daemon/executor.cpp index 3379eeca4..fbc7d04fd 100644 --- a/src/daemon/executor.cpp +++ b/src/daemon/executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/executor.h b/src/daemon/executor.h index 35c9e9b47..79d70567a 100644 --- a/src/daemon/executor.h +++ b/src/daemon/executor.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index a47e74c71..7bac2d3d8 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -287,7 +287,7 @@ int main(int argc, char const * argv[]) MINFO("Moving from main() into the daemonize now."); - return daemonizer::daemonize(argc, argv, daemonize::t_executor{}, vm); + return daemonizer::daemonize(argc, argv, daemonize::t_executor{}, vm) ? 0 : 1; } catch (std::exception const & ex) { diff --git a/src/daemon/p2p.h b/src/daemon/p2p.h index 309eb7453..7fcb03751 100644 --- a/src/daemon/p2p.h +++ b/src/daemon/p2p.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemon/protocol.h b/src/daemon/protocol.h index 01de535d5..fd1d1b638 100644 --- a/src/daemon/protocol.h +++ b/src/daemon/protocol.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -46,9 +46,9 @@ private: public: t_protocol( boost::program_options::variables_map const & vm - , t_core & core + , t_core & core, bool offline = false ) - : m_protocol{core.get(), nullptr} + : m_protocol{core.get(), nullptr, offline} { MGINFO("Initializing cryptonote protocol..."); if (!m_protocol.init(vm)) diff --git a/src/daemon/rpc.h b/src/daemon/rpc.h index 9b7438053..17f6c7f67 100644 --- a/src/daemon/rpc.h +++ b/src/daemon/rpc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -60,28 +60,28 @@ public: ) : m_server{core.get(), p2p.get()}, m_description{description} { - MGINFO("Initializing " << m_description << " rpc server..."); + MGINFO("Initializing " << m_description << " RPC server..."); if (!m_server.init(vm, restricted, testnet, port)) { - throw std::runtime_error("Failed to initialize " + m_description + " rpc server."); + throw std::runtime_error("Failed to initialize " + m_description + " RPC server."); } - MGINFO(m_description << " rpc server initialized OK on port: " << m_server.get_binded_port()); + MGINFO(m_description << " RPC server initialized OK on port: " << m_server.get_binded_port()); } void run() { - MGINFO("Starting " << m_description << " rpc server..."); + MGINFO("Starting " << m_description << " RPC server..."); if (!m_server.run(2, false)) { - throw std::runtime_error("Failed to start " + m_description + " rpc server."); + throw std::runtime_error("Failed to start " + m_description + " RPC server."); } - MGINFO(m_description << " rpc server started ok"); + MGINFO(m_description << " RPC server started ok"); } void stop() { - MGINFO("Stopping " << m_description << " rpc server..."); + MGINFO("Stopping " << m_description << " RPC server..."); m_server.send_stop_signal(); m_server.timed_wait_server_stop(5000); } @@ -93,11 +93,11 @@ public: ~t_rpc() { - MGINFO("Deinitializing " << m_description << " rpc server..."); + MGINFO("Deinitializing " << m_description << " RPC server..."); try { m_server.deinit(); } catch (...) { - MERROR("Failed to deinitialize " << m_description << " rpc server..."); + MERROR("Failed to deinitialize " << m_description << " RPC server..."); } } }; diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 2e2411708..5ef799d40 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -353,15 +353,18 @@ static std::string get_fork_extra_info(uint64_t t, uint64_t now, uint64_t block_ return ""; } -static float get_sync_percentage(const cryptonote::COMMAND_RPC_GET_INFO::response &ires) +static float get_sync_percentage(uint64_t height, uint64_t target_height) { - uint64_t height = ires.height; - uint64_t target_height = ires.target_height ? ires.target_height < ires.height ? ires.height : ires.target_height : ires.height; + target_height = target_height ? target_height < height ? height : target_height : height; float pc = 100.0f * height / target_height; if (height < target_height && pc > 99.9f) return 99.9f; // to avoid 100% when not fully synced return pc; } +static float get_sync_percentage(const cryptonote::COMMAND_RPC_GET_INFO::response &ires) +{ + return get_sync_percentage(ires.height, ires.target_height); +} bool t_rpc_command_executor::show_status() { cryptonote::COMMAND_RPC_GET_INFO::request ireq; @@ -421,12 +424,26 @@ bool t_rpc_command_executor::show_status() { std::time_t uptime = std::time(nullptr) - ires.start_time; uint64_t net_height = ires.target_height > ires.height ? ires.target_height : ires.height; + std::string bootstrap_msg; + if (ires.was_bootstrap_ever_used) + { + bootstrap_msg = ", bootstrapping from " + ires.bootstrap_daemon_address; + if (ires.untrusted) + { + bootstrap_msg += (boost::format(", local height: %llu (%.1f%%)") % ires.height_without_bootstrap % get_sync_percentage(ires.height_without_bootstrap, net_height)).str(); + } + else + { + bootstrap_msg += " was used before"; + } + } - tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us") + tools::success_msg_writer() << boost::format("Height: %llu/%llu (%.1f%%) on %s%s, %s, net hash %s, v%u%s, %s, %u(out)+%u(in) connections, uptime %ud %uh %um %us") % (unsigned long long)ires.height % (unsigned long long)net_height % get_sync_percentage(ires) % (ires.testnet ? "testnet" : "mainnet") + % bootstrap_msg % (!has_mining_info ? "mining info unavailable" : mining_busy ? "syncing" : mres.active ? ( ( mres.is_background_mining_enabled ? "smart " : "" ) + std::string("mining at ") + get_mining_speed(mres.speed) ) : "not mining") % get_mining_speed(ires.difficulty / ires.target) % (unsigned)hfres.version @@ -1262,7 +1279,7 @@ bool t_rpc_command_executor::out_peers(uint64_t limit) if (m_is_rpc) { - if (!m_rpc_client->json_rpc_request(req, res, "out_peers", fail_message.c_str())) + if (!m_rpc_client->rpc_request(req, res, "/out_peers", fail_message.c_str())) { return true; } @@ -1281,6 +1298,38 @@ bool t_rpc_command_executor::out_peers(uint64_t limit) return true; } +bool t_rpc_command_executor::in_peers(uint64_t limit) +{ + cryptonote::COMMAND_RPC_IN_PEERS::request req; + cryptonote::COMMAND_RPC_IN_PEERS::response res; + + epee::json_rpc::error error_resp; + + req.in_peers = limit; + + std::string fail_message = "Unsuccessful"; + + if (m_is_rpc) + { + if (!m_rpc_client->rpc_request(req, res, "/in_peers", fail_message.c_str())) + { + return true; + } + } + else + { + if (!m_rpc_server->on_in_peers(req, res) || res.status != CORE_RPC_STATUS_OK) + { + tools::fail_msg_writer() << make_error(fail_message, res.status); + return true; + } + } + + std::cout << "Max number of in peers set to " << limit << std::endl; + + return true; +} + bool t_rpc_command_executor::start_save_graph() { cryptonote::COMMAND_RPC_START_SAVE_GRAPH::request req; diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index efe1ae56a..fa83d8988 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -6,7 +6,7 @@ */ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -122,7 +122,9 @@ public: bool set_limit(int64_t limit_down, int64_t limit_up); bool out_peers(uint64_t limit); - + + bool in_peers(uint64_t limit); + bool start_save_graph(); bool stop_save_graph(); diff --git a/src/daemonizer/CMakeLists.txt b/src/daemonizer/CMakeLists.txt index c8cb1b445..2c0583c49 100644 --- a/src/daemonizer/CMakeLists.txt +++ b/src/daemonizer/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/daemonizer/daemonizer.h b/src/daemonizer/daemonizer.h index 5f53d062b..c5852b59c 100644 --- a/src/daemonizer/daemonizer.h +++ b/src/daemonizer/daemonizer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/posix_daemonizer.inl b/src/daemonizer/posix_daemonizer.inl index 506c7766f..b3f3f262f 100644 --- a/src/daemonizer/posix_daemonizer.inl +++ b/src/daemonizer/posix_daemonizer.inl @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/posix_fork.h b/src/daemonizer/posix_fork.h index 77ef4cb19..9294b00e2 100644 --- a/src/daemonizer/posix_fork.h +++ b/src/daemonizer/posix_fork.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/windows_daemonizer.inl b/src/daemonizer/windows_daemonizer.inl index e02468125..8077f29fb 100644 --- a/src/daemonizer/windows_daemonizer.inl +++ b/src/daemonizer/windows_daemonizer.inl @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/windows_service.cpp b/src/daemonizer/windows_service.cpp index 9b8e46615..b344e1a4b 100644 --- a/src/daemonizer/windows_service.cpp +++ b/src/daemonizer/windows_service.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/windows_service.h b/src/daemonizer/windows_service.h index 070434b04..aacf3d039 100644 --- a/src/daemonizer/windows_service.h +++ b/src/daemonizer/windows_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/daemonizer/windows_service_runner.h b/src/daemonizer/windows_service_runner.h index 528d13a53..06e180823 100644 --- a/src/daemonizer/windows_service_runner.h +++ b/src/daemonizer/windows_service_runner.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/debug_utilities/CMakeLists.txt b/src/debug_utilities/CMakeLists.txt index 7a82c12d9..6942399e4 100644 --- a/src/debug_utilities/CMakeLists.txt +++ b/src/debug_utilities/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/debug_utilities/cn_deserialize.cpp b/src/debug_utilities/cn_deserialize.cpp index 04c0935c8..4f274a66e 100644 --- a/src/debug_utilities/cn_deserialize.cpp +++ b/src/debug_utilities/cn_deserialize.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/debug_utilities/object_sizes.cpp b/src/debug_utilities/object_sizes.cpp index 967742229..a3d037a59 100644 --- a/src/debug_utilities/object_sizes.cpp +++ b/src/debug_utilities/object_sizes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/gen_multisig/CMakeLists.txt b/src/gen_multisig/CMakeLists.txt index 8c534d213..18a6a9efe 100644 --- a/src/gen_multisig/CMakeLists.txt +++ b/src/gen_multisig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, The Monero Project +# Copyright (c) 2017-2018, The Monero Project # # All rights reserved. # diff --git a/src/gen_multisig/gen_multisig.cpp b/src/gen_multisig/gen_multisig.cpp index a9bc7b8fd..64204d8b9 100644 --- a/src/gen_multisig/gen_multisig.cpp +++ b/src/gen_multisig/gen_multisig.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/mnemonics/CMakeLists.txt b/src/mnemonics/CMakeLists.txt index 79964e873..e3836bcca 100644 --- a/src/mnemonics/CMakeLists.txt +++ b/src/mnemonics/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/mnemonics/chinese_simplified.h b/src/mnemonics/chinese_simplified.h index a85bbe963..dd5548ba2 100644 --- a/src/mnemonics/chinese_simplified.h +++ b/src/mnemonics/chinese_simplified.h @@ -21,7 +21,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2017, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/dutch.h b/src/mnemonics/dutch.h index 1cf9b606e..43185cd1d 100644 --- a/src/mnemonics/dutch.h +++ b/src/mnemonics/dutch.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp index f44ad40aa..f1fef2426 100644 --- a/src/mnemonics/electrum-words.cpp +++ b/src/mnemonics/electrum-words.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/mnemonics/electrum-words.h b/src/mnemonics/electrum-words.h index 941768352..48ee378c0 100644 --- a/src/mnemonics/electrum-words.h +++ b/src/mnemonics/electrum-words.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/mnemonics/english.h b/src/mnemonics/english.h index e6cfa8951..d4a89ebbc 100644 --- a/src/mnemonics/english.h +++ b/src/mnemonics/english.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/english_old.h b/src/mnemonics/english_old.h index 9fa5e81e1..8866c8d71 100644 --- a/src/mnemonics/english_old.h +++ b/src/mnemonics/english_old.h @@ -1,6 +1,6 @@ // Word list originally created as part of the Electrum project, Copyright (C) 2014 Thomas Voegtlin
//
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/esperanto.h b/src/mnemonics/esperanto.h index 8589f871e..21ee4c9f1 100644 --- a/src/mnemonics/esperanto.h +++ b/src/mnemonics/esperanto.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/french.h b/src/mnemonics/french.h index ef951b2cc..a472263b3 100644 --- a/src/mnemonics/french.h +++ b/src/mnemonics/french.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/mnemonics/german.h b/src/mnemonics/german.h index 46a8cf1fe..01c483664 100644 --- a/src/mnemonics/german.h +++ b/src/mnemonics/german.h @@ -1,6 +1,6 @@ // Word list created by Monero contributor Shrikez
//
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/italian.h b/src/mnemonics/italian.h index da0e1363c..f9536e2dd 100644 --- a/src/mnemonics/italian.h +++ b/src/mnemonics/italian.h @@ -1,6 +1,6 @@ // Word list created by Monero contributor Shrikez
//
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/japanese.h b/src/mnemonics/japanese.h index fd5425fb1..5b5884c3b 100644 --- a/src/mnemonics/japanese.h +++ b/src/mnemonics/japanese.h @@ -21,7 +21,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2017, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
diff --git a/src/mnemonics/language_base.h b/src/mnemonics/language_base.h index 8f0a7a9d3..2124b8ea4 100644 --- a/src/mnemonics/language_base.h +++ b/src/mnemonics/language_base.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/lojban.h b/src/mnemonics/lojban.h index 8ea9510a3..723f1eac0 100644 --- a/src/mnemonics/lojban.h +++ b/src/mnemonics/lojban.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/portuguese.h b/src/mnemonics/portuguese.h index bb1fe8ee5..f68716962 100644 --- a/src/mnemonics/portuguese.h +++ b/src/mnemonics/portuguese.h @@ -21,7 +21,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2017, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/russian.h b/src/mnemonics/russian.h index bfe970b9d..749191c9b 100644 --- a/src/mnemonics/russian.h +++ b/src/mnemonics/russian.h @@ -1,6 +1,6 @@ // Word list created by Monero contributor sammy007
//
-// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/singleton.h b/src/mnemonics/singleton.h index 5ba9269b1..a15c2b9ae 100644 --- a/src/mnemonics/singleton.h +++ b/src/mnemonics/singleton.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project
+// Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/mnemonics/spanish.h b/src/mnemonics/spanish.h index 9db2a03f3..0c581128e 100644 --- a/src/mnemonics/spanish.h +++ b/src/mnemonics/spanish.h @@ -21,7 +21,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Code surrounding the word list is Copyright (c) 2014-2017, The Monero Project
+// Code surrounding the word list is Copyright (c) 2014-2018, The Monero Project
//
// All rights reserved.
//
diff --git a/src/multisig/CMakeLists.txt b/src/multisig/CMakeLists.txt index 432865ad3..a770c6dc5 100644 --- a/src/multisig/CMakeLists.txt +++ b/src/multisig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, The Monero Project +# Copyright (c) 2017-2018, The Monero Project # # All rights reserved. # diff --git a/src/multisig/multisig.cpp b/src/multisig/multisig.cpp index 39d0e1c4b..6c05a38d9 100644 --- a/src/multisig/multisig.cpp +++ b/src/multisig/multisig.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/multisig/multisig.h b/src/multisig/multisig.h index f29b47987..f95611441 100644 --- a/src/multisig/multisig.h +++ b/src/multisig/multisig.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/p2p/CMakeLists.txt b/src/p2p/CMakeLists.txt index 3fc053dc7..9421a1477 100644 --- a/src/p2p/CMakeLists.txt +++ b/src/p2p/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp index 4ea08a1f8..994941168 100644 --- a/src/p2p/net_node.cpp +++ b/src/p2p/net_node.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -55,6 +55,7 @@ namespace nodetool const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"}; const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max number of out peers", -1}; + const command_line::arg_descriptor<int64_t> arg_in_peers = {"in-peers", "set max number of in peers", -1}; const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1}; const command_line::arg_descriptor<int64_t> arg_limit_rate_up = {"limit-rate-up", "set limit-rate-up [kB/s]", -1}; diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 294ccde9e..568c650cc 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -81,6 +81,7 @@ namespace nodetool node_server(t_payload_net_handler& payload_handler) :m_payload_handler(payload_handler), m_current_number_of_out_peers(0), + m_current_number_of_in_peers(0), m_allow_local_ip(false), m_hide_my_port(false), m_no_igd(false), @@ -117,8 +118,10 @@ namespace nodetool bool log_connections(); virtual uint64_t get_connections_count(); size_t get_outgoing_connections_count(); + size_t get_incoming_connections_count(); peerlist_manager& get_peerlist_manager(){return m_peerlist;} - void delete_connections(size_t count); + void delete_out_connections(size_t count); + void delete_in_connections(size_t count); virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME); virtual bool unblock_host(const epee::net_utils::network_address &address); virtual std::map<std::string, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; } @@ -230,6 +233,7 @@ namespace nodetool bool parse_peers_and_add_to_container(const boost::program_options::variables_map& vm, const command_line::arg_descriptor<std::vector<std::string> > & arg, Container& container); bool set_max_out_peers(const boost::program_options::variables_map& vm, int64_t max); + bool set_max_in_peers(const boost::program_options::variables_map& vm, int64_t max); bool set_tos_flag(const boost::program_options::variables_map& vm, int limit); bool set_rate_up_limit(const boost::program_options::variables_map& vm, int64_t limit); @@ -271,6 +275,7 @@ namespace nodetool public: config m_config; // TODO was private, add getters? std::atomic<unsigned int> m_current_number_of_out_peers; + std::atomic<unsigned int> m_current_number_of_in_peers; void set_save_graph(bool save_graph) { @@ -345,6 +350,7 @@ namespace nodetool extern const command_line::arg_descriptor<bool> arg_no_igd; extern const command_line::arg_descriptor<bool> arg_offline; extern const command_line::arg_descriptor<int64_t> arg_out_peers; + extern const command_line::arg_descriptor<int64_t> arg_in_peers; extern const command_line::arg_descriptor<int> arg_tos_flag; extern const command_line::arg_descriptor<int64_t> arg_limit_rate_up; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index f8b96d7a4..3445674f6 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -85,6 +85,7 @@ namespace nodetool command_line::add_arg(desc, arg_p2p_hide_my_port); command_line::add_arg(desc, arg_no_igd); command_line::add_arg(desc, arg_out_peers); + command_line::add_arg(desc, arg_in_peers); command_line::add_arg(desc, arg_tos_flag); command_line::add_arg(desc, arg_limit_rate_up); command_line::add_arg(desc, arg_limit_rate_down); @@ -270,6 +271,7 @@ namespace nodetool 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); m_offline = command_line::get_arg(vm, cryptonote::arg_offline); + m_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); if (command_line::has_arg(vm, arg_p2p_add_peer)) { @@ -314,6 +316,9 @@ namespace nodetool if ( !set_max_out_peers(vm, command_line::get_arg(vm, arg_out_peers) ) ) return false; + if ( !set_max_in_peers(vm, command_line::get_arg(vm, arg_in_peers) ) ) + return false; + if ( !set_tos_flag(vm, command_line::get_arg(vm, arg_tos_flag) ) ) return false; @@ -398,14 +403,16 @@ namespace nodetool bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm) { std::set<std::string> full_addrs; - m_testnet = command_line::get_arg(vm, cryptonote::arg_testnet_on); + + bool res = handle_command_line(vm); + CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); if (m_testnet) { memcpy(&m_network_id, &::config::testnet::NETWORK_ID, 16); full_addrs = get_seed_nodes(true); } - else + else if (m_exclusive_peers.empty()) { memcpy(&m_network_id, &::config::NETWORK_ID, 16); // for each hostname in the seed nodes list, attempt to DNS resolve and @@ -496,9 +503,6 @@ namespace nodetool } MDEBUG("Number of seed nodes: " << m_seed_nodes.size()); - bool res = handle_command_line(vm); - CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); - auto config_arg = m_testnet ? cryptonote::arg_testnet_data_dir : cryptonote::arg_data_dir; m_config_folder = command_line::get_arg(vm, config_arg); @@ -565,14 +569,23 @@ namespace nodetool while (!is_closing && !m_net_server.is_stop_signal_sent()) { // main loop of thread //number_of_peers = m_net_server.get_config_object().get_connections_count(); - unsigned int number_of_peers = 0; + unsigned int number_of_in_peers = 0; + unsigned int number_of_out_peers = 0; m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) { - if (!cntxt.m_is_income) ++number_of_peers; + if (cntxt.m_is_income) + { + ++number_of_in_peers; + } + else + { + ++number_of_out_peers; + } return true; }); // lambda - m_current_number_of_out_peers = number_of_peers; + m_current_number_of_in_peers = number_of_in_peers; + m_current_number_of_out_peers = number_of_out_peers; boost::this_thread::sleep_for(boost::chrono::seconds(1)); } // main loop of thread @@ -871,11 +884,11 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::try_to_connect_and_handshake_with_new_peer(const epee::net_utils::network_address& na, bool just_take_peerlist, uint64_t last_seen_stamp, PeerType peer_type, uint64_t first_seen_stamp) { - if (m_current_number_of_out_peers == m_config.m_net_config.connections_count) // out peers limit + if (m_current_number_of_out_peers == m_config.m_net_config.max_out_connection_count) // out peers limit { return false; } - else if (m_current_number_of_out_peers > m_config.m_net_config.connections_count) + else if (m_current_number_of_out_peers > m_config.m_net_config.max_out_connection_count) { m_net_server.get_config_object().del_out_connections(1); m_current_number_of_out_peers --; // atomic variable, update time = 1s @@ -1110,7 +1123,7 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::connect_to_seed() { - if (m_seed_nodes.empty() || m_offline) + if (m_seed_nodes.empty() || m_offline || !m_exclusive_peers.empty()) return true; size_t try_count = 0; @@ -1164,10 +1177,10 @@ namespace nodetool if (!connect_to_peerlist(m_priority_peers)) return false; - size_t expected_white_connections = (m_config.m_net_config.connections_count*P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT)/100; + size_t expected_white_connections = (m_config.m_net_config.max_out_connection_count*P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT)/100; size_t conn_count = get_outgoing_connections_count(); - if(conn_count < m_config.m_net_config.connections_count) + if(conn_count < m_config.m_net_config.max_out_connection_count) { if(conn_count < expected_white_connections) { @@ -1178,20 +1191,20 @@ namespace nodetool if(!make_expected_connections_count(white, expected_white_connections)) return false; //then do grey list - if(!make_expected_connections_count(gray, m_config.m_net_config.connections_count)) + if(!make_expected_connections_count(gray, m_config.m_net_config.max_out_connection_count)) return false; }else { //start from grey list - if(!make_expected_connections_count(gray, m_config.m_net_config.connections_count)) + if(!make_expected_connections_count(gray, m_config.m_net_config.max_out_connection_count)) return false; //and then do white list - if(!make_expected_connections_count(white, m_config.m_net_config.connections_count)) + if(!make_expected_connections_count(white, m_config.m_net_config.max_out_connection_count)) return false; } } - if (start_conn_count == get_outgoing_connections_count() && start_conn_count < m_config.m_net_config.connections_count) + if (start_conn_count == get_outgoing_connections_count() && start_conn_count < m_config.m_net_config.max_out_connection_count) { MINFO("Failed to connect to any, trying seeds"); if (!connect_to_seed()) @@ -1253,6 +1266,20 @@ namespace nodetool } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> + size_t node_server<t_payload_net_handler>::get_incoming_connections_count() + { + size_t count = 0; + m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) + { + if(cntxt.m_is_income) + ++count; + return true; + }); + + return count; + } + //----------------------------------------------------------------------------------- + template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::idle_worker() { m_peer_handshake_idle_maker_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::peer_sync_idle_maker, this)); @@ -1618,6 +1645,13 @@ namespace nodetool return 1; } + if (m_current_number_of_in_peers >= m_config.m_net_config.max_in_connection_count) // in peers limit + { + LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came, but already have max incoming connections, so dropping this one."); + drop_connection(context); + return 1; + } + if(!m_payload_handler.process_payload_sync_data(arg.payload_data, context, true)) { LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came, but process_payload_sync_data returned false, dropping connection."); @@ -1779,20 +1813,37 @@ namespace nodetool bool node_server<t_payload_net_handler>::set_max_out_peers(const boost::program_options::variables_map& vm, int64_t max) { if(max == -1) { - m_config.m_net_config.connections_count = P2P_DEFAULT_CONNECTIONS_COUNT; + m_config.m_net_config.max_out_connection_count = P2P_DEFAULT_CONNECTIONS_COUNT; + return true; + } + m_config.m_net_config.max_out_connection_count = max; + return true; + } + + template<class t_payload_net_handler> + bool node_server<t_payload_net_handler>::set_max_in_peers(const boost::program_options::variables_map& vm, int64_t max) + { + if(max == -1) { + m_config.m_net_config.max_in_connection_count = -1; return true; } - m_config.m_net_config.connections_count = max; + m_config.m_net_config.max_in_connection_count = max; return true; } template<class t_payload_net_handler> - void node_server<t_payload_net_handler>::delete_connections(size_t count) + void node_server<t_payload_net_handler>::delete_out_connections(size_t count) { m_net_server.get_config_object().del_out_connections(count); } template<class t_payload_net_handler> + void node_server<t_payload_net_handler>::delete_in_connections(size_t count) + { + m_net_server.get_config_object().del_in_connections(count); + } + + template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::set_tos_flag(const boost::program_options::variables_map& vm, int flag) { if(flag==-1){ diff --git a/src/p2p/net_node_common.h b/src/p2p/net_node_common.h index 26bad7c72..218250efa 100644 --- a/src/p2p/net_node_common.h +++ b/src/p2p/net_node_common.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index 8216e9be6..1d609a37e 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/p2p/net_peerlist_boost_serialization.h b/src/p2p/net_peerlist_boost_serialization.h index 079524aa1..e79207888 100644 --- a/src/p2p/net_peerlist_boost_serialization.h +++ b/src/p2p/net_peerlist_boost_serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 181854e8e..e793e19b6 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -131,13 +131,15 @@ namespace nodetool struct network_config { BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(connections_count) + KV_SERIALIZE(max_out_connection_count) + KV_SERIALIZE(max_in_connection_count) KV_SERIALIZE(handshake_interval) KV_SERIALIZE(packet_max_size) KV_SERIALIZE(config_id) END_KV_SERIALIZE_MAP() - uint32_t connections_count; + uint32_t max_out_connection_count; + uint32_t max_in_connection_count; uint32_t connection_timeout; uint32_t ping_connection_timeout; uint32_t handshake_interval; diff --git a/src/p2p/stdafx.h b/src/p2p/stdafx.h index 5e9baa895..b6ff37811 100644 --- a/src/p2p/stdafx.h +++ b/src/p2p/stdafx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/platform/mingw/alloca.h b/src/platform/mingw/alloca.h index f850d1cdf..71934b19a 100644 --- a/src/platform/mingw/alloca.h +++ b/src/platform/mingw/alloca.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/platform/msc/alloca.h b/src/platform/msc/alloca.h index 2f3f79a3f..89743e12b 100644 --- a/src/platform/msc/alloca.h +++ b/src/platform/msc/alloca.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/platform/msc/inline_c.h b/src/platform/msc/inline_c.h index 030604ef8..b274f3ec2 100644 --- a/src/platform/msc/inline_c.h +++ b/src/platform/msc/inline_c.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/platform/msc/stdbool.h b/src/platform/msc/stdbool.h index 05d2e7a38..63e4200b2 100644 --- a/src/platform/msc/stdbool.h +++ b/src/platform/msc/stdbool.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/platform/msc/sys/param.h b/src/platform/msc/sys/param.h index db6eca28b..ca9c9282d 100644 --- a/src/platform/msc/sys/param.h +++ b/src/platform/msc/sys/param.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/ringct/CMakeLists.txt b/src/ringct/CMakeLists.txt index 1452e5367..3a28997dd 100644 --- a/src/ringct/CMakeLists.txt +++ b/src/ringct/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2016, The Monero Project +# Copyright (c) 2016-2018, The Monero Project # # All rights reserved. # diff --git a/src/ringct/bulletproofs.cc b/src/ringct/bulletproofs.cc index 51cf9e3be..fd15ffbc4 100644 --- a/src/ringct/bulletproofs.cc +++ b/src/ringct/bulletproofs.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // @@ -297,6 +297,39 @@ static rct::keyV slice(const rct::keyV &a, size_t start, size_t stop) return res; } +static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1) +{ + rct::keyV data; + data.reserve(3); + data.push_back(hash_cache); + data.push_back(mash0); + data.push_back(mash1); + return hash_cache = rct::hash_to_scalar(data); +} + +static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1, const rct::key &mash2) +{ + rct::keyV data; + data.reserve(4); + data.push_back(hash_cache); + data.push_back(mash0); + data.push_back(mash1); + data.push_back(mash2); + return hash_cache = rct::hash_to_scalar(data); +} + +static rct::key hash_cache_mash(rct::key &hash_cache, const rct::key &mash0, const rct::key &mash1, const rct::key &mash2, const rct::key &mash3) +{ + rct::keyV data; + data.reserve(5); + data.push_back(hash_cache); + data.push_back(mash0); + data.push_back(mash1); + data.push_back(mash2); + data.push_back(mash3); + return hash_cache = rct::hash_to_scalar(data); +} + /* Given a value v (0..2^N-1) and a mask gamma, construct a range proof */ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) { @@ -329,6 +362,7 @@ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) } PERF_TIMER_STOP(PROVE_aLaR); + rct::key hash_cache = rct::hash_to_scalar(V); // DEBUG: Test to ensure this recovers the value #ifdef DEBUG_BP @@ -361,11 +395,8 @@ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) rct::addKeys(S, ve, rct::scalarmultBase(rho)); // PAPER LINES 43-45 - rct::keyV hashed; - hashed.push_back(A); - hashed.push_back(S); - rct::key y = rct::hash_to_scalar(hashed); - rct::key z = rct::hash_to_scalar(y); + rct::key y = hash_cache_mash(hash_cache, A, S); + rct::key z = hash_cache = rct::hash_to_scalar(y); // Polynomial construction before PAPER LINE 46 rct::key t0 = rct::zero(); @@ -427,11 +458,7 @@ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) rct::key T2 = rct::addKeys(rct::scalarmultKey(rct::H, t2), rct::scalarmultBase(tau2)); // PAPER LINES 49-51 - hashed.clear(); - hashed.push_back(z); - hashed.push_back(T1); - hashed.push_back(T2); - rct::key x = rct::hash_to_scalar(hashed); + rct::key x = hash_cache_mash(hash_cache, z, T1, T2); // PAPER LINES 52-53 rct::key taux = rct::zero(); @@ -460,12 +487,7 @@ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) #endif // PAPER LINES 32-33 - hashed.clear(); - hashed.push_back(x); - hashed.push_back(taux); - hashed.push_back(mu); - hashed.push_back(t); - rct::key x_ip = rct::hash_to_scalar(hashed); + rct::key x_ip = hash_cache_mash(hash_cache, x, taux, mu, t); // These are used in the inner product rounds size_t nprime = N; @@ -509,20 +531,7 @@ Bulletproof bulletproof_PROVE(const rct::key &sv, const rct::key &gamma) rct::addKeys(R[round], R[round], rct::scalarmultKey(rct::H, tmp)); // PAPER LINES 21-22 - hashed.clear(); - if (round == 0) - { - hashed.push_back(L[0]); - hashed.push_back(R[0]); - w[0] = rct::hash_to_scalar(hashed); - } - else - { - hashed.push_back(w[round - 1]); - hashed.push_back(L[round]); - hashed.push_back(R[round]); - w[round] = rct::hash_to_scalar(hashed); - } + w[round] = hash_cache_mash(hash_cache, L[round], R[round]); // PAPER LINES 24-25 const rct::key winv = invert(w[round]); @@ -563,6 +572,7 @@ bool bulletproof_VERIFY(const Bulletproof &proof) { init_exponents(); + CHECK_AND_ASSERT_MES(proof.V.size() == 1, false, "V does not have exactly one element"); CHECK_AND_ASSERT_MES(proof.L.size() == proof.R.size(), false, "Mismatched L and R sizes"); CHECK_AND_ASSERT_MES(proof.L.size() > 0, false, "Empty proof"); CHECK_AND_ASSERT_MES(proof.L.size() == 6, false, "Proof is not for 64 bits"); @@ -573,26 +583,15 @@ bool bulletproof_VERIFY(const Bulletproof &proof) // Reconstruct the challenges PERF_TIMER_START_BP(VERIFY); PERF_TIMER_START_BP(VERIFY_start); - rct::keyV hashed; - hashed.push_back(proof.A); - hashed.push_back(proof.S); - rct::key y = rct::hash_to_scalar(hashed); - rct::key z = rct::hash_to_scalar(y); - hashed.clear(); - hashed.push_back(z); - hashed.push_back(proof.T1); - hashed.push_back(proof.T2); - rct::key x = rct::hash_to_scalar(hashed); + rct::key hash_cache = rct::hash_to_scalar(proof.V[0]); + rct::key y = hash_cache_mash(hash_cache, proof.A, proof.S); + rct::key z = hash_cache = rct::hash_to_scalar(y); + rct::key x = hash_cache_mash(hash_cache, z, proof.T1, proof.T2); PERF_TIMER_STOP(VERIFY_start); PERF_TIMER_START_BP(VERIFY_line_60); // Reconstruct the challenges - hashed.clear(); - hashed.push_back(x); - hashed.push_back(proof.taux); - hashed.push_back(proof.mu); - hashed.push_back(proof.t); - rct::key x_ip = hash_to_scalar(hashed); + rct::key x_ip = hash_cache_mash(hash_cache, x, proof.taux, proof.mu, proof.t); PERF_TIMER_STOP(VERIFY_line_60); PERF_TIMER_START_BP(VERIFY_line_61); @@ -647,17 +646,9 @@ bool bulletproof_VERIFY(const Bulletproof &proof) // PAPER LINES 21-22 // The inner product challenges are computed per round rct::keyV w(rounds); - hashed.clear(); - hashed.push_back(proof.L[0]); - hashed.push_back(proof.R[0]); - w[0] = rct::hash_to_scalar(hashed); - for (size_t i = 1; i < rounds; ++i) + for (size_t i = 0; i < rounds; ++i) { - hashed.clear(); - hashed.push_back(w[i-1]); - hashed.push_back(proof.L[i]); - hashed.push_back(proof.R[i]); - w[i] = rct::hash_to_scalar(hashed); + w[i] = hash_cache_mash(hash_cache, proof.L[i], proof.R[i]); } PERF_TIMER_STOP(VERIFY_line_21_22); diff --git a/src/ringct/bulletproofs.h b/src/ringct/bulletproofs.h index aca470f47..3061d272e 100644 --- a/src/ringct/bulletproofs.h +++ b/src/ringct/bulletproofs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/ringct/rctCryptoOps.c b/src/ringct/rctCryptoOps.c index f69d692f6..6fdd17f6b 100644 --- a/src/ringct/rctCryptoOps.c +++ b/src/ringct/rctCryptoOps.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/ringct/rctCryptoOps.h b/src/ringct/rctCryptoOps.h index 2674c2243..e5c1c987a 100644 --- a/src/ringct/rctCryptoOps.h +++ b/src/ringct/rctCryptoOps.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/ringct/rctSigs.cpp b/src/ringct/rctSigs.cpp index 3c34a5637..0c2be5add 100644 --- a/src/ringct/rctSigs.cpp +++ b/src/ringct/rctSigs.cpp @@ -43,6 +43,30 @@ using namespace std; #define MONERO_DEFAULT_LOG_CATEGORY "ringct" namespace rct { + bool is_simple(int type) + { + switch (type) + { + case RCTTypeSimple: + case RCTTypeSimpleBulletproof: + return true; + default: + return false; + } + } + + bool is_bulletproof(int type) + { + switch (type) + { + case RCTTypeSimpleBulletproof: + case RCTTypeFullBulletproof: + return true; + default: + return false; + } + } + Bulletproof proveRangeBulletproof(key &C, key &mask, uint64_t amount) { mask = rct::skGen(); @@ -357,7 +381,8 @@ namespace rct { std::stringstream ss; binary_archive<true> ba(ss); - const size_t inputs = rv.pseudoOuts.size(); + CHECK_AND_ASSERT_THROW_MES(!rv.mixRing.empty(), "Empty mixRing"); + const size_t inputs = is_simple(rv.type) ? rv.mixRing.size() : rv.mixRing[0].size(); const size_t outputs = rv.ecdhInfo.size(); CHECK_AND_ASSERT_THROW_MES(const_cast<rctSig&>(rv).serialize_rctsig_base(ba, inputs, outputs), "Failed to serialize rctSigBase"); @@ -750,25 +775,26 @@ namespace rct { // TODO: unused ?? // key txnFeeKey = scalarmultH(d2h(rv.txnFee)); rv.mixRing = mixRing; - rv.pseudoOuts.resize(inamounts.size()); + keyV &pseudoOuts = bulletproof ? rv.p.pseudoOuts : rv.pseudoOuts; + pseudoOuts.resize(inamounts.size()); rv.p.MGs.resize(inamounts.size()); key sumpouts = zero(); //sum pseudoOut masks keyV a(inamounts.size()); for (i = 0 ; i < inamounts.size() - 1; i++) { skGen(a[i]); sc_add(sumpouts.bytes, a[i].bytes, sumpouts.bytes); - genC(rv.pseudoOuts[i], a[i], inamounts[i]); + genC(pseudoOuts[i], a[i], inamounts[i]); } rv.mixRing = mixRing; sc_sub(a[i].bytes, sumout.bytes, sumpouts.bytes); - genC(rv.pseudoOuts[i], a[i], inamounts[i]); - DP(rv.pseudoOuts[i]); + genC(pseudoOuts[i], a[i], inamounts[i]); + DP(pseudoOuts[i]); key full_message = get_pre_mlsag_hash(rv); if (msout) msout->c.resize(inamounts.size()); for (i = 0 ; i < inamounts.size(); i++) { - rv.p.MGs[i] = proveRctMGSimple(full_message, rv.mixRing[i], inSk[i], a[i], rv.pseudoOuts[i], kLRki ? &(*kLRki)[i]: NULL, msout ? &msout->c[i] : NULL, index[i]); + rv.p.MGs[i] = proveRctMGSimple(full_message, rv.mixRing[i], inSk[i], a[i], pseudoOuts[i], kLRki ? &(*kLRki)[i]: NULL, msout ? &msout->c[i] : NULL, index[i]); } return rv; } @@ -876,16 +902,26 @@ namespace rct { if (semantics) { if (rv.type == RCTTypeSimpleBulletproof) + { CHECK_AND_ASSERT_MES(rv.outPk.size() == rv.p.bulletproofs.size(), false, "Mismatched sizes of outPk and rv.p.bulletproofs"); + CHECK_AND_ASSERT_MES(rv.p.pseudoOuts.size() == rv.p.MGs.size(), false, "Mismatched sizes of rv.p.pseudoOuts and rv.p.MGs"); + CHECK_AND_ASSERT_MES(rv.pseudoOuts.empty(), false, "rv.pseudoOuts is not empty"); + } else + { CHECK_AND_ASSERT_MES(rv.outPk.size() == rv.p.rangeSigs.size(), false, "Mismatched sizes of outPk and rv.p.rangeSigs"); + CHECK_AND_ASSERT_MES(rv.pseudoOuts.size() == rv.p.MGs.size(), false, "Mismatched sizes of rv.pseudoOuts and rv.p.MGs"); + CHECK_AND_ASSERT_MES(rv.p.pseudoOuts.empty(), false, "rv.p.pseudoOuts is not empty"); + } CHECK_AND_ASSERT_MES(rv.outPk.size() == rv.ecdhInfo.size(), false, "Mismatched sizes of outPk and rv.ecdhInfo"); - CHECK_AND_ASSERT_MES(rv.pseudoOuts.size() == rv.p.MGs.size(), false, "Mismatched sizes of rv.pseudoOuts and rv.p.MGs"); } else { // semantics check is early, and mixRing/MGs aren't resolved yet - CHECK_AND_ASSERT_MES(rv.pseudoOuts.size() == rv.mixRing.size(), false, "Mismatched sizes of rv.pseudoOuts and mixRing"); + if (rv.type == RCTTypeSimpleBulletproof) + CHECK_AND_ASSERT_MES(rv.p.pseudoOuts.size() == rv.mixRing.size(), false, "Mismatched sizes of rv.p.pseudoOuts and mixRing"); + else + CHECK_AND_ASSERT_MES(rv.pseudoOuts.size() == rv.mixRing.size(), false, "Mismatched sizes of rv.pseudoOuts and mixRing"); } const size_t threads = std::max(rv.outPk.size(), rv.mixRing.size()); @@ -894,6 +930,8 @@ namespace rct { tools::threadpool& tpool = tools::threadpool::getInstance(); tools::threadpool::waiter waiter; + const keyV &pseudoOuts = is_bulletproof(rv.type) ? rv.p.pseudoOuts : rv.pseudoOuts; + if (semantics) { key sumOutpks = identity(); for (size_t i = 0; i < rv.outPk.size(); i++) { @@ -904,8 +942,8 @@ namespace rct { addKeys(sumOutpks, txnFeeKey, sumOutpks); key sumPseudoOuts = identity(); - for (size_t i = 0 ; i < rv.pseudoOuts.size() ; i++) { - addKeys(sumPseudoOuts, sumPseudoOuts, rv.pseudoOuts[i]); + for (size_t i = 0 ; i < pseudoOuts.size() ; i++) { + addKeys(sumPseudoOuts, sumPseudoOuts, pseudoOuts[i]); } DP(sumPseudoOuts); @@ -941,7 +979,7 @@ namespace rct { results.resize(rv.mixRing.size()); for (size_t i = 0 ; i < rv.mixRing.size() ; i++) { tpool.submit(&waiter, [&, i] { - results[i] = verRctMGSimple(message, rv.p.MGs[i], rv.mixRing[i], rv.pseudoOuts[i]); + results[i] = verRctMGSimple(message, rv.p.MGs[i], rv.mixRing[i], pseudoOuts[i]); }); } waiter.wait(); diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 2df797360..eba1e3d93 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -246,7 +246,7 @@ namespace rct { // inputs/outputs not saved, only here for serialization help // FIELD(message) - not serialized, it can be reconstructed // FIELD(mixRing) - not serialized, it can be reconstructed - if (type == RCTTypeSimple || type == RCTTypeSimpleBulletproof) + if (type == RCTTypeSimple) // moved to prunable with bulletproofs { ar.tag("pseudoOuts"); ar.begin_array(); @@ -294,6 +294,7 @@ namespace rct { std::vector<rangeSig> rangeSigs; std::vector<Bulletproof> bulletproofs; std::vector<mgSig> MGs; // simple rct has N, full has 1 + keyV pseudoOuts; //C - for simple rct template<bool W, template <bool> class Archive> bool serialize_rctsig_prunable(Archive<W> &ar, uint8_t type, size_t inputs, size_t outputs, size_t mixin) @@ -381,6 +382,21 @@ namespace rct { ar.delimit_array(); } ar.end_array(); + if (type == RCTTypeSimpleBulletproof) + { + ar.tag("pseudoOuts"); + ar.begin_array(); + PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, pseudoOuts); + if (pseudoOuts.size() != inputs) + return false; + for (size_t i = 0; i < inputs; ++i) + { + FIELDS(pseudoOuts[i]) + if (inputs - i > 1) + ar.delimit_array(); + } + ar.end_array(); + } return true; } diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt index 19ea93902..7162317ed 100644 --- a/src/rpc/CMakeLists.txt +++ b/src/rpc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 4966b107d..da2e79dfa 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -42,6 +42,7 @@ using namespace epee; #include "cryptonote_basic/account.h" #include "cryptonote_basic/cryptonote_basic_impl.h" #include "misc_language.h" +#include "storages/http_abstract_invoke.h" #include "crypto/hash.h" #include "rpc/rpc_args.h" #include "core_rpc_server_error_codes.h" @@ -75,6 +76,8 @@ namespace cryptonote 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); cryptonote::rpc_args::init_options(desc); } //------------------------------------------------------------------------------------------------------------------------------ @@ -101,6 +104,30 @@ namespace cryptonote if (!rpc_config) return false; + m_bootstrap_daemon_address = command_line::get_arg(vm, arg_bootstrap_daemon_address); + if (!m_bootstrap_daemon_address.empty()) + { + const std::string &bootstrap_daemon_login = command_line::get_arg(vm, arg_bootstrap_daemon_login); + const auto loc = bootstrap_daemon_login.find(':'); + if (!bootstrap_daemon_login.empty() && loc != std::string::npos) + { + epee::net_utils::http::login login; + login.username = bootstrap_daemon_login.substr(0, loc); + login.password = bootstrap_daemon_login.substr(loc + 1); + m_http_client.set_server(m_bootstrap_daemon_address, login, false); + } + else + { + m_http_client.set_server(m_bootstrap_daemon_address, boost::none, false); + } + m_should_use_bootstrap_daemon = true; + } + else + { + m_should_use_bootstrap_daemon = false; + } + m_was_bootstrap_ever_used = false; + boost::optional<epee::net_utils::http::login> http_login{}; if (rpc_config->login) @@ -126,6 +153,10 @@ namespace cryptonote bool core_rpc_server::on_get_height(const COMMAND_RPC_GET_HEIGHT::request& req, COMMAND_RPC_GET_HEIGHT::response& res) { PERF_TIMER(on_get_height); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_HEIGHT>(invoke_http_mode::JON, "/getheight", req, res, r)) + return r; + res.height = m_core.get_current_blockchain_height(); res.status = CORE_RPC_STATUS_OK; return true; @@ -134,6 +165,17 @@ namespace cryptonote bool core_rpc_server::on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res) { PERF_TIMER(on_get_info); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_INFO>(invoke_http_mode::JON, "/getinfo", req, res, r)) + { + res.bootstrap_daemon_address = m_bootstrap_daemon_address; + crypto::hash top_hash; + m_core.get_blockchain_top(res.height_without_bootstrap, top_hash); + ++res.height_without_bootstrap; // turn top block height into blockchain height + res.was_bootstrap_ever_used = true; + return r; + } + crypto::hash top_hash; m_core.get_blockchain_top(res.height, top_hash); ++res.height; // turn top block height into blockchain height @@ -153,10 +195,17 @@ namespace cryptonote res.testnet = m_testnet; res.cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.height - 1); res.block_size_limit = m_core.get_blockchain_storage().get_current_cumulative_blocksize_limit(); + res.block_size_median = m_core.get_blockchain_storage().get_current_cumulative_blocksize_median(); res.status = CORE_RPC_STATUS_OK; res.start_time = (uint64_t)m_core.get_start_time(); res.free_space = m_restricted ? std::numeric_limits<uint64_t>::max() : m_core.get_free_space(); res.offline = m_core.offline(); + res.bootstrap_daemon_address = m_bootstrap_daemon_address; + res.height_without_bootstrap = res.height; + { + boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + res.was_bootstrap_ever_used = m_was_bootstrap_ever_used; + } return true; } //------------------------------------------------------------------------------------------------------------------------------ @@ -180,6 +229,10 @@ namespace cryptonote bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res) { PERF_TIMER(on_get_blocks); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCKS_FAST>(invoke_http_mode::BIN, "/getblocks.bin", req, res, r)) + return r; + std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > > bs; if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT)) @@ -239,6 +292,10 @@ namespace cryptonote bool core_rpc_server::on_get_alt_blocks_hashes(const COMMAND_RPC_GET_ALT_BLOCKS_HASHES::request& req, COMMAND_RPC_GET_ALT_BLOCKS_HASHES::response& res) { PERF_TIMER(on_get_alt_blocks_hashes); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_ALT_BLOCKS_HASHES>(invoke_http_mode::JON, "/get_alt_blocks_hashes", req, res, r)) + return r; + std::list<block> blks; if(!m_core.get_alternative_blocks(blks)) @@ -262,6 +319,10 @@ namespace cryptonote bool core_rpc_server::on_get_blocks_by_height(const COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response& res) { PERF_TIMER(on_get_blocks_by_height); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCKS_BY_HEIGHT>(invoke_http_mode::BIN, "/getblocks_by_height.bin", req, res, r)) + return r; + res.status = "Failed"; res.blocks.clear(); res.blocks.reserve(req.heights.size()); @@ -292,6 +353,10 @@ namespace cryptonote bool core_rpc_server::on_get_hashes(const COMMAND_RPC_GET_HASHES_FAST::request& req, COMMAND_RPC_GET_HASHES_FAST::response& res) { PERF_TIMER(on_get_hashes); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_HASHES_FAST>(invoke_http_mode::BIN, "/gethashes.bin", req, res, r)) + return r; + NOTIFY_RESPONSE_CHAIN_ENTRY::request resp; resp.start_height = req.start_height; @@ -311,6 +376,10 @@ namespace cryptonote bool core_rpc_server::on_get_random_outs(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res) { PERF_TIMER(on_get_random_outs); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS>(invoke_http_mode::BIN, "/getrandom_outs.bin", req, res, r)) + return r; + res.status = "Failed"; if (m_restricted) @@ -350,6 +419,10 @@ namespace cryptonote bool core_rpc_server::on_get_outs_bin(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res) { PERF_TIMER(on_get_outs_bin); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUTS_BIN>(invoke_http_mode::BIN, "/get_outs.bin", req, res, r)) + return r; + res.status = "Failed"; if (m_restricted) @@ -373,6 +446,10 @@ namespace cryptonote bool core_rpc_server::on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res) { PERF_TIMER(on_get_outs); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUTS>(invoke_http_mode::JON, "/get_outs", req, res, r)) + return r; + res.status = "Failed"; if (m_restricted) @@ -411,6 +488,10 @@ namespace cryptonote bool core_rpc_server::on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res) { PERF_TIMER(on_get_random_rct_outs); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS>(invoke_http_mode::BIN, "/getrandom_rctouts.bin", req, res, r)) + return r; + res.status = "Failed"; if(!m_core.get_random_rct_outs(req, res)) { @@ -435,6 +516,10 @@ namespace cryptonote bool core_rpc_server::on_get_indexes(const COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res) { PERF_TIMER(on_get_indexes); + bool ok; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES>(invoke_http_mode::BIN, "/get_o_indexes.bin", req, res, ok)) + return ok; + bool r = m_core.get_tx_outputs_gindexs(req.txid, res.o_indexes); if(!r) { @@ -449,6 +534,10 @@ namespace cryptonote bool core_rpc_server::on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res) { PERF_TIMER(on_get_transactions); + bool ok; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTIONS>(invoke_http_mode::JON, "/gettransactions", req, res, ok)) + return ok; + std::vector<crypto::hash> vh; for(const auto& tx_hex_str: req.txs_hashes) { @@ -599,6 +688,10 @@ namespace cryptonote bool core_rpc_server::on_is_key_image_spent(const COMMAND_RPC_IS_KEY_IMAGE_SPENT::request& req, COMMAND_RPC_IS_KEY_IMAGE_SPENT::response& res, bool request_has_rpc_origin) { PERF_TIMER(on_is_key_image_spent); + bool ok; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_IS_KEY_IMAGE_SPENT>(invoke_http_mode::JON, "/is_key_image_spent", req, res, ok)) + return ok; + std::vector<crypto::key_image> key_images; for(const auto& ki_hex_str: req.key_images) { @@ -662,6 +755,10 @@ namespace cryptonote bool core_rpc_server::on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request& req, COMMAND_RPC_SEND_RAW_TX::response& res) { PERF_TIMER(on_send_raw_tx); + bool ok; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_SEND_RAW_TX>(invoke_http_mode::JON, "/sendrawtransaction", req, res, ok)) + return ok; + CHECK_CORE_READY(); std::string tx_blob; @@ -885,6 +982,10 @@ namespace cryptonote bool core_rpc_server::on_get_transaction_pool(const COMMAND_RPC_GET_TRANSACTION_POOL::request& req, COMMAND_RPC_GET_TRANSACTION_POOL::response& res, bool request_has_rpc_origin) { PERF_TIMER(on_get_transaction_pool); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL>(invoke_http_mode::JON, "/get_transaction_pool", req, res, r)) + return r; + m_core.get_pool_transactions_and_spent_keys_info(res.transactions, res.spent_key_images, !request_has_rpc_origin || !m_restricted); res.status = CORE_RPC_STATUS_OK; return true; @@ -893,6 +994,10 @@ namespace cryptonote bool core_rpc_server::on_get_transaction_pool_hashes(const COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_HASHES::response& res, bool request_has_rpc_origin) { PERF_TIMER(on_get_transaction_pool_hashes); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_HASHES>(invoke_http_mode::JON, "/get_transaction_pool_hashes.bin", req, res, r)) + return r; + m_core.get_pool_transaction_hashes(res.tx_hashes, !request_has_rpc_origin || !m_restricted); res.status = CORE_RPC_STATUS_OK; return true; @@ -901,6 +1006,10 @@ namespace cryptonote bool core_rpc_server::on_get_transaction_pool_stats(const COMMAND_RPC_GET_TRANSACTION_POOL_STATS::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_STATS::response& res, bool request_has_rpc_origin) { PERF_TIMER(on_get_transaction_pool_stats); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_STATS>(invoke_http_mode::JON, "/get_transaction_pool_stats", req, res, r)) + return r; + m_core.get_pool_transaction_stats(res.pool_stats, !request_has_rpc_origin || !m_restricted); res.status = CORE_RPC_STATUS_OK; return true; @@ -919,6 +1028,14 @@ namespace cryptonote bool core_rpc_server::on_getblockcount(const COMMAND_RPC_GETBLOCKCOUNT::request& req, COMMAND_RPC_GETBLOCKCOUNT::response& res) { PERF_TIMER(on_getblockcount); + { + boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + if (m_should_use_bootstrap_daemon) + { + res.status = "This command is unsupported for bootstrap daemon"; + return false; + } + } res.count = m_core.get_current_blockchain_height(); res.status = CORE_RPC_STATUS_OK; return true; @@ -927,6 +1044,14 @@ namespace cryptonote bool core_rpc_server::on_getblockhash(const COMMAND_RPC_GETBLOCKHASH::request& req, COMMAND_RPC_GETBLOCKHASH::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_getblockhash); + { + boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + if (m_should_use_bootstrap_daemon) + { + res = "This command is unsupported for bootstrap daemon"; + return false; + } + } if(req.size() != 1) { error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM; @@ -963,6 +1088,10 @@ namespace cryptonote bool core_rpc_server::on_getblocktemplate(const COMMAND_RPC_GETBLOCKTEMPLATE::request& req, COMMAND_RPC_GETBLOCKTEMPLATE::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_getblocktemplate); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GETBLOCKTEMPLATE>(invoke_http_mode::JON_RPC, "getblocktemplate", req, res, r)) + return r; + if(!check_core_ready()) { error_resp.code = CORE_RPC_ERROR_CODE_CORE_BUSY; @@ -1038,6 +1167,14 @@ namespace cryptonote bool core_rpc_server::on_submitblock(const COMMAND_RPC_SUBMITBLOCK::request& req, COMMAND_RPC_SUBMITBLOCK::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_submitblock); + { + boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + if (m_should_use_bootstrap_daemon) + { + res.status = "This command is unsupported for bootstrap daemon"; + return false; + } + } CHECK_CORE_READY(); if(req.size()!=1) { @@ -1111,9 +1248,80 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + template <typename COMMAND_TYPE> + bool core_rpc_server::use_bootstrap_daemon_if_necessary(const invoke_http_mode &mode, const std::string &command_name, const typename COMMAND_TYPE::request& req, typename COMMAND_TYPE::response& res, bool &r) + { + res.untrusted = false; + if (m_bootstrap_daemon_address.empty()) + return false; + + boost::unique_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + if (!m_should_use_bootstrap_daemon) + { + MINFO("The local daemon is fully synced. Not switching back to the bootstrap daemon"); + return false; + } + + auto current_time = std::chrono::system_clock::now(); + if (current_time - m_bootstrap_height_check_time > std::chrono::seconds(30)) // update every 30s + { + m_bootstrap_height_check_time = current_time; + + uint64_t top_height; + crypto::hash top_hash; + m_core.get_blockchain_top(top_height, top_hash); + ++top_height; // turn top block height into blockchain height + + // query bootstrap daemon's height + cryptonote::COMMAND_RPC_GET_HEIGHT::request getheight_req; + cryptonote::COMMAND_RPC_GET_HEIGHT::response getheight_res; + bool ok = epee::net_utils::invoke_http_json("/getheight", getheight_req, getheight_res, m_http_client); + ok = ok && getheight_res.status == CORE_RPC_STATUS_OK; + + m_should_use_bootstrap_daemon = ok && top_height + 10 < getheight_res.height; + MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << getheight_res.height << ")"); + } + if (!m_should_use_bootstrap_daemon) + return false; + + if (mode == invoke_http_mode::JON) + { + r = epee::net_utils::invoke_http_json(command_name, req, res, m_http_client); + } + else if (mode == invoke_http_mode::BIN) + { + r = epee::net_utils::invoke_http_bin(command_name, req, res, m_http_client); + } + else if (mode == invoke_http_mode::JON_RPC) + { + epee::json_rpc::request<typename COMMAND_TYPE::request> json_req = AUTO_VAL_INIT(json_req); + epee::json_rpc::response<typename COMMAND_TYPE::response, std::string> json_resp = AUTO_VAL_INIT(json_resp); + json_req.jsonrpc = "2.0"; + json_req.id = epee::serialization::storage_entry(0); + json_req.method = command_name; + json_req.params = req; + r = net_utils::invoke_http_json("/json_rpc", json_req, json_resp, m_http_client); + if (r) + res = json_resp.result; + } + else + { + MERROR("Unknown invoke_http_mode: " << mode); + return false; + } + m_was_bootstrap_ever_used = true; + r = r && res.status == CORE_RPC_STATUS_OK; + res.untrusted = true; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_last_block_header(const COMMAND_RPC_GET_LAST_BLOCK_HEADER::request& req, COMMAND_RPC_GET_LAST_BLOCK_HEADER::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_last_block_header); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_LAST_BLOCK_HEADER>(invoke_http_mode::JON_RPC, "getlastblockheader", req, res, r)) + return r; + CHECK_CORE_READY(); uint64_t last_block_height; crypto::hash last_block_hash; @@ -1139,6 +1347,10 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_block_header_by_hash(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH::response& res, epee::json_rpc::error& error_resp){ PERF_TIMER(on_get_block_header_by_hash); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HASH>(invoke_http_mode::JON_RPC, "getblockheaderbyhash", req, res, r)) + return r; + crypto::hash block_hash; bool hash_parsed = parse_hash256(req.hash, block_hash); if(!hash_parsed) @@ -1176,6 +1388,10 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_block_headers_range(const COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request& req, COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response& res, epee::json_rpc::error& error_resp){ PERF_TIMER(on_get_block_headers_range); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADERS_RANGE>(invoke_http_mode::JON_RPC, "getblockheadersrange", req, res, r)) + return r; + const uint64_t bc_height = m_core.get_current_blockchain_height(); if (req.start_height >= bc_height || req.end_height >= bc_height || req.start_height > req.end_height) { @@ -1222,6 +1438,10 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_block_header_by_height(const COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT::response& res, epee::json_rpc::error& error_resp){ PERF_TIMER(on_get_block_header_by_height); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK_HEADER_BY_HEIGHT>(invoke_http_mode::JON_RPC, "getblockheaderbyheight", req, res, r)) + return r; + if(m_core.get_current_blockchain_height() <= req.height) { error_resp.code = CORE_RPC_ERROR_CODE_TOO_BIG_HEIGHT; @@ -1250,6 +1470,10 @@ namespace cryptonote //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_block(const COMMAND_RPC_GET_BLOCK::request& req, COMMAND_RPC_GET_BLOCK::response& res, epee::json_rpc::error& error_resp){ PERF_TIMER(on_get_block); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_BLOCK>(invoke_http_mode::JON_RPC, "getblock", req, res, r)) + return r; + crypto::hash block_hash; if (!req.hash.empty()) { @@ -1319,6 +1543,16 @@ namespace cryptonote bool core_rpc_server::on_get_info_json(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_info_json); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_INFO>(invoke_http_mode::JON_RPC, "get_info", req, res, r)) + { + res.bootstrap_daemon_address = m_bootstrap_daemon_address; + crypto::hash top_hash; + m_core.get_blockchain_top(res.height_without_bootstrap, top_hash); + ++res.height_without_bootstrap; // turn top block height into blockchain height + res.was_bootstrap_ever_used = true; + return r; + } crypto::hash top_hash; m_core.get_blockchain_top(res.height, top_hash); @@ -1339,16 +1573,26 @@ namespace cryptonote res.testnet = m_testnet; res.cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(res.height - 1); res.block_size_limit = m_core.get_blockchain_storage().get_current_cumulative_blocksize_limit(); + res.block_size_median = m_core.get_blockchain_storage().get_current_cumulative_blocksize_median(); res.status = CORE_RPC_STATUS_OK; res.start_time = (uint64_t)m_core.get_start_time(); res.free_space = m_restricted ? std::numeric_limits<uint64_t>::max() : m_core.get_free_space(); res.offline = m_core.offline(); + res.bootstrap_daemon_address = m_bootstrap_daemon_address; + res.height_without_bootstrap = res.height; + { + boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex); + res.was_bootstrap_ever_used = m_was_bootstrap_ever_used; + } return true; } //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_hard_fork_info(const COMMAND_RPC_HARD_FORK_INFO::request& req, COMMAND_RPC_HARD_FORK_INFO::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_hard_fork_info); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_HARD_FORK_INFO>(invoke_http_mode::JON_RPC, "hard_fork_info", req, res, r)) + return r; const Blockchain &blockchain = m_core.get_blockchain_storage(); uint8_t version = req.version > 0 ? req.version : blockchain.get_next_hard_fork_version(); @@ -1471,6 +1715,9 @@ namespace cryptonote bool core_rpc_server::on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_output_histogram); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_OUTPUT_HISTOGRAM>(invoke_http_mode::JON_RPC, "get_output_histogram", req, res, r)) + return r; std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> histogram; try @@ -1498,6 +1745,10 @@ namespace cryptonote bool core_rpc_server::on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_version); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_VERSION>(invoke_http_mode::JON_RPC, "get_version", req, res, r)) + return r; + res.version = CORE_RPC_VERSION; res.status = CORE_RPC_STATUS_OK; return true; @@ -1516,6 +1767,10 @@ namespace cryptonote bool core_rpc_server::on_get_per_kb_fee_estimate(const COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::request& req, COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_per_kb_fee_estimate); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE>(invoke_http_mode::JON_RPC, "get_fee_estimate", req, res, r)) + return r; + res.fee = m_core.get_blockchain_storage().get_dynamic_per_kb_fee_estimate(req.grace_blocks); res.status = CORE_RPC_STATUS_OK; return true; @@ -1543,6 +1798,10 @@ namespace cryptonote bool core_rpc_server::on_get_limit(const COMMAND_RPC_GET_LIMIT::request& req, COMMAND_RPC_GET_LIMIT::response& res) { PERF_TIMER(on_get_limit); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_LIMIT>(invoke_http_mode::JON, "/get_limit", req, res, r)) + return r; + res.limit_down = epee::net_utils::connection_basic::get_rate_down_limit(); res.limit_up = epee::net_utils::connection_basic::get_rate_up_limit(); res.status = CORE_RPC_STATUS_OK; @@ -1594,9 +1853,21 @@ namespace cryptonote PERF_TIMER(on_out_peers); size_t n_connections = m_p2p.get_outgoing_connections_count(); size_t n_delete = (n_connections > req.out_peers) ? n_connections - req.out_peers : 0; - m_p2p.m_config.m_net_config.connections_count = req.out_peers; + m_p2p.m_config.m_net_config.max_out_connection_count = req.out_peers; if (n_delete) - m_p2p.delete_connections(n_delete); + m_p2p.delete_out_connections(n_delete); + res.status = CORE_RPC_STATUS_OK; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_in_peers(const COMMAND_RPC_IN_PEERS::request& req, COMMAND_RPC_IN_PEERS::response& res) + { + PERF_TIMER(on_in_peers); + size_t n_connections = m_p2p.get_incoming_connections_count(); + size_t n_delete = (n_connections > req.in_peers) ? n_connections - req.in_peers : 0; + m_p2p.m_config.m_net_config.max_in_connection_count = req.in_peers; + if (n_delete) + m_p2p.delete_in_connections(n_delete); res.status = CORE_RPC_STATUS_OK; return true; } @@ -1788,6 +2059,9 @@ namespace cryptonote bool core_rpc_server::on_get_txpool_backlog(const COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::request& req, COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG::response& res, epee::json_rpc::error& error_resp) { PERF_TIMER(on_get_txpool_backlog); + bool r; + if (use_bootstrap_daemon_if_necessary<COMMAND_RPC_GET_TRANSACTION_POOL_BACKLOG>(invoke_http_mode::JON_RPC, "get_txpool_backlog", req, res, r)) + return r; if (!m_core.get_txpool_backlog(res.backlog)) { @@ -1830,4 +2104,16 @@ namespace cryptonote , "Restrict RPC to view only commands and do not return privacy sensitive data in RPC calls" , false }; + + const command_line::arg_descriptor<std::string> core_rpc_server::arg_bootstrap_daemon_address = { + "bootstrap-daemon-address" + , "URL of a 'bootstrap' remote daemon that the connected wallets can use while this daemon is still not fully synced" + , "" + }; + + const command_line::arg_descriptor<std::string> core_rpc_server::arg_bootstrap_daemon_login = { + "bootstrap-daemon-login" + , "Specify username:password for the bootstrap daemon login" + , "" + }; } // namespace cryptonote diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 82d73728c..650e738bd 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -34,6 +34,7 @@ #include <boost/program_options/variables_map.hpp> #include "net/http_server_impl_base.h" +#include "net/http_client.h" #include "core_rpc_server_commands_defs.h" #include "cryptonote_core/cryptonote_core.h" #include "p2p/net_node.h" @@ -57,6 +58,8 @@ namespace cryptonote 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; typedef epee::net_utils::connection_context_base connection_context; @@ -114,6 +117,7 @@ namespace cryptonote MAP_URI_AUTO_JON2("/get_limit", on_get_limit, COMMAND_RPC_GET_LIMIT) MAP_URI_AUTO_JON2_IF("/set_limit", on_set_limit, COMMAND_RPC_SET_LIMIT, !m_restricted) MAP_URI_AUTO_JON2_IF("/out_peers", on_out_peers, COMMAND_RPC_OUT_PEERS, !m_restricted) + MAP_URI_AUTO_JON2_IF("/in_peers", on_in_peers, COMMAND_RPC_IN_PEERS, !m_restricted) MAP_URI_AUTO_JON2_IF("/start_save_graph", on_start_save_graph, COMMAND_RPC_START_SAVE_GRAPH, !m_restricted) MAP_URI_AUTO_JON2_IF("/stop_save_graph", on_stop_save_graph, COMMAND_RPC_STOP_SAVE_GRAPH, !m_restricted) MAP_URI_AUTO_JON2("/get_outs", on_get_outs, COMMAND_RPC_GET_OUTPUTS) @@ -170,7 +174,7 @@ namespace cryptonote bool on_get_outs_bin(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res); bool on_get_outs(const COMMAND_RPC_GET_OUTPUTS::request& req, COMMAND_RPC_GET_OUTPUTS::response& res); bool on_get_random_rct_outs(const COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::request& req, COMMAND_RPC_GET_RANDOM_RCT_OUTPUTS::response& res); - bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); + bool on_get_info(const COMMAND_RPC_GET_INFO::request& req, COMMAND_RPC_GET_INFO::response& res); bool on_save_bc(const COMMAND_RPC_SAVE_BC::request& req, COMMAND_RPC_SAVE_BC::response& res); bool on_get_peer_list(const COMMAND_RPC_GET_PEER_LIST::request& req, COMMAND_RPC_GET_PEER_LIST::response& res); bool on_set_log_hash_rate(const COMMAND_RPC_SET_LOG_HASH_RATE::request& req, COMMAND_RPC_SET_LOG_HASH_RATE::response& res); @@ -183,6 +187,7 @@ namespace cryptonote bool on_get_limit(const COMMAND_RPC_GET_LIMIT::request& req, COMMAND_RPC_GET_LIMIT::response& res); bool on_set_limit(const COMMAND_RPC_SET_LIMIT::request& req, COMMAND_RPC_SET_LIMIT::response& res); bool on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res); + bool on_in_peers(const COMMAND_RPC_IN_PEERS::request& req, COMMAND_RPC_IN_PEERS::response& res); bool on_start_save_graph(const COMMAND_RPC_START_SAVE_GRAPH::request& req, COMMAND_RPC_START_SAVE_GRAPH::response& res); bool on_stop_save_graph(const COMMAND_RPC_STOP_SAVE_GRAPH::request& req, COMMAND_RPC_STOP_SAVE_GRAPH::response& res); bool on_update(const COMMAND_RPC_UPDATE::request& req, COMMAND_RPC_UPDATE::response& res); @@ -220,9 +225,18 @@ private: //utils uint64_t get_block_reward(const block& blk); bool fill_block_header_response(const block& blk, bool orphan_status, uint64_t height, const crypto::hash& hash, block_header_response& response); + enum invoke_http_mode { JON, BIN, JON_RPC }; + template <typename COMMAND_TYPE> + bool use_bootstrap_daemon_if_necessary(const invoke_http_mode &mode, const std::string &command_name, const typename COMMAND_TYPE::request& req, typename COMMAND_TYPE::response& res, bool &r); core& m_core; nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& m_p2p; + std::string m_bootstrap_daemon_address; + epee::net_utils::http::http_simple_client m_http_client; + boost::shared_mutex m_bootstrap_daemon_mutex; + bool m_should_use_bootstrap_daemon; + std::chrono::system_clock::time_point m_bootstrap_height_check_time; + bool m_was_bootstrap_ever_used; bool m_testnet; bool m_restricted; }; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 00b553bad..64a97f8a3 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -49,7 +49,7 @@ namespace cryptonote // advance which version they will stop working with // Don't go over 32767 for any of these #define CORE_RPC_VERSION_MAJOR 1 -#define CORE_RPC_VERSION_MINOR 17 +#define CORE_RPC_VERSION_MINOR 18 #define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR) @@ -65,10 +65,12 @@ namespace cryptonote { uint64_t height; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(height) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -113,6 +115,7 @@ namespace cryptonote uint64_t current_height; std::string status; std::vector<block_output_indices> output_indices; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(blocks) @@ -120,6 +123,7 @@ namespace cryptonote KV_SERIALIZE(current_height) KV_SERIALIZE(status) KV_SERIALIZE(output_indices) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -138,10 +142,12 @@ namespace cryptonote { std::vector<block_complete_entry> blocks; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(blocks) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -158,10 +164,12 @@ namespace cryptonote { std::vector<std::string> blks_hashes; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(blks_hashes) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -184,12 +192,14 @@ namespace cryptonote uint64_t start_height; uint64_t current_height; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_ids) KV_SERIALIZE(start_height) KV_SERIALIZE(current_height) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -595,6 +605,7 @@ namespace cryptonote // new style std::vector<entry> txs; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(txs_as_hex) @@ -602,6 +613,7 @@ namespace cryptonote KV_SERIALIZE(txs) KV_SERIALIZE(missed_tx) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -629,10 +641,12 @@ namespace cryptonote { std::vector<int> spent_status; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(spent_status) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -653,9 +667,11 @@ namespace cryptonote { std::vector<uint64_t> o_indexes; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(o_indexes) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -695,9 +711,11 @@ namespace cryptonote { std::vector<outs_for_amount> outs; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(outs) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -745,10 +763,12 @@ namespace cryptonote { std::vector<outkey> outs; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(outs) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -785,10 +805,12 @@ namespace cryptonote { std::vector<outkey> outs; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(outs) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -817,9 +839,11 @@ namespace cryptonote { std::list<out_entry> outs; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_CONTAINER_POD_AS_BLOB(outs) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -836,7 +860,7 @@ namespace cryptonote BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(tx_as_hex) - KV_SERIALIZE(do_not_relay) + KV_SERIALIZE_OPT(do_not_relay, false) END_KV_SERIALIZE_MAP() }; @@ -854,6 +878,7 @@ namespace cryptonote bool overspend; bool fee_too_low; bool not_rct; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) @@ -867,6 +892,7 @@ namespace cryptonote KV_SERIALIZE(overspend) KV_SERIALIZE(fee_too_low) KV_SERIALIZE(not_rct) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -926,9 +952,14 @@ namespace cryptonote std::string top_block_hash; uint64_t cumulative_difficulty; uint64_t block_size_limit; + uint64_t block_size_median; uint64_t start_time; uint64_t free_space; bool offline; + bool untrusted; + std::string bootstrap_daemon_address; + uint64_t height_without_bootstrap; + bool was_bootstrap_ever_used; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) @@ -948,9 +979,14 @@ namespace cryptonote KV_SERIALIZE(top_block_hash) KV_SERIALIZE(cumulative_difficulty) KV_SERIALIZE(block_size_limit) + KV_SERIALIZE(block_size_median) KV_SERIALIZE(start_time) KV_SERIALIZE(free_space) KV_SERIALIZE(offline) + KV_SERIALIZE(untrusted) + KV_SERIALIZE(bootstrap_daemon_address) + KV_SERIALIZE(height_without_bootstrap) + KV_SERIALIZE(was_bootstrap_ever_used) END_KV_SERIALIZE_MAP() }; }; @@ -1078,6 +1114,7 @@ namespace cryptonote blobdata blocktemplate_blob; blobdata blockhashing_blob; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(difficulty) @@ -1088,6 +1125,7 @@ namespace cryptonote KV_SERIALIZE(blocktemplate_blob) KV_SERIALIZE(blockhashing_blob) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1151,10 +1189,12 @@ namespace cryptonote { std::string status; block_header_response block_header; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; @@ -1175,10 +1215,12 @@ namespace cryptonote { std::string status; block_header_response block_header; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; @@ -1199,10 +1241,12 @@ namespace cryptonote { std::string status; block_header_response block_header; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; @@ -1229,6 +1273,7 @@ namespace cryptonote std::vector<std::string> tx_hashes; std::string blob; std::string json; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(block_header) @@ -1237,6 +1282,7 @@ namespace cryptonote KV_SERIALIZE(status) KV_SERIALIZE(blob) KV_SERIALIZE(json) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; @@ -1413,11 +1459,13 @@ namespace cryptonote std::string status; std::vector<tx_info> transactions; std::vector<spent_key_image_info> spent_key_images; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(transactions) KV_SERIALIZE(spent_key_images) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1434,10 +1482,12 @@ namespace cryptonote { std::string status; std::vector<crypto::hash> tx_hashes; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE_CONTAINER_POD_AS_BLOB(tx_hashes) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1461,10 +1511,12 @@ namespace cryptonote { std::string status; std::vector<tx_backlog_entry> backlog; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE_CONTAINER_POD_AS_BLOB(backlog) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1525,10 +1577,12 @@ namespace cryptonote { std::string status; txpool_stats pool_stats; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(pool_stats) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1571,10 +1625,12 @@ namespace cryptonote { std::string status; std::vector<block_header_response> headers; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(headers) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1628,11 +1684,13 @@ namespace cryptonote std::string status; uint64_t limit_up; uint64_t limit_down; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(limit_up) KV_SERIALIZE(limit_down) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1676,8 +1734,28 @@ namespace cryptonote struct response { - std::string status; - + std::string status; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(status) + END_KV_SERIALIZE_MAP() + }; + }; + + struct COMMAND_RPC_IN_PEERS + { + struct request + { + uint64_t in_peers; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(in_peers) + END_KV_SERIALIZE_MAP() + }; + + struct response + { + std::string status; + BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) END_KV_SERIALIZE_MAP() @@ -1742,6 +1820,7 @@ namespace cryptonote uint32_t state; uint64_t earliest_height; std::string status; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(version) @@ -1753,6 +1832,7 @@ namespace cryptonote KV_SERIALIZE(state) KV_SERIALIZE(earliest_height) KV_SERIALIZE(status) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1889,10 +1969,12 @@ namespace cryptonote { std::string status; std::vector<entry> histogram; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(histogram) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1909,10 +1991,12 @@ namespace cryptonote { std::string status; uint32_t version; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(version) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; @@ -1959,10 +2043,12 @@ namespace cryptonote { std::string status; uint64_t fee; + bool untrusted; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(fee) + KV_SERIALIZE(untrusted) END_KV_SERIALIZE_MAP() }; }; diff --git a/src/rpc/core_rpc_server_error_codes.h b/src/rpc/core_rpc_server_error_codes.h index bd90d37aa..69caaa6a6 100644 --- a/src/rpc/core_rpc_server_error_codes.h +++ b/src/rpc/core_rpc_server_error_codes.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp index 908f9e187..2f3f336a4 100644 --- a/src/rpc/daemon_handler.cpp +++ b/src/rpc/daemon_handler.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/daemon_handler.h b/src/rpc/daemon_handler.h index 0d356bad2..f43711640 100644 --- a/src/rpc/daemon_handler.h +++ b/src/rpc/daemon_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/daemon_messages.cpp b/src/rpc/daemon_messages.cpp index 640058df9..e5fb9781c 100644 --- a/src/rpc/daemon_messages.cpp +++ b/src/rpc/daemon_messages.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/daemon_messages.h b/src/rpc/daemon_messages.h index 685f66843..1495c845f 100644 --- a/src/rpc/daemon_messages.h +++ b/src/rpc/daemon_messages.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/daemon_rpc_version.h b/src/rpc/daemon_rpc_version.h index bb735fe7c..e20af5b21 100644 --- a/src/rpc/daemon_rpc_version.h +++ b/src/rpc/daemon_rpc_version.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/instanciations.cpp b/src/rpc/instanciations.cpp index ac521247e..ec8882982 100644 --- a/src/rpc/instanciations.cpp +++ b/src/rpc/instanciations.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/message.cpp b/src/rpc/message.cpp index 98b40e667..0ebe34efe 100644 --- a/src/rpc/message.cpp +++ b/src/rpc/message.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/message.h b/src/rpc/message.h index d1abe3fbe..16b8e92fc 100644 --- a/src/rpc/message.h +++ b/src/rpc/message.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/message_data_structs.h b/src/rpc/message_data_structs.h index 581048eaf..9ba311976 100644 --- a/src/rpc/message_data_structs.h +++ b/src/rpc/message_data_structs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp index ce4070270..d4a6138ba 100644 --- a/src/rpc/rpc_args.cpp +++ b/src/rpc/rpc_args.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -37,7 +37,7 @@ namespace cryptonote { rpc_args::descriptors::descriptors() - : rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("Specify ip to bind rpc server"), "127.0.0.1"}) + : rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("Specify IP to bind RPC server"), "127.0.0.1"}) , rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true}) , confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rpc-bind-ip value is NOT a loopback (local) IP")}) , rpc_access_control_origins({"rpc-access-control-origins", rpc_args::tr("Specify a comma separated list of origins to allow cross origin resource sharing"), ""}) diff --git a/src/rpc/rpc_args.h b/src/rpc/rpc_args.h index 72b5aa706..8e375385b 100644 --- a/src/rpc/rpc_args.h +++ b/src/rpc/rpc_args.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/rpc_handler.h b/src/rpc/rpc_handler.h index d75180199..64bade5a8 100644 --- a/src/rpc/rpc_handler.h +++ b/src/rpc/rpc_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp index 6f06f4497..3aee8c4c7 100644 --- a/src/rpc/zmq_server.cpp +++ b/src/rpc/zmq_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/rpc/zmq_server.h b/src/rpc/zmq_server.h index c278ff759..0cd906a3f 100644 --- a/src/rpc/zmq_server.h +++ b/src/rpc/zmq_server.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/CMakeLists.txt b/src/serialization/CMakeLists.txt index e4aa0b6a2..5a6bebf09 100644 --- a/src/serialization/CMakeLists.txt +++ b/src/serialization/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2016, The Monero Project +# Copyright (c) 2016-2018, The Monero Project # # All rights reserved. # diff --git a/src/serialization/binary_archive.h b/src/serialization/binary_archive.h index 0a267b081..79c6c753c 100644 --- a/src/serialization/binary_archive.h +++ b/src/serialization/binary_archive.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/binary_utils.h b/src/serialization/binary_utils.h index 08eba41da..79b30b337 100644 --- a/src/serialization/binary_utils.h +++ b/src/serialization/binary_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/crypto.h b/src/serialization/crypto.h index 8083bdeb1..87172834f 100644 --- a/src/serialization/crypto.h +++ b/src/serialization/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/debug_archive.h b/src/serialization/debug_archive.h index c5365aab7..c6033a399 100644 --- a/src/serialization/debug_archive.h +++ b/src/serialization/debug_archive.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/json_archive.h b/src/serialization/json_archive.h index 8f74e26b1..f906b5d3b 100644 --- a/src/serialization/json_archive.h +++ b/src/serialization/json_archive.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp index 2c86d4054..a7fb58ee4 100644 --- a/src/serialization/json_object.cpp +++ b/src/serialization/json_object.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h index fc4f528b2..de21ace66 100644 --- a/src/serialization/json_object.h +++ b/src/serialization/json_object.h @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2017, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/json_utils.h b/src/serialization/json_utils.h index 32e7b69cf..16f32cf66 100644 --- a/src/serialization/json_utils.h +++ b/src/serialization/json_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/list.h b/src/serialization/list.h index d725458e7..ef0063a98 100644 --- a/src/serialization/list.h +++ b/src/serialization/list.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/pair.h b/src/serialization/pair.h index 4913a74d6..67105d530 100644 --- a/src/serialization/pair.h +++ b/src/serialization/pair.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2015, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h index 56496c790..5fc382a1e 100644 --- a/src/serialization/serialization.h +++ b/src/serialization/serialization.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/set.h b/src/serialization/set.h index e6eff62a9..edf170852 100644 --- a/src/serialization/set.h +++ b/src/serialization/set.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/string.h b/src/serialization/string.h index b94f43dd8..97268d454 100644 --- a/src/serialization/string.h +++ b/src/serialization/string.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/variant.h b/src/serialization/variant.h index 9048e2963..31d903d55 100644 --- a/src/serialization/variant.h +++ b/src/serialization/variant.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/serialization/vector.h b/src/serialization/vector.h index 9cf3d8272..f180b5353 100644 --- a/src/serialization/vector.h +++ b/src/serialization/vector.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt index f190ada8d..4230e32c0 100644 --- a/src/simplewallet/CMakeLists.txt +++ b/src/simplewallet/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index b6b6da441..0a57dec80 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -158,7 +158,7 @@ namespace boost::optional<tools::password_container> default_password_prompter(bool verify) { - return password_prompter(verify ? tr("Enter new wallet password") : tr("Wallet password"), verify); + return password_prompter(verify ? tr("Enter a new password for the wallet") : tr("Wallet password"), verify); } inline std::string interpret_rpc_response(bool ok, const std::string& status) @@ -442,6 +442,21 @@ namespace fail_msg_writer() << tr("unexpected error: ") << e.what(); } } + + bool check_file_overwrite(const std::string &filename) + { + boost::system::error_code errcode; + if (boost::filesystem::exists(filename, errcode)) + { + if (boost::ends_with(filename, ".keys")) + { + fail_msg_writer() << boost::format(tr("File %s likely stores wallet private keys! Use a different file name.")) % filename; + return false; + } + return command_line::is_yes(input_line((boost::format(tr("File %s already exists. Are you sure to overwrite it? (Y/Yes/N/No): ")) % filename).str())); + } + return true; + } } bool parse_priority(const std::string& arg, uint32_t& priority) @@ -874,6 +889,8 @@ bool simple_wallet::export_multisig(const std::vector<std::string> &args) return true; const std::string filename = args[0]; + if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) + return true; try { cryptonote::blobdata ciphertext = m_wallet->export_multisig(); @@ -1122,6 +1139,8 @@ bool simple_wallet::export_raw_multisig(const std::vector<std::string> &args) if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } std::string filename = args[0]; + if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) + return true; try { tools::wallet2::multisig_tx_set txs; @@ -1274,7 +1293,7 @@ bool simple_wallet::set_default_priority(const std::vector<std::string> &args/* priority = boost::lexical_cast<int>(args[1]); if (priority < 1 || priority > 4) { - fail_msg_writer() << tr("priority must be 0, 1, 2, 3,or 4"); + fail_msg_writer() << tr("priority must be 0, 1, 2, 3, or 4"); return true; } } @@ -1289,7 +1308,7 @@ bool simple_wallet::set_default_priority(const std::vector<std::string> &args/* } catch(const boost::bad_lexical_cast &) { - fail_msg_writer() << tr("priority must be 0, 1, 2 3,or 4"); + fail_msg_writer() << tr("priority must be 0, 1, 2, 3, or 4"); return true; } catch(...) @@ -1384,7 +1403,7 @@ bool simple_wallet::set_unit(const std::vector<std::string> &args/* = std::vecto const auto pwd_container = get_and_verify_password(); if (pwd_container) { - m_wallet->set_default_decimal_point(decimal_point); + cryptonote::set_default_decimal_point(decimal_point); m_wallet->rewrite(m_wallet_file, pwd_container->password()); } return true; @@ -1470,6 +1489,19 @@ bool simple_wallet::set_confirm_backlog_threshold(const std::vector<std::string> return true; } +bool simple_wallet::set_confirm_export_overwrite(const std::vector<std::string> &args/* = std::vector<std::string>()*/) +{ + const auto pwd_container = get_and_verify_password(); + if (pwd_container) + { + parse_bool_and_use(args[1], [&](bool r) { + m_wallet->confirm_export_overwrite(r); + m_wallet->rewrite(m_wallet_file, pwd_container->password()); + }); + } + return true; +} + bool simple_wallet::set_refresh_from_block_height(const std::vector<std::string> &args/* = std::vector<std::string>()*/) { const auto pwd_container = get_and_verify_password(); @@ -1487,6 +1519,19 @@ bool simple_wallet::set_refresh_from_block_height(const std::vector<std::string> return true; } +bool simple_wallet::set_auto_low_priority(const std::vector<std::string> &args/* = std::vector<std::string>()*/) +{ + const auto pwd_container = get_and_verify_password(); + if (pwd_container) + { + parse_bool_and_use(args[1], [&](bool r) { + m_wallet->auto_low_priority(r); + m_wallet->rewrite(m_wallet_file, pwd_container->password()); + }); + } + return true; +} + bool simple_wallet::help(const std::vector<std::string> &args/* = std::vector<std::string>()*/) { if(args.empty()) @@ -1544,14 +1589,14 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("transfer_original", boost::bind(&simple_wallet::transfer, this, _1), tr("transfer_original [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"), - tr("Transfer <amount> to <address> using an older transaction building algorithm. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); + tr("Transfer <amount> to <address> using an older transaction building algorithm. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer_new, this, _1), tr("transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"), - tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); + tr("Transfer <amount> to <address>. If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("locked_transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <addr> <amount> <lockblocks> [<payment_id>]"), - tr("Transfer <amount> to <address> and lock it for <lockblocks> (max. 1000000). If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); + tr("Transfer <amount> to <address> and lock it for <lockblocks> (max. 1000000). If the parameter \"index=<N1>[,<N2>,...]\" is specified, the wallet uses outputs received by addresses of those indices. If omitted, the wallet randomly chooses address indices to be used. In any case, it tries its best not to combine outputs across multiple addresses. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command \"set priority\") is used. <ring_size> is the number of inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)")); m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with ring_size 1")); @@ -1659,7 +1704,9 @@ simple_wallet::simple_wallet() "confirm-backlog-threshold [n]\n " " Set a threshold for confirm-backlog to only warn if the transaction backlog is greater than n blocks.\n " "refresh-from-block-height [n]\n " - " Set the height before which to ignore blocks.")); + " Set the height before which to ignore blocks.\n " + "auto-low-priority <1|0>\n " + " Whether to automatically use the low priority fee level when it's safe to do so.")); m_cmd_binder.set_handler("encrypted_seed", boost::bind(&simple_wallet::encrypted_seed, this, _1), tr("Display the encrypted Electrum-style mnemonic seed.")); @@ -1674,9 +1721,9 @@ simple_wallet::simple_wallet() boost::bind(&simple_wallet::check_tx_key, this, _1), tr("check_tx_key <txid> <txkey> <address>"), tr("Check the amount going to <address> in <txid>.")); - m_cmd_binder.set_handler("get_tx_proof_out", + m_cmd_binder.set_handler("get_tx_proof", boost::bind(&simple_wallet::get_tx_proof, this, _1), - tr("get_tx_proof_out <txid> <address> [<message>]"), + tr("get_tx_proof <txid> <address> [<message>]"), tr("Generate a signature proving funds sent to <address> in <txid>, optionally with a challenge string <message>, using either the transaction secret key (when <address> is not your wallet's address) or the view secret key (otherwise), which does not disclose the secret key.")); m_cmd_binder.set_handler("check_tx_proof", boost::bind(&simple_wallet::check_tx_proof, this, _1), @@ -1818,13 +1865,15 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args) success_msg_writer() << "priority = " << m_wallet->get_default_priority(); success_msg_writer() << "confirm-missing-payment-id = " << m_wallet->confirm_missing_payment_id(); success_msg_writer() << "ask-password = " << m_wallet->ask_password(); - success_msg_writer() << "unit = " << cryptonote::get_unit(m_wallet->get_default_decimal_point()); + success_msg_writer() << "unit = " << cryptonote::get_unit(cryptonote::get_default_decimal_point()); success_msg_writer() << "min-outputs-count = " << m_wallet->get_min_output_count(); success_msg_writer() << "min-outputs-value = " << cryptonote::print_money(m_wallet->get_min_output_value()); success_msg_writer() << "merge-destinations = " << m_wallet->merge_destinations(); success_msg_writer() << "confirm-backlog = " << m_wallet->confirm_backlog(); success_msg_writer() << "confirm-backlog-threshold = " << m_wallet->get_confirm_backlog_threshold(); + success_msg_writer() << "confirm-export-overwrite = " << m_wallet->confirm_export_overwrite(); success_msg_writer() << "refresh-from-block-height = " << m_wallet->get_refresh_from_block_height(); + success_msg_writer() << "auto-low-priority = " << m_wallet->auto_low_priority(); return true; } else @@ -1872,7 +1921,9 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args) CHECK_SIMPLE_VARIABLE("merge-destinations", set_merge_destinations, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("confirm-backlog", set_confirm_backlog, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("confirm-backlog-threshold", set_confirm_backlog_threshold, tr("unsigned integer")); + CHECK_SIMPLE_VARIABLE("confirm-export-overwrite", set_confirm_export_overwrite, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("refresh-from-block-height", set_refresh_from_block_height, tr("block height")); + CHECK_SIMPLE_VARIABLE("auto-low-priority", set_auto_low_priority, tr("0 or 1")); } fail_msg_writer() << tr("set: unrecognized argument(s)"); return true; @@ -2423,7 +2474,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) r = new_wallet(vm, m_recovery_key, m_restore_deterministic_wallet, m_non_deterministic, old_language); CHECK_AND_ASSERT_MES(r, false, tr("account creation failed")); } - if (!m_restore_height && m_restoring) + if (!m_wallet->explicit_refresh_from_block_height() && m_restoring) { uint32_t version; bool connected = try_connect_to_daemon(false, &version); @@ -2621,12 +2672,12 @@ std::string simple_wallet::get_mnemonic_language() if (!((language_number >= 0) && (static_cast<unsigned int>(language_number) < language_list.size()))) { language_number = -1; - fail_msg_writer() << tr("invalid language choice passed. Please try again.\n"); + fail_msg_writer() << tr("invalid language choice entered. Please try again.\n"); } } catch (const std::exception &e) { - fail_msg_writer() << tr("invalid language choice passed. Please try again.\n"); + fail_msg_writer() << tr("invalid language choice entered. Please try again.\n"); } } return language_list[language_number]; @@ -3383,7 +3434,7 @@ bool simple_wallet::show_payments(const std::vector<std::string> &args) { if(args.empty()) { - fail_msg_writer() << tr("expected at least one payment_id"); + fail_msg_writer() << tr("expected at least one payment ID"); return true; } @@ -3633,6 +3684,8 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri if (local_args.size() > 0 && parse_priority(local_args[0], priority)) local_args.erase(local_args.begin()); + priority = m_wallet->adjust_priority(priority); + size_t fake_outs_count = 0; if(local_args.size() > 0) { size_t ring_size; @@ -3820,7 +3873,6 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri { std::stringstream prompt; double worst_fee_per_byte = std::numeric_limits<double>::max(); - uint64_t size = 0, fee = 0; for (size_t n = 0; n < ptx_vector.size(); ++n) { const uint64_t blob_size = cryptonote::tx_to_blob(ptx_vector[n].tx).size(); @@ -3828,13 +3880,11 @@ bool simple_wallet::transfer_main(int transfer_type, const std::vector<std::stri if (fee_per_byte < worst_fee_per_byte) { worst_fee_per_byte = fee_per_byte; - fee = ptx_vector[n].fee; } - size += blob_size; } try { - std::vector<std::pair<uint64_t, uint64_t>> nblocks = m_wallet->estimate_backlog(size, size, {fee}); + std::vector<std::pair<uint64_t, uint64_t>> nblocks = m_wallet->estimate_backlog({std::make_pair(worst_fee_per_byte, worst_fee_per_byte)}); if (nblocks.size() != 1) { prompt << "Internal error checking for backlog. " << tr("Is this okay anyway? (Y/Yes/N/No): "); @@ -4113,6 +4163,8 @@ bool simple_wallet::sweep_main(uint64_t below, const std::vector<std::string> &a if (local_args.size() > 0 && parse_priority(local_args[0], priority)) local_args.erase(local_args.begin()); + priority = m_wallet->adjust_priority(priority); + size_t fake_outs_count = 0; if(local_args.size() > 0) { size_t ring_size; @@ -4325,17 +4377,11 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_) std::vector<std::string> local_args = args_; - int priority = 0; - if(local_args.size() > 0) { - auto priority_pos = std::find( - allowed_priority_strings.begin(), - allowed_priority_strings.end(), - local_args[0]); - if(priority_pos != allowed_priority_strings.end()) { - local_args.erase(local_args.begin()); - priority = std::distance(allowed_priority_strings.begin(), priority_pos); - } - } + uint32_t priority = 0; + if (local_args.size() > 0 && parse_priority(local_args[0], priority)) + local_args.erase(local_args.begin()); + + priority = m_wallet->adjust_priority(priority); size_t fake_outs_count = 0; if(local_args.size() > 0) { @@ -4532,7 +4578,7 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args_) uint64_t below = 0; if (args_.size() < 1) { - fail_msg_writer() << tr("missing amount threshold"); + fail_msg_writer() << tr("missing threshold amount"); return true; } if (!cryptonote::parse_amount(below, args_[0])) @@ -4858,7 +4904,7 @@ bool simple_wallet::get_tx_proof(const std::vector<std::string> &args) { if (args.size() != 2 && args.size() != 3) { - fail_msg_writer() << tr("usage: get_tx_proof_out <txid> <address> [<message>]"); + fail_msg_writer() << tr("usage: get_tx_proof <txid> <address> [<message>]"); return true; } @@ -6329,6 +6375,8 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args) } if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } std::string filename = args[0]; + if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) + return true; try { @@ -6396,6 +6444,8 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args) } if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } std::string filename = args[0]; + if (m_wallet->confirm_export_overwrite() && !check_file_overwrite(filename)) + return true; LOCK_IDLE_SCOPE(); try diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 086076be0..af2f940c3 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -44,6 +44,7 @@ #include "cryptonote_basic/cryptonote_basic_impl.h" #include "wallet/wallet2.h" #include "console_handler.h" +#include "common/i18n.h" #include "common/password.h" #include "crypto/crypto.h" // for definition of crypto::secret_key @@ -128,7 +129,9 @@ namespace cryptonote bool set_merge_destinations(const std::vector<std::string> &args = std::vector<std::string>()); bool set_confirm_backlog(const std::vector<std::string> &args = std::vector<std::string>()); bool set_confirm_backlog_threshold(const std::vector<std::string> &args = std::vector<std::string>()); + bool set_confirm_export_overwrite(const std::vector<std::string> &args = std::vector<std::string>()); bool set_refresh_from_block_height(const std::vector<std::string> &args = std::vector<std::string>()); + bool set_auto_low_priority(const std::vector<std::string> &args = std::vector<std::string>()); bool help(const std::vector<std::string> &args = std::vector<std::string>()); bool start_mining(const std::vector<std::string> &args); bool stop_mining(const std::vector<std::string> &args); diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index abecabbc3..c6d0bd9da 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/src/wallet/api/CMakeLists.txt b/src/wallet/api/CMakeLists.txt index 60d6970bd..1e67495f1 100644 --- a/src/wallet/api/CMakeLists.txt +++ b/src/wallet/api/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # @@ -88,4 +88,4 @@ else() endif() install(FILES ${wallet_api_headers} - DESTINATION include/wallet) + DESTINATION include/wallet/api) diff --git a/src/wallet/api/address_book.cpp b/src/wallet/api/address_book.cpp index da412cd4b..38c34a912 100644 --- a/src/wallet/api/address_book.cpp +++ b/src/wallet/api/address_book.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -74,7 +74,7 @@ bool AddressBookImpl::addRow(const std::string &dst_addr , const std::string &pa // integrated + long payment id provided if(has_long_pid && info.has_payment_id) { - m_errorString = tr("Integrated address and long payment id can't be used at the same time"); + m_errorString = tr("Integrated address and long payment ID can't be used at the same time"); m_errorCode = Invalid_Payment_Id; return false; } diff --git a/src/wallet/api/address_book.h b/src/wallet/api/address_book.h index b92743fe6..7d9200550 100644 --- a/src/wallet/api/address_book.h +++ b/src/wallet/api/address_book.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/pending_transaction.cpp b/src/wallet/api/pending_transaction.cpp index e17931de1..ff4619f0f 100644 --- a/src/wallet/api/pending_transaction.cpp +++ b/src/wallet/api/pending_transaction.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/pending_transaction.h b/src/wallet/api/pending_transaction.h index c98da59da..d0bd66eb5 100644 --- a/src/wallet/api/pending_transaction.h +++ b/src/wallet/api/pending_transaction.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/subaddress.cpp b/src/wallet/api/subaddress.cpp index ceda9a9da..61dbbf4b0 100644 --- a/src/wallet/api/subaddress.cpp +++ b/src/wallet/api/subaddress.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/subaddress.h b/src/wallet/api/subaddress.h index 45fef6e67..3f9e37ac8 100644 --- a/src/wallet/api/subaddress.h +++ b/src/wallet/api/subaddress.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/subaddress_account.cpp b/src/wallet/api/subaddress_account.cpp index 736ef874e..19ed8fb38 100644 --- a/src/wallet/api/subaddress_account.cpp +++ b/src/wallet/api/subaddress_account.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/subaddress_account.h b/src/wallet/api/subaddress_account.h index 0a4db9671..b052182f8 100644 --- a/src/wallet/api/subaddress_account.h +++ b/src/wallet/api/subaddress_account.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/transaction_history.cpp b/src/wallet/api/transaction_history.cpp index 8a8243047..95a055f8f 100644 --- a/src/wallet/api/transaction_history.cpp +++ b/src/wallet/api/transaction_history.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/transaction_history.h b/src/wallet/api/transaction_history.h index e5207e53a..7bdce97e2 100644 --- a/src/wallet/api/transaction_history.h +++ b/src/wallet/api/transaction_history.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/transaction_info.cpp b/src/wallet/api/transaction_info.cpp index 1a5df454c..cc3209609 100644 --- a/src/wallet/api/transaction_info.cpp +++ b/src/wallet/api/transaction_info.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/transaction_info.h b/src/wallet/api/transaction_info.h index c961c0a9e..5df9a44ef 100644 --- a/src/wallet/api/transaction_info.h +++ b/src/wallet/api/transaction_info.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp index d22719189..c6ebcb009 100644 --- a/src/wallet/api/unsigned_transaction.cpp +++ b/src/wallet/api/unsigned_transaction.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/unsigned_transaction.h b/src/wallet/api/unsigned_transaction.h index 33c994d5f..a35630535 100644 --- a/src/wallet/api/unsigned_transaction.h +++ b/src/wallet/api/unsigned_transaction.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/utils.cpp b/src/wallet/api/utils.cpp index e54dd9f1c..aebe41e59 100644 --- a/src/wallet/api/utils.cpp +++ b/src/wallet/api/utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index f96640d6e..f648160c9 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -458,6 +458,16 @@ bool WalletImpl::recoverFromKeys(const std::string &path, const std::string &viewkey_string, const std::string &spendkey_string) { + return recoverFromKeysWithPassword(path, "", language, address_string, viewkey_string, spendkey_string); +} + +bool WalletImpl::recoverFromKeysWithPassword(const std::string &path, + const std::string &password, + const std::string &language, + const std::string &address_string, + const std::string &viewkey_string, + const std::string &spendkey_string) +{ cryptonote::address_parse_info info; if(!get_account_address_from_str(info, m_wallet->testnet(), address_string)) { @@ -524,12 +534,12 @@ bool WalletImpl::recoverFromKeys(const std::string &path, try { if (has_spendkey) { - m_wallet->generate(path, "", info.address, spendkey, viewkey); + m_wallet->generate(path, password, info.address, spendkey, viewkey); setSeedLanguage(language); LOG_PRINT_L1("Generated new wallet from keys with seed language: " + language); } else { - m_wallet->generate(path, "", info.address, viewkey); + m_wallet->generate(path, password, info.address, viewkey); LOG_PRINT_L1("Generated new view only wallet from keys"); } @@ -570,6 +580,11 @@ bool WalletImpl::open(const std::string &path, const std::string &password) bool WalletImpl::recover(const std::string &path, const std::string &seed) { + return recover(path, "", seed); +} + +bool WalletImpl::recover(const std::string &path, const std::string &password, const std::string &seed) +{ clearStatus(); m_errorString.clear(); if (seed.empty()) { @@ -590,7 +605,7 @@ bool WalletImpl::recover(const std::string &path, const std::string &seed) try { m_wallet->set_seed_language(old_language); - m_wallet->generate(path, "", recovery_key, true, false); + m_wallet->generate(path, password, recovery_key, true, false); } catch (const std::exception &e) { m_status = Status_Critical; @@ -611,7 +626,7 @@ bool WalletImpl::close(bool store) if (status() != Status_Critical) m_wallet->store(); else - LOG_ERROR("Status_Critical - not storing wallet"); + LOG_ERROR("Status_Critical - not saving wallet"); LOG_PRINT_L1("wallet::store done"); } LOG_PRINT_L1("Calling wallet::stop..."); @@ -717,7 +732,7 @@ bool WalletImpl::store(const std::string &path) m_wallet->store_to(path, m_password); } } catch (const std::exception &e) { - LOG_ERROR("Error storing wallet: " << e.what()); + LOG_ERROR("Error saving wallet: " << e.what()); m_status = Status_Error; m_errorString = e.what(); } @@ -1059,6 +1074,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const if (fake_outs_count == 0) fake_outs_count = DEFAULT_MIXIN; + uint32_t adjusted_priority = m_wallet->adjust_priority(static_cast<uint32_t>(priority)); + PendingTransactionImpl * transaction = new PendingTransactionImpl(*this); do { @@ -1118,7 +1135,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const de.is_subaddress = info.is_subaddress; dsts.push_back(de); transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */, - static_cast<uint32_t>(priority), + adjusted_priority, extra, subaddr_account, subaddr_indices, m_trustedDaemon); } else { // for the GUI, sweep_all (i.e. amount set as "(all)") will always sweep all the funds in all the addresses @@ -1128,7 +1145,7 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const subaddr_indices.insert(index); } transaction->m_pending_tx = m_wallet->create_transactions_all(0, info.address, info.is_subaddress, fake_outs_count, 0 /* unlock_time */, - static_cast<uint32_t>(priority), + adjusted_priority, extra, subaddr_account, subaddr_indices, m_trustedDaemon); } diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 0b9fc851b..fcd53c3f8 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -59,7 +59,18 @@ public: bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const; bool open(const std::string &path, const std::string &password); + bool recover(const std::string &path,const std::string &password, + const std::string &seed); + bool recoverFromKeysWithPassword(const std::string &path, + const std::string &password, + const std::string &language, + const std::string &address_string, + const std::string &viewkey_string, + const std::string &spendkey_string = ""); + // following two methods are deprecated since they create passwordless wallets + // use the two equivalent methods above bool recover(const std::string &path, const std::string &seed); + // deprecated: use recoverFromKeysWithPassword() instead bool recoverFromKeys(const std::string &path, const std::string &language, const std::string &address_string, diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index acecbb9dd..a22788399 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -70,6 +70,7 @@ struct PendingTransaction }; enum Priority { + Priority_Default = 0, Priority_Low = 1, Priority_Medium = 2, Priority_High = 3, @@ -105,13 +106,6 @@ struct UnsignedTransaction Status_Critical }; - enum Priority { - Priority_Low = 1, - Priority_Medium = 2, - Priority_High = 3, - Priority_Last - }; - virtual ~UnsignedTransaction() = 0; virtual int status() const = 0; virtual std::string errorString() const = 0; @@ -755,7 +749,7 @@ struct WalletManager * \brief Creates new wallet * \param path Name of wallet file * \param password Password of wallet file - * \param language Language to be used to generate electrum seed memo + * \param language Language to be used to generate electrum seed mnemonic * \return Wallet instance (Wallet::status() needs to be called to check if created successfully) */ virtual Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet = false) = 0; @@ -769,16 +763,51 @@ struct WalletManager virtual Wallet * openWallet(const std::string &path, const std::string &password, bool testnet = false) = 0; /*! - * \brief recovers existing wallet using memo (electrum seed) + * \brief recovers existing wallet using mnemonic (electrum seed) + * \param path Name of wallet file to be created + * \param password Password of wallet file + * \param mnemonic mnemonic (25 words electrum seed) + * \param testnet testnet + * \param restoreHeight restore from start height + * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) + */ + virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, + bool testnet = false, uint64_t restoreHeight = 0) = 0; + + /*! + * \deprecated this method creates a wallet WITHOUT a passphrase, use the alternate recoverWallet() method + * \brief recovers existing wallet using mnemonic (electrum seed) + * \param path Name of wallet file to be created + * \param mnemonic mnemonic (25 words electrum seed) + * \param testnet testnet + * \param restoreHeight restore from start height + * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) + */ + virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, bool testnet = false, uint64_t restoreHeight = 0) = 0; + + /*! + * \brief recovers existing wallet using keys. Creates a view only wallet if spend key is omitted * \param path Name of wallet file to be created - * \param memo memo (25 words electrum seed) + * \param password Password of wallet file + * \param language language * \param testnet testnet * \param restoreHeight restore from start height + * \param addressString public address + * \param viewKeyString view key + * \param spendKeyString spend key (optional) * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) */ - virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet = false, uint64_t restoreHeight = 0) = 0; + virtual Wallet * createWalletFromKeys(const std::string &path, + const std::string &password, + const std::string &language, + bool testnet, + uint64_t restoreHeight, + const std::string &addressString, + const std::string &viewKeyString, + const std::string &spendKeyString = "") = 0; /*! + * \deprecated this method creates a wallet WITHOUT a passphrase, use createWalletFromKeys(..., password, ...) instead * \brief recovers existing wallet using keys. Creates a view only wallet if spend key is omitted * \param path Name of wallet file to be created * \param language language diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp index a6e5e551e..bb144227e 100644 --- a/src/wallet/api/wallet_manager.cpp +++ b/src/wallet/api/wallet_manager.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -76,17 +76,39 @@ Wallet *WalletManagerImpl::openWallet(const std::string &path, const std::string return wallet; } -Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight) +Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, const std::string &mnemonic, bool testnet, uint64_t restoreHeight) +{ + return recoveryWallet(path, "", mnemonic, testnet, restoreHeight); +} + +Wallet *WalletManagerImpl::createWalletFromKeys(const std::string &path, + const std::string &language, + bool testnet, + uint64_t restoreHeight, + const std::string &addressString, + const std::string &viewKeyString, + const std::string &spendKeyString) +{ + return createWalletFromKeys(path, "", language, testnet, restoreHeight, + addressString, viewKeyString, spendKeyString); +} + +Wallet *WalletManagerImpl::recoveryWallet(const std::string &path, + const std::string &password, + const std::string &mnemonic, + bool testnet, + uint64_t restoreHeight) { WalletImpl * wallet = new WalletImpl(testnet); if(restoreHeight > 0){ wallet->setRefreshFromBlockHeight(restoreHeight); } - wallet->recover(path, memo); + wallet->recover(path, password, mnemonic); return wallet; } -Wallet *WalletManagerImpl::createWalletFromKeys(const std::string &path, +Wallet *WalletManagerImpl::createWalletFromKeys(const std::string &path, + const std::string &password, const std::string &language, bool testnet, uint64_t restoreHeight, @@ -98,7 +120,7 @@ Wallet *WalletManagerImpl::createWalletFromKeys(const std::string &path, if(restoreHeight > 0){ wallet->setRefreshFromBlockHeight(restoreHeight); } - wallet->recoverFromKeys(path, language, addressString, viewKeyString, spendKeyString); + wallet->recoverFromKeysWithPassword(path, password, language, addressString, viewKeyString, spendKeyString); return wallet; } diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h index ef5b8f91b..6a4d9de2e 100644 --- a/src/wallet/api/wallet_manager.h +++ b/src/wallet/api/wallet_manager.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -40,7 +40,22 @@ public: Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet); Wallet * openWallet(const std::string &path, const std::string &password, bool testnet); - virtual Wallet * recoveryWallet(const std::string &path, const std::string &memo, bool testnet, uint64_t restoreHeight); + virtual Wallet * recoveryWallet(const std::string &path, + const std::string &password, + const std::string &mnemonic, + bool testnet, + uint64_t restoreHeight); + virtual Wallet * createWalletFromKeys(const std::string &path, + const std::string &password, + const std::string &language, + bool testnet, + uint64_t restoreHeight, + const std::string &addressString, + const std::string &viewKeyString, + const std::string &spendKeyString = ""); + // next two methods are deprecated - use the above version which allow setting of a password + virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, bool testnet, uint64_t restoreHeight); + // deprecated: use createWalletFromKeys(..., password, ...) instead virtual Wallet * createWalletFromKeys(const std::string &path, const std::string &language, bool testnet, diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp index 07185d12c..a9562291e 100644 --- a/src/wallet/node_rpc_proxy.cpp +++ b/src/wallet/node_rpc_proxy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/node_rpc_proxy.h b/src/wallet/node_rpc_proxy.h index fb288189a..1b183212d 100644 --- a/src/wallet/node_rpc_proxy.h +++ b/src/wallet/node_rpc_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 0c2b7e984..d97e53011 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -223,7 +223,7 @@ boost::optional<tools::password_container> get_password(const boost::program_opt THROW_WALLET_EXCEPTION_IF(!password_prompter, tools::error::wallet_internal_error, tools::wallet2::tr("no password specified; use --prompt-for-password to prompt for a password")); - return password_prompter(verify ? tr("Enter new wallet password") : tr("Wallet password"), verify); + return password_prompter(verify ? tr("Enter a new password for the wallet") : tr("Wallet password"), verify); } std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file, const boost::program_options::variables_map& vm, const options& opts, const std::function<boost::optional<tools::password_container>(const char *, bool)> &password_prompter) @@ -361,6 +361,7 @@ std::unique_ptr<tools::wallet2> generate_from_json(const std::string& json_file, wallet.reset(make_basic(vm, opts, password_prompter).release()); wallet->set_refresh_from_block_height(field_scan_from_height); + wallet->explicit_refresh_from_block_height(field_scan_from_height_found); try { @@ -532,12 +533,9 @@ size_t estimate_tx_size(bool use_rct, int n_inputs, int mixin, int n_outputs, si return n_inputs * (mixin+1) * APPROXIMATE_INPUT_BYTES + extra_size; } -uint8_t get_bulletproof_fork(bool testnet) +uint8_t get_bulletproof_fork() { - if (testnet) - return 7; - else - return 255; // TODO + return 8; } crypto::hash8 get_short_payment_id(const tools::wallet2::pending_tx &ptx) @@ -604,6 +602,7 @@ wallet2::wallet2(bool testnet, bool restricted): m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), + m_explicit_refresh_from_block_height(true), m_confirm_missing_payment_id(true), m_ask_password(true), m_min_output_count(0), @@ -611,6 +610,8 @@ wallet2::wallet2(bool testnet, bool restricted): m_merge_destinations(false), m_confirm_backlog(true), m_confirm_backlog_threshold(0), + m_confirm_export_overwrite(true), + m_auto_low_priority(true), m_is_initialized(false), m_restricted(restricted), is_old_file_format(false), @@ -1010,7 +1011,7 @@ static uint64_t decodeRct(const rct::rctSig & rv, const crypto::key_derivation & } } //---------------------------------------------------------------------------------------------------- -void wallet2::scan_output(const cryptonote::account_keys &keys, const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs) +void wallet2::scan_output(const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs) const { THROW_WALLET_EXCEPTION_IF(i >= tx.vout.size(), error::wallet_internal_error, "Invalid vout index"); if (m_multisig) @@ -1021,7 +1022,7 @@ void wallet2::scan_output(const cryptonote::account_keys &keys, const cryptonote } else { - bool r = cryptonote::generate_key_image_helper_precomp(keys, boost::get<cryptonote::txout_to_key>(tx.vout[i].target).key, tx_scan_info.received->derivation, i, tx_scan_info.received->index, tx_scan_info.in_ephemeral, tx_scan_info.ki); + bool r = cryptonote::generate_key_image_helper_precomp(m_account.get_keys(), boost::get<cryptonote::txout_to_key>(tx.vout[i].target).key, tx_scan_info.received->derivation, i, tx_scan_info.received->index, tx_scan_info.in_ephemeral, tx_scan_info.ki); THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key image"); THROW_WALLET_EXCEPTION_IF(tx_scan_info.in_ephemeral.pub != boost::get<cryptonote::txout_to_key>(tx.vout[i].target).key, error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key"); @@ -1126,7 +1127,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); if (tx_scan_info[i].received) { - scan_output(keys, tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); + scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); } } } @@ -1144,7 +1145,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); if (tx_scan_info[i].received) { - scan_output(keys, tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); + scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); } } } @@ -1156,7 +1157,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); if (tx_scan_info[i].received) { - scan_output(keys, tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); + scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); } } } @@ -1331,6 +1332,8 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote } } + uint64_t fee = miner_tx ? 0 : tx.version == 1 ? tx_money_spent_in_ins - get_outs_money_amount(tx) : tx.rct_signatures.txnFee; + if (tx_money_spent_in_ins > 0 && !pool) { uint64_t self_received = std::accumulate<decltype(tx_money_got_in_outs.begin()), uint64_t>(tx_money_got_in_outs.begin(), tx_money_got_in_outs.end(), 0, @@ -1340,7 +1343,6 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote }); process_outgoing(txid, tx, height, ts, tx_money_spent_in_ins, self_received, *subaddr_account, subaddr_indices); // if sending to yourself at the same subaddress account, set the outgoing payment amount to 0 so that it's less confusing - uint64_t fee = tx.version == 1 ? tx_money_spent_in_ins - get_outs_money_amount(tx) : tx.rct_signatures.txnFee; if (tx_money_spent_in_ins == self_received + fee) { auto i = m_confirmed_txs.find(txid); @@ -1405,6 +1407,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote { payment_details payment; payment.m_tx_hash = txid; + payment.m_fee = fee; payment.m_amount = i.second; payment.m_block_height = height; payment.m_unlock_time = tx.unlock_time; @@ -2441,6 +2444,12 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable value2.SetUint(m_confirm_backlog_threshold); json.AddMember("confirm_backlog_threshold", value2, json.GetAllocator()); + value2.SetInt(m_confirm_export_overwrite ? 1 :0); + json.AddMember("confirm_export_overwrite", value2, json.GetAllocator()); + + value2.SetInt(m_auto_low_priority ? 1 : 0); + json.AddMember("auto_low_priority", value2, json.GetAllocator()); + value2.SetInt(m_testnet ? 1 :0); json.AddMember("testnet", value2, json.GetAllocator()); @@ -2522,6 +2531,8 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_ m_merge_destinations = false; m_confirm_backlog = true; m_confirm_backlog_threshold = 0; + m_confirm_export_overwrite = true; + m_auto_low_priority = true; } else if(json.IsObject()) { @@ -2621,6 +2632,10 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_ m_confirm_backlog = field_confirm_backlog; GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, confirm_backlog_threshold, uint32_t, Uint, false, 0); m_confirm_backlog_threshold = field_confirm_backlog_threshold; + GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, confirm_export_overwrite, int, Int, false, true); + m_confirm_export_overwrite = field_confirm_export_overwrite; + GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, m_auto_low_priority, int, Int, false, true); + m_auto_low_priority = field_m_auto_low_priority; GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, testnet, int, Int, false, m_testnet); // Wallet is being opened with testnet flag, but is saved as a mainnet wallet THROW_WALLET_EXCEPTION_IF(m_testnet && !field_testnet, error::wallet_internal_error, "Mainnet wallet can not be opened as testnet wallet"); @@ -3410,16 +3425,6 @@ bool wallet2::parse_payment_id(const std::string& payment_id_str, crypto::hash& return false; } //---------------------------------------------------------------------------------------------------- -void wallet2::set_default_decimal_point(unsigned int decimal_point) -{ - cryptonote::set_default_decimal_point(decimal_point); -} -//---------------------------------------------------------------------------------------------------- -unsigned int wallet2::get_default_decimal_point() const -{ - return cryptonote::get_default_decimal_point(); -} -//---------------------------------------------------------------------------------------------------- bool wallet2::prepare_file_names(const std::string& file_path) { do_prepare_file_names(file_path, m_keys_file, m_wallet_file); @@ -4135,7 +4140,7 @@ size_t wallet2::pop_best_value(std::vector<size_t> &unused_indices, const std::v // returns: // direct return: amount of money found // modified reference: selected_transfers, a list of iterators/indices of input sources -uint64_t wallet2::select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers, bool trusted_daemon) +uint64_t wallet2::select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers, bool trusted_daemon) const { uint64_t found_money = 0; selected_transfers.reserve(unused_transfers_indices.size()); @@ -4143,7 +4148,7 @@ uint64_t wallet2::select_transfers(uint64_t needed_money, std::vector<size_t> un { size_t idx = pop_best_value(unused_transfers_indices, selected_transfers); - transfer_container::iterator it = m_transfers.begin() + idx; + const transfer_container::const_iterator it = m_transfers.begin() + idx; selected_transfers.push_back(idx); found_money += it->amount(); } @@ -4350,7 +4355,7 @@ void wallet2::commit_tx(std::vector<pending_tx>& ptx_vector) } } //---------------------------------------------------------------------------------------------------- -bool wallet2::save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) +bool wallet2::save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const { LOG_PRINT_L0("saving " << ptx_vector.size() << " transactions"); unsigned_tx_set txs; @@ -4379,7 +4384,7 @@ bool wallet2::save_tx(const std::vector<pending_tx>& ptx_vector, const std::stri return epee::file_io_utils::save_string_to_file(filename, std::string(UNSIGNED_TX_PREFIX) + ciphertext); } //---------------------------------------------------------------------------------------------------- -bool wallet2::load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) +bool wallet2::load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const { std::string s; boost::system::error_code errcode; @@ -4953,7 +4958,7 @@ bool wallet2::sign_multisig_tx_from_file(const std::string &filename, std::vecto return sign_multisig_tx_to_file(exported_txs, filename, txids); } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::get_fee_multiplier(uint32_t priority, int fee_algorithm) +uint64_t wallet2::get_fee_multiplier(uint32_t priority, int fee_algorithm) const { static const uint64_t old_multipliers[3] = {1, 2, 3}; static const uint64_t new_multipliers[3] = {1, 20, 166}; @@ -4990,7 +4995,7 @@ uint64_t wallet2::get_fee_multiplier(uint32_t priority, int fee_algorithm) return 1; } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::get_dynamic_per_kb_fee_estimate() +uint64_t wallet2::get_dynamic_per_kb_fee_estimate() const { uint64_t fee; boost::optional<std::string> result = m_node_rpc_proxy.get_dynamic_per_kb_fee_estimate(FEE_ESTIMATE_GRACE_BLOCKS, fee); @@ -5000,7 +5005,7 @@ uint64_t wallet2::get_dynamic_per_kb_fee_estimate() return FEE_PER_KB; } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::get_per_kb_fee() +uint64_t wallet2::get_per_kb_fee() const { if(m_light_wallet) return m_light_wallet_per_kb_fee; @@ -5011,7 +5016,7 @@ uint64_t wallet2::get_per_kb_fee() return get_dynamic_per_kb_fee_estimate(); } //---------------------------------------------------------------------------------------------------- -int wallet2::get_fee_algorithm() +int wallet2::get_fee_algorithm() const { // changes at v3 and v5 if (use_fork_rules(5, 0)) @@ -5021,7 +5026,7 @@ int wallet2::get_fee_algorithm() return 0; } //------------------------------------------------------------------------------------------------------------------------------ -uint64_t wallet2::adjust_mixin(uint64_t mixin) +uint64_t wallet2::adjust_mixin(uint64_t mixin) const { if (mixin < 4 && use_fork_rules(6, 10)) { MWARNING("Requested ring size " << (mixin + 1) << " too low for hard fork 6, using 5"); @@ -5034,6 +5039,90 @@ uint64_t wallet2::adjust_mixin(uint64_t mixin) return mixin; } //---------------------------------------------------------------------------------------------------- +uint32_t wallet2::adjust_priority(uint32_t priority) +{ + if (priority == 0 && get_default_priority() != 1 && auto_low_priority()) + { + try + { + // check if there's a backlog in the tx pool + const double fee_level = get_fee_multiplier(1) * get_per_kb_fee() * (12/(double)13) / (double)1024; + const std::vector<std::pair<uint64_t, uint64_t>> blocks = estimate_backlog({std::make_pair(fee_level, fee_level)}); + if (blocks.size() != 1) + { + MERROR("Bad estimated backlog array size"); + return priority; + } + else if (blocks[0].first > 0) + { + MINFO("We don't use the low priority because there's a backlog in the tx pool."); + return priority; + } + + // get the current full reward zone + epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_INFO::request> getinfo_req = AUTO_VAL_INIT(getinfo_req); + epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_INFO::response, std::string> getinfo_res = AUTO_VAL_INIT(getinfo_res); + m_daemon_rpc_mutex.lock(); + getinfo_req.jsonrpc = "2.0"; + getinfo_req.id = epee::serialization::storage_entry(0); + getinfo_req.method = "get_info"; + bool r = net_utils::invoke_http_json("/json_rpc", getinfo_req, getinfo_res, m_http_client); + m_daemon_rpc_mutex.unlock(); + THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "get_info"); + THROW_WALLET_EXCEPTION_IF(getinfo_res.result.status == CORE_RPC_STATUS_BUSY, error::daemon_busy, "get_info"); + THROW_WALLET_EXCEPTION_IF(getinfo_res.result.status != CORE_RPC_STATUS_OK, error::get_tx_pool_error); + const uint64_t full_reward_zone = getinfo_res.result.block_size_limit / 2; + + // get the last N block headers and sum the block sizes + const size_t N = 10; + if (m_blockchain.size() < N) + { + MERROR("The blockchain is too short"); + return priority; + } + epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::request> getbh_req = AUTO_VAL_INIT(getbh_req); + epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_BLOCK_HEADERS_RANGE::response, std::string> getbh_res = AUTO_VAL_INIT(getbh_res); + m_daemon_rpc_mutex.lock(); + getbh_req.jsonrpc = "2.0"; + getbh_req.id = epee::serialization::storage_entry(0); + getbh_req.method = "getblockheadersrange"; + getbh_req.params.start_height = m_blockchain.size() - N; + getbh_req.params.end_height = m_blockchain.size() - 1; + r = net_utils::invoke_http_json("/json_rpc", getbh_req, getbh_res, m_http_client, rpc_timeout); + m_daemon_rpc_mutex.unlock(); + THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "getblockheadersrange"); + THROW_WALLET_EXCEPTION_IF(getbh_res.result.status == CORE_RPC_STATUS_BUSY, error::daemon_busy, "getblockheadersrange"); + THROW_WALLET_EXCEPTION_IF(getbh_res.result.status != CORE_RPC_STATUS_OK, error::get_blocks_error, getbh_res.result.status); + if (getbh_res.result.headers.size() != N) + { + MERROR("Bad blockheaders size"); + return priority; + } + size_t block_size_sum = 0; + for (const cryptonote::block_header_response &i : getbh_res.result.headers) + { + block_size_sum += i.block_size; + } + + // estimate how 'full' the last N blocks are + const size_t P = 100 * block_size_sum / (N * full_reward_zone); + MINFO((boost::format("The last %d blocks fill roughly %d%% of the full reward zone.") % N % P).str()); + if (P > 80) + { + MINFO("We don't use the low priority because recent blocks are quite full."); + return priority; + } + MINFO("We'll use the low priority because probably it's safe to do so."); + return 1; + } + catch (const std::exception &e) + { + MERROR(e.what()); + } + } + return priority; +} +//---------------------------------------------------------------------------------------------------- // separated the call(s) to wallet2::transfer into their own function // // this function will make multiple calls to wallet2::transfer if multiple @@ -6309,6 +6398,7 @@ void wallet2::light_wallet_get_address_txs() address_tx.m_tx_hash = tx_hash; address_tx.m_incoming = incoming; address_tx.m_amount = incoming ? total_received - total_sent : total_sent - total_received; + address_tx.m_fee = 0; // TODO address_tx.m_block_height = t.height; address_tx.m_unlock_time = t.unlock_time; address_tx.m_timestamp = t.timestamp; @@ -6322,6 +6412,7 @@ void wallet2::light_wallet_get_address_txs() payment_details payment; payment.m_tx_hash = tx_hash; payment.m_amount = total_received - total_sent; + payment.m_fee = 0; // TODO payment.m_block_height = t.height; payment.m_unlock_time = t.unlock_time; payment.m_timestamp = t.timestamp; @@ -6550,7 +6641,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp uint64_t needed_fee, available_for_fee = 0; uint64_t upper_transaction_size_limit = get_upper_transaction_size_limit(); const bool use_rct = use_fork_rules(4, 0); - const bool bulletproof = use_fork_rules(get_bulletproof_fork(m_testnet), 0); + const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0); const uint64_t fee_per_kb = get_per_kb_fee(); const uint64_t fee_multiplier = get_fee_multiplier(priority, get_fee_algorithm()); @@ -7059,7 +7150,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton std::vector<std::vector<get_outs_entry>> outs; const bool use_rct = fake_outs_count > 0 && use_fork_rules(4, 0); - const bool bulletproof = use_fork_rules(get_bulletproof_fork(m_testnet), 0); + const bool bulletproof = use_fork_rules(get_bulletproof_fork(), 0); const uint64_t fee_per_kb = get_per_kb_fee(); const uint64_t fee_multiplier = get_fee_multiplier(priority, get_fee_algorithm()); @@ -7178,13 +7269,13 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton return ptx_vector; } //---------------------------------------------------------------------------------------------------- -void wallet2::get_hard_fork_info(uint8_t version, uint64_t &earliest_height) +void wallet2::get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const { boost::optional<std::string> result = m_node_rpc_proxy.get_earliest_height(version, earliest_height); throw_on_rpc_response_error(result, "get_hard_fork_info"); } //---------------------------------------------------------------------------------------------------- -bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) +bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) const { // TODO: How to get fork rule info from light wallet node? if(m_light_wallet) @@ -7203,7 +7294,7 @@ bool wallet2::use_fork_rules(uint8_t version, int64_t early_blocks) return close_enough; } //---------------------------------------------------------------------------------------------------- -uint64_t wallet2::get_upper_transaction_size_limit() +uint64_t wallet2::get_upper_transaction_size_limit() const { if (m_upper_transaction_size_limit > 0) return m_upper_transaction_size_limit; @@ -7211,7 +7302,7 @@ uint64_t wallet2::get_upper_transaction_size_limit() return full_reward_zone - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; } //---------------------------------------------------------------------------------------------------- -std::vector<size_t> wallet2::select_available_outputs(const std::function<bool(const transfer_details &td)> &f) +std::vector<size_t> wallet2::select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const { std::vector<size_t> outputs; size_t n = 0; @@ -7229,7 +7320,7 @@ std::vector<size_t> wallet2::select_available_outputs(const std::function<bool(c return outputs; } //---------------------------------------------------------------------------------------------------- -std::vector<uint64_t> wallet2::get_unspent_amounts_vector() +std::vector<uint64_t> wallet2::get_unspent_amounts_vector() const { std::set<uint64_t> set; for (const auto &td: m_transfers) @@ -8204,7 +8295,7 @@ std::string wallet2::get_daemon_address() const return m_daemon_address; } -uint64_t wallet2::get_daemon_blockchain_height(string &err) +uint64_t wallet2::get_daemon_blockchain_height(string &err) const { uint64_t height; @@ -8262,8 +8353,9 @@ uint64_t wallet2::get_approximate_blockchain_height() const // Calculated blockchain height uint64_t approx_blockchain_height = fork_block + (time(NULL) - fork_time)/seconds_per_block; // testnet got some huge rollbacks, so the estimation is way off - if (m_testnet && approx_blockchain_height > 105000) - approx_blockchain_height -= 105000; + static const uint64_t approximate_testnet_rolled_back_blocks = 148540; + if (m_testnet && approx_blockchain_height > approximate_testnet_rolled_back_blocks) + approx_blockchain_height -= approximate_testnet_rolled_back_blocks; LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height); return approx_blockchain_height; } @@ -8434,7 +8526,7 @@ crypto::public_key wallet2::get_tx_pub_key_from_received_outs(const tools::walle return crypto::null_pkey; } -bool wallet2::export_key_images(const std::string &filename) +bool wallet2::export_key_images(const std::string &filename) const { std::vector<std::pair<crypto::key_image, crypto::signature>> ski = export_key_images(); std::string magic(KEY_IMAGE_EXPORT_FILE_MAGIC, strlen(KEY_IMAGE_EXPORT_FILE_MAGIC)); @@ -8839,7 +8931,7 @@ void wallet2::import_blockchain(const std::tuple<size_t, crypto::hash, std::vect m_blockchain.clear(); if (std::get<0>(bc)) { - for (size_t n = std::get<0>(bc); n > 0; ++n) + for (size_t n = std::get<0>(bc); n > 0; --n) m_blockchain.push_back(std::get<1>(bc)); m_blockchain.trim(std::get<0>(bc)); } @@ -9238,7 +9330,7 @@ std::string wallet2::decrypt_with_view_secret_key(const std::string &ciphertext, return decrypt(ciphertext, get_account().get_keys().m_view_secret_key, authenticated); } //---------------------------------------------------------------------------------------------------- -std::string wallet2::make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) +std::string wallet2::make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const { cryptonote::address_parse_info info; if(!get_account_address_from_str(info, testnet(), address)) @@ -9472,13 +9564,12 @@ bool wallet2::is_synced() const return get_blockchain_current_height() >= height; } //---------------------------------------------------------------------------------------------------- -std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees) +std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels) { - THROW_WALLET_EXCEPTION_IF(min_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); - THROW_WALLET_EXCEPTION_IF(max_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); - for (uint64_t fee: fees) + for (const auto &fee_level: fee_levels) { - THROW_WALLET_EXCEPTION_IF(fee == 0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(fee_level.first == 0.0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(fee_level.second == 0.0, error::wallet_internal_error, "Invalid 0 fee"); } // get txpool backlog @@ -9508,9 +9599,10 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t mi uint64_t full_reward_zone = resp_t.result.block_size_limit / 2; std::vector<std::pair<uint64_t, uint64_t>> blocks; - for (uint64_t fee: fees) + for (const auto &fee_level: fee_levels) { - double our_fee_byte_min = fee / (double)min_blob_size, our_fee_byte_max = fee / (double)max_blob_size; + const double our_fee_byte_min = fee_level.first; + const double our_fee_byte_max = fee_level.second; uint64_t priority_size_min = 0, priority_size_max = 0; for (const auto &i: res.result.backlog) { @@ -9528,15 +9620,32 @@ std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t mi uint64_t nblocks_min = priority_size_min / full_reward_zone; uint64_t nblocks_max = priority_size_max / full_reward_zone; - MDEBUG("estimate_backlog: priority_size " << priority_size_min << " - " << priority_size_max << " for " << fee - << " (" << our_fee_byte_min << " - " << our_fee_byte_max << " piconero byte fee), " + MDEBUG("estimate_backlog: priority_size " << priority_size_min << " - " << priority_size_max << " for " + << our_fee_byte_min << " - " << our_fee_byte_max << " piconero byte fee, " << nblocks_min << " - " << nblocks_max << " blocks at block size " << full_reward_zone); blocks.push_back(std::make_pair(nblocks_min, nblocks_max)); } return blocks; } //---------------------------------------------------------------------------------------------------- -void wallet2::generate_genesis(cryptonote::block& b) { +std::vector<std::pair<uint64_t, uint64_t>> wallet2::estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees) +{ + THROW_WALLET_EXCEPTION_IF(min_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); + THROW_WALLET_EXCEPTION_IF(max_blob_size == 0, error::wallet_internal_error, "Invalid 0 fee"); + for (uint64_t fee: fees) + { + THROW_WALLET_EXCEPTION_IF(fee == 0, error::wallet_internal_error, "Invalid 0 fee"); + } + std::vector<std::pair<double, double>> fee_levels; + for (uint64_t fee: fees) + { + double our_fee_byte_min = fee / (double)min_blob_size, our_fee_byte_max = fee / (double)max_blob_size; + fee_levels.emplace_back(our_fee_byte_min, our_fee_byte_max); + } + return estimate_backlog(fee_levels); +} +//---------------------------------------------------------------------------------------------------- +void wallet2::generate_genesis(cryptonote::block& b) const { if (m_testnet) { cryptonote::generate_genesis_block(b, config::testnet::GENESIS_TX, config::testnet::GENESIS_NONCE); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 04d789f18..f9995c2ee 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -252,6 +252,7 @@ namespace tools { crypto::hash m_tx_hash; uint64_t m_amount; + uint64_t m_fee; uint64_t m_block_height; uint64_t m_unlock_time; uint64_t m_timestamp; @@ -560,6 +561,9 @@ namespace tools void set_refresh_from_block_height(uint64_t height) {m_refresh_from_block_height = height;} uint64_t get_refresh_from_block_height() const {return m_refresh_from_block_height;} + void explicit_refresh_from_block_height(bool expl) {m_explicit_refresh_from_block_height = expl;} + bool explicit_refresh_from_block_height() const {return m_explicit_refresh_from_block_height;} + // upper_transaction_size_limit as defined below is set to // approximately 125% of the fixed minimum allowable penalty // free block size. TODO: fix this so that it actually takes @@ -656,7 +660,7 @@ namespace tools void commit_tx(pending_tx& ptx_vector); void commit_tx(std::vector<pending_tx>& ptx_vector); - bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename); + bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const; std::string save_multisig_tx(multisig_tx_set txs); bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename); std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector); @@ -666,7 +670,7 @@ namespace tools // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false); // load unsigned_tx_set from file. - bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs); + bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const; bool load_tx(const std::string &signed_filename, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set&)> accept_func = NULL); std::vector<pending_tx> create_transactions(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, bool trusted_daemon); std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, bool trusted_daemon); // pass subaddr_indices by value on purpose @@ -825,8 +829,6 @@ namespace tools void confirm_missing_payment_id(bool always) { m_confirm_missing_payment_id = always; } bool ask_password() const { return m_ask_password; } void ask_password(bool always) { m_ask_password = always; } - void set_default_decimal_point(unsigned int decimal_point); - unsigned int get_default_decimal_point() const; void set_min_output_count(uint32_t count) { m_min_output_count = count; } uint32_t get_min_output_count() const { return m_min_output_count; } void set_min_output_value(uint64_t value) { m_min_output_value = value; } @@ -837,6 +839,10 @@ namespace tools void confirm_backlog(bool always) { m_confirm_backlog = always; } void set_confirm_backlog_threshold(uint32_t threshold) { m_confirm_backlog_threshold = threshold; }; uint32_t get_confirm_backlog_threshold() const { return m_confirm_backlog_threshold; }; + bool confirm_export_overwrite() const { return m_confirm_export_overwrite; } + void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; } + bool auto_low_priority() const { return m_auto_low_priority; } + void auto_low_priority(bool value) { m_auto_low_priority = value; } bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const; void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations); @@ -877,15 +883,15 @@ namespace tools size_t get_num_transfer_details() const { return m_transfers.size(); } const transfer_details &get_transfer_details(size_t idx) const; - void get_hard_fork_info(uint8_t version, uint64_t &earliest_height); - bool use_fork_rules(uint8_t version, int64_t early_blocks = 0); - int get_fee_algorithm(); + void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const; + bool use_fork_rules(uint8_t version, int64_t early_blocks = 0) const; + int get_fee_algorithm() const; std::string get_wallet_file() const; std::string get_keys_file() const; std::string get_daemon_address() const; const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; } - uint64_t get_daemon_blockchain_height(std::string& err); + uint64_t get_daemon_blockchain_height(std::string& err) const; uint64_t get_daemon_blockchain_target_height(std::string& err); /*! * \brief Calculates the approximate blockchain height from current date/time. @@ -893,7 +899,7 @@ namespace tools uint64_t get_approximate_blockchain_height() const; uint64_t estimate_blockchain_height(); std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct, bool trusted_daemon); - std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f); + std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const; std::vector<size_t> select_available_unmixable_outputs(bool trusted_daemon); std::vector<size_t> select_available_mixable_outputs(bool trusted_daemon); @@ -935,7 +941,7 @@ namespace tools void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments); std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const; void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc); - bool export_key_images(const std::string &filename); + bool export_key_images(const std::string &filename) const; std::vector<std::pair<crypto::key_image, crypto::signature>> export_key_images() const; uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent = true); uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent); @@ -948,18 +954,20 @@ namespace tools std::string decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const; std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const; - std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error); + std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const; bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error); uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31 bool is_synced() const; + std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels); std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_blob_size, uint64_t max_blob_size, const std::vector<uint64_t> &fees); - uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1); - uint64_t get_per_kb_fee(); - uint64_t adjust_mixin(uint64_t mixin); + uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const; + uint64_t get_per_kb_fee() const; + uint64_t adjust_mixin(uint64_t mixin) const; + uint32_t adjust_priority(uint32_t priority); // Light wallet specific functions // fetch unspent outs from lw node and store in m_transfers @@ -1029,20 +1037,20 @@ namespace tools void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history); void pull_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, const std::list<cryptonote::block_complete_entry> &prev_blocks, std::list<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices, bool &error); void process_blocks(uint64_t start_height, const std::list<cryptonote::block_complete_entry> &blocks, const std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices, uint64_t& blocks_added); - uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers, bool trusted_daemon); + uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers, bool trusted_daemon) const; bool prepare_file_names(const std::string& file_path); void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height); void process_outgoing(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices); void add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amount_in, const std::vector<cryptonote::tx_destination_entry> &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices); - void generate_genesis(cryptonote::block& b); + void generate_genesis(cryptonote::block& b) const; void check_genesis(const crypto::hash& genesis_hash) const; //throws bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const; crypto::hash get_payment_id(const pending_tx &ptx) const; void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const; void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const; - uint64_t get_upper_transaction_size_limit(); - std::vector<uint64_t> get_unspent_amounts_vector(); - uint64_t get_dynamic_per_kb_fee_estimate(); + uint64_t get_upper_transaction_size_limit() const; + std::vector<uint64_t> get_unspent_amounts_vector() const; + uint64_t get_dynamic_per_kb_fee_estimate() const; float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const; std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) const; void set_spent(size_t idx, uint64_t height); @@ -1052,7 +1060,7 @@ namespace tools crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const; bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const; std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const; - void scan_output(const cryptonote::account_keys &keys, const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs); + void scan_output(const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs) const; void trim_hashchain(); crypto::key_image get_multisig_composite_key_image(size_t n) const; rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const; @@ -1112,6 +1120,9 @@ namespace tools RefreshType m_refresh_type; bool m_auto_refresh; uint64_t m_refresh_from_block_height; + // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that + // m_refresh_from_block_height was defaulted to zero.*/ + bool m_explicit_refresh_from_block_height; bool m_confirm_missing_payment_id; bool m_ask_password; uint32_t m_min_output_count; @@ -1119,6 +1130,8 @@ namespace tools bool m_merge_destinations; bool m_confirm_backlog; uint32_t m_confirm_backlog_threshold; + bool m_confirm_export_overwrite; + bool m_auto_low_priority; bool m_is_initialized; NodeRPCProxy m_node_rpc_proxy; std::unordered_set<crypto::hash> m_scanned_pool_txs[2]; @@ -1144,7 +1157,7 @@ BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 9) BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1) BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0) BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1) -BOOST_CLASS_VERSION(tools::wallet2::payment_details, 2) +BOOST_CLASS_VERSION(tools::wallet2::payment_details, 3) BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1) BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 7) BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 5) @@ -1409,6 +1422,12 @@ namespace boost return; } a & x.m_subaddr_index; + if (ver < 3) + { + x.m_fee = 0; + return; + } + a & x.m_fee; } template <class Archive> diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp index 2273f14ad..a6ff63dd3 100644 --- a/src/wallet/wallet_args.cpp +++ b/src/wallet/wallet_args.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet_args.h b/src/wallet/wallet_args.h index 212958988..af6685845 100644 --- a/src/wallet/wallet_args.h +++ b/src/wallet/wallet_args.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index 023b53f28..5c1c49d5d 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 3bb69f2be..7d17591db 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -254,7 +254,7 @@ namespace tools entry.timestamp = pd.m_timestamp; entry.amount = pd.m_amount; entry.unlock_time = pd.m_unlock_time; - entry.fee = 0; // TODO + entry.fee = pd.m_fee; entry.note = m_wallet->get_tx_note(pd.m_tx_hash); entry.type = "in"; entry.subaddr_index = pd.m_subaddr_index; @@ -317,7 +317,7 @@ namespace tools entry.timestamp = pd.m_timestamp; entry.amount = pd.m_amount; entry.unlock_time = pd.m_unlock_time; - entry.fee = 0; // TODO + entry.fee = pd.m_fee; entry.note = m_wallet->get_tx_note(pd.m_tx_hash); entry.double_spend_seen = ppd.m_double_spend_seen; entry.type = "pool"; @@ -786,7 +786,8 @@ namespace tools try { uint64_t mixin = m_wallet->adjust_mixin(req.mixin); - std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); + uint32_t priority = m_wallet->adjust_priority(req.priority); + std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); if (ptx_vector.empty()) { @@ -837,8 +838,9 @@ namespace tools try { uint64_t mixin = m_wallet->adjust_mixin(req.mixin); + uint32_t priority = m_wallet->adjust_priority(req.priority); LOG_PRINT_L2("on_transfer_split calling create_transactions_2"); - std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); + std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); LOG_PRINT_L2("on_transfer_split called create_transactions_2"); return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, req.do_not_relay, @@ -903,7 +905,8 @@ namespace tools try { uint64_t mixin = m_wallet->adjust_mixin(req.mixin); - std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); + uint32_t priority = m_wallet->adjust_priority(req.priority); + std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon); return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, req.do_not_relay, res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er); @@ -950,7 +953,8 @@ namespace tools try { uint64_t mixin = m_wallet->adjust_mixin(req.mixin); - std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, req.priority, extra, m_trusted_daemon); + uint32_t priority = m_wallet->adjust_priority(req.priority); + std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_single(ki, dsts[0].addr, dsts[0].is_subaddress, mixin, req.unlock_time, priority, extra, m_trusted_daemon); if (ptx_vector.empty()) { @@ -1319,6 +1323,10 @@ namespace tools { res.key = string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key); } + else if(req.key_type.compare("spend_key") == 0) + { + res.key = string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key); + } else { er.message = "key_type " + req.key_type + " not found"; @@ -2914,12 +2922,12 @@ int main(int argc, char** argv) { // if we ^C during potentially length load/refresh, there's no server loop yet if (quit) { - MINFO(tools::wallet_rpc_server::tr("Storing wallet...")); + MINFO(tools::wallet_rpc_server::tr("Saving wallet...")); wal->store(); - MINFO(tools::wallet_rpc_server::tr("Stored ok")); + MINFO(tools::wallet_rpc_server::tr("Successfully saved")); return 1; } - MINFO(tools::wallet_rpc_server::tr("Loaded ok")); + MINFO(tools::wallet_rpc_server::tr("Successfully loaded")); } catch (const std::exception& e) { @@ -2930,11 +2938,11 @@ just_dir: tools::wallet_rpc_server wrpc; if (wal) wrpc.set_wallet(wal.release()); bool r = wrpc.init(&(vm.get())); - CHECK_AND_ASSERT_MES(r, 1, tools::wallet_rpc_server::tr("Failed to initialize wallet rpc server")); + CHECK_AND_ASSERT_MES(r, 1, tools::wallet_rpc_server::tr("Failed to initialize wallet RPC server")); tools::signal_handler::install([&wrpc](int) { wrpc.send_stop_signal(); }); - LOG_PRINT_L0(tools::wallet_rpc_server::tr("Starting wallet rpc server")); + LOG_PRINT_L0(tools::wallet_rpc_server::tr("Starting wallet RPC server")); try { wrpc.run(); @@ -2944,16 +2952,16 @@ just_dir: LOG_ERROR(tools::wallet_rpc_server::tr("Failed to run wallet: ") << e.what()); return 1; } - LOG_PRINT_L0(tools::wallet_rpc_server::tr("Stopped wallet rpc server")); + LOG_PRINT_L0(tools::wallet_rpc_server::tr("Stopped wallet RPC server")); try { - LOG_PRINT_L0(tools::wallet_rpc_server::tr("Storing wallet...")); + LOG_PRINT_L0(tools::wallet_rpc_server::tr("Saving wallet...")); wrpc.stop(); - LOG_PRINT_L0(tools::wallet_rpc_server::tr("Stored ok")); + LOG_PRINT_L0(tools::wallet_rpc_server::tr("Successfully saved")); } catch (const std::exception& e) { - LOG_ERROR(tools::wallet_rpc_server::tr("Failed to store wallet: ") << e.what()); + LOG_ERROR(tools::wallet_rpc_server::tr("Failed to save wallet: ") << e.what()); return 1; } return 0; diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index a70d8626e..bb458aa99 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index ac25e8e84..e9f112b63 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/src/wallet/wallet_rpc_server_error_codes.h b/src/wallet/wallet_rpc_server_error_codes.h index 578413e38..311556657 100644 --- a/src/wallet/wallet_rpc_server_error_codes.h +++ b/src/wallet/wallet_rpc_server_error_codes.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d0c89db46..20afd4203 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/core_proxy/CMakeLists.txt b/tests/core_proxy/CMakeLists.txt index d2dc93cf0..105c20d22 100644 --- a/tests/core_proxy/CMakeLists.txt +++ b/tests/core_proxy/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp index d6c89fc39..8c9340318 100644 --- a/tests/core_proxy/core_proxy.cpp +++ b/tests/core_proxy/core_proxy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_proxy/core_proxy.h b/tests/core_proxy/core_proxy.h index 51f0f892c..b7c3dc022 100644 --- a/tests/core_proxy/core_proxy.h +++ b/tests/core_proxy/core_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/CMakeLists.txt b/tests/core_tests/CMakeLists.txt index d80d62135..4d2452e84 100644 --- a/tests/core_tests/CMakeLists.txt +++ b/tests/core_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index 8e68554d3..9b0e74911 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/block_reward.h b/tests/core_tests/block_reward.h index 1ec890bbe..b7eb7c98e 100644 --- a/tests/core_tests/block_reward.h +++ b/tests/core_tests/block_reward.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp index 94b636f82..b9818d2c5 100644 --- a/tests/core_tests/block_validation.cpp +++ b/tests/core_tests/block_validation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/block_validation.h b/tests/core_tests/block_validation.h index d3cf00cc0..d229e4530 100644 --- a/tests/core_tests/block_validation.h +++ b/tests/core_tests/block_validation.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chain_split_1.cpp b/tests/core_tests/chain_split_1.cpp index 79aecb1c0..d78e793bb 100644 --- a/tests/core_tests/chain_split_1.cpp +++ b/tests/core_tests/chain_split_1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chain_split_1.h b/tests/core_tests/chain_split_1.h index 25fd8d3a3..75602d1b0 100644 --- a/tests/core_tests/chain_split_1.h +++ b/tests/core_tests/chain_split_1.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chain_switch_1.cpp b/tests/core_tests/chain_switch_1.cpp index 01cf00f7a..c5017a0df 100644 --- a/tests/core_tests/chain_switch_1.cpp +++ b/tests/core_tests/chain_switch_1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chain_switch_1.h b/tests/core_tests/chain_switch_1.h index f1d59ca69..5a035bf06 100644 --- a/tests/core_tests/chain_switch_1.h +++ b/tests/core_tests/chain_switch_1.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 4c5dc6c9a..c1bcc7a47 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index 9fed95183..6a723d56f 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chaingen001.cpp b/tests/core_tests/chaingen001.cpp index a01f92229..e84bfb924 100644 --- a/tests/core_tests/chaingen001.cpp +++ b/tests/core_tests/chaingen001.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 95284c11a..6a1992cd1 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/chaingen_tests_list.h b/tests/core_tests/chaingen_tests_list.h index b9bbf03b4..174610d5d 100644 --- a/tests/core_tests/chaingen_tests_list.h +++ b/tests/core_tests/chaingen_tests_list.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/double_spend.cpp b/tests/core_tests/double_spend.cpp index d82120254..7ed62cf6d 100644 --- a/tests/core_tests/double_spend.cpp +++ b/tests/core_tests/double_spend.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/double_spend.h b/tests/core_tests/double_spend.h index b7483e0e5..276e74853 100644 --- a/tests/core_tests/double_spend.h +++ b/tests/core_tests/double_spend.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/double_spend.inl b/tests/core_tests/double_spend.inl index bf63503ae..0c58fb018 100644 --- a/tests/core_tests/double_spend.inl +++ b/tests/core_tests/double_spend.inl @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp index 4abdfbff5..e7e1ac9ca 100644 --- a/tests/core_tests/integer_overflow.cpp +++ b/tests/core_tests/integer_overflow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/integer_overflow.h b/tests/core_tests/integer_overflow.h index e18c085ea..eaca268e4 100644 --- a/tests/core_tests/integer_overflow.h +++ b/tests/core_tests/integer_overflow.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/multisig.cpp b/tests/core_tests/multisig.cpp index 79a3a7cf4..c35800e6c 100644 --- a/tests/core_tests/multisig.cpp +++ b/tests/core_tests/multisig.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/multisig.h b/tests/core_tests/multisig.h index 62a1c6a35..f0157a6d1 100644 --- a/tests/core_tests/multisig.h +++ b/tests/core_tests/multisig.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/rct.cpp b/tests/core_tests/rct.cpp index e5047baf2..62799d842 100644 --- a/tests/core_tests/rct.cpp +++ b/tests/core_tests/rct.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/rct.h b/tests/core_tests/rct.h index 8cd84c462..641f3dd5e 100644 --- a/tests/core_tests/rct.h +++ b/tests/core_tests/rct.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/ring_signature_1.cpp b/tests/core_tests/ring_signature_1.cpp index 43c63dc53..38eb1cf9b 100644 --- a/tests/core_tests/ring_signature_1.cpp +++ b/tests/core_tests/ring_signature_1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/ring_signature_1.h b/tests/core_tests/ring_signature_1.h index 1de24d15d..7ff6cfd96 100644 --- a/tests/core_tests/ring_signature_1.h +++ b/tests/core_tests/ring_signature_1.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp index 00c602103..9157c2db4 100644 --- a/tests/core_tests/transaction_tests.cpp +++ b/tests/core_tests/transaction_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/transaction_tests.h b/tests/core_tests/transaction_tests.h index b58aae99c..9500c66f6 100644 --- a/tests/core_tests/transaction_tests.h +++ b/tests/core_tests/transaction_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp index 9987f80d6..6707cc003 100644 --- a/tests/core_tests/tx_validation.cpp +++ b/tests/core_tests/tx_validation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/tx_validation.h b/tests/core_tests/tx_validation.h index 9e49cf0ff..01a258a20 100644 --- a/tests/core_tests/tx_validation.h +++ b/tests/core_tests/tx_validation.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp index 6c2f91fcf..b96c744b3 100644 --- a/tests/core_tests/v2_tests.cpp +++ b/tests/core_tests/v2_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/core_tests/v2_tests.h b/tests/core_tests/v2_tests.h index 0a2111adf..ecb23818c 100644 --- a/tests/core_tests/v2_tests.h +++ b/tests/core_tests/v2_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt index f4abb3a9a..df96c57cc 100644 --- a/tests/crypto/CMakeLists.txt +++ b/tests/crypto/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/crypto/crypto-ops-data.c b/tests/crypto/crypto-ops-data.c index dd509ef39..9bdd6b88f 100644 --- a/tests/crypto/crypto-ops-data.c +++ b/tests/crypto/crypto-ops-data.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/crypto-ops.c b/tests/crypto/crypto-ops.c index c10f2f750..476de786a 100644 --- a/tests/crypto/crypto-ops.c +++ b/tests/crypto/crypto-ops.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/crypto-tests.h b/tests/crypto/crypto-tests.h index 0271fc22c..d910a845c 100644 --- a/tests/crypto/crypto-tests.h +++ b/tests/crypto/crypto-tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/crypto.cpp b/tests/crypto/crypto.cpp index 6142ebd2b..6a1dd1b29 100644 --- a/tests/crypto/crypto.cpp +++ b/tests/crypto/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/hash.c b/tests/crypto/hash.c index 849f5678e..6b865abd9 100644 --- a/tests/crypto/hash.c +++ b/tests/crypto/hash.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/main.cpp b/tests/crypto/main.cpp index 0fc8aba59..e5406f771 100644 --- a/tests/crypto/main.cpp +++ b/tests/crypto/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/crypto/random.c b/tests/crypto/random.c index 4ada988b9..e9464d457 100644 --- a/tests/crypto/random.c +++ b/tests/crypto/random.c @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/cryptolib.pl b/tests/cryptolib.pl index 8e835ab62..3d4cb638b 100644 --- a/tests/cryptolib.pl +++ b/tests/cryptolib.pl @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/cryptotest.pl b/tests/cryptotest.pl index cca346da3..13f8db09e 100644 --- a/tests/cryptotest.pl +++ b/tests/cryptotest.pl @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/daemon_tests/CMakeLists.txt b/tests/daemon_tests/CMakeLists.txt index b554bfec8..bc1dce2cc 100644 --- a/tests/daemon_tests/CMakeLists.txt +++ b/tests/daemon_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/daemon_tests/transfers.cpp b/tests/daemon_tests/transfers.cpp index 1fbd43fe6..726f11dfb 100644 --- a/tests/daemon_tests/transfers.cpp +++ b/tests/daemon_tests/transfers.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/difficulty/CMakeLists.txt b/tests/difficulty/CMakeLists.txt index 9244c773e..3cb8af8d5 100644 --- a/tests/difficulty/CMakeLists.txt +++ b/tests/difficulty/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/difficulty/difficulty.cpp b/tests/difficulty/difficulty.cpp index 14f027e4d..736a58237 100644 --- a/tests/difficulty/difficulty.cpp +++ b/tests/difficulty/difficulty.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/difficulty/generate-data b/tests/difficulty/generate-data index 8dfb2e8f1..c41ce025d 100755 --- a/tests/difficulty/generate-data +++ b/tests/difficulty/generate-data @@ -1,6 +1,6 @@ #!/usr/bin/python3 -# Copyright (c) 2014-2016, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt index 498fe3c2c..7a2a7fbd1 100644 --- a/tests/functional_tests/CMakeLists.txt +++ b/tests/functional_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index 9fd24cc06..b9a686dbc 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/functional_tests/transactions_flow_test.cpp b/tests/functional_tests/transactions_flow_test.cpp index d39b1b2e8..98368c26b 100644 --- a/tests/functional_tests/transactions_flow_test.cpp +++ b/tests/functional_tests/transactions_flow_test.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/functional_tests/transactions_flow_test.h b/tests/functional_tests/transactions_flow_test.h index 28baf0768..78135b9c0 100644 --- a/tests/functional_tests/transactions_flow_test.h +++ b/tests/functional_tests/transactions_flow_test.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/functional_tests/transactions_generation_from_blockchain.cpp b/tests/functional_tests/transactions_generation_from_blockchain.cpp index b1c2819bf..92dc00f2d 100644 --- a/tests/functional_tests/transactions_generation_from_blockchain.cpp +++ b/tests/functional_tests/transactions_generation_from_blockchain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/functional_tests/transactions_generation_from_blockchain.h b/tests/functional_tests/transactions_generation_from_blockchain.h index 1176f0c1d..b684f7c7a 100644 --- a/tests/functional_tests/transactions_generation_from_blockchain.h +++ b/tests/functional_tests/transactions_generation_from_blockchain.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt index 5d58f9a3c..6d34b13e2 100644 --- a/tests/fuzz/CMakeLists.txt +++ b/tests/fuzz/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # @@ -143,6 +143,7 @@ target_link_libraries(http-client_fuzz_tests PRIVATE epee ${Boost_THREAD_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SYSTEM_LIBRARY} @@ -158,6 +159,7 @@ target_link_libraries(levin_fuzz_tests common epee ${Boost_THREAD_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} diff --git a/tests/fuzz/base58.cpp b/tests/fuzz/base58.cpp index aea62f721..49516dd83 100644 --- a/tests/fuzz/base58.cpp +++ b/tests/fuzz/base58.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/block.cpp b/tests/fuzz/block.cpp index ce8785cc3..2df77b046 100644 --- a/tests/fuzz/block.cpp +++ b/tests/fuzz/block.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/cold-outputs.cpp b/tests/fuzz/cold-outputs.cpp index 6e813d823..e6f92db27 100644 --- a/tests/fuzz/cold-outputs.cpp +++ b/tests/fuzz/cold-outputs.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/cold-transaction.cpp b/tests/fuzz/cold-transaction.cpp index 20715c9ed..5879d6253 100644 --- a/tests/fuzz/cold-transaction.cpp +++ b/tests/fuzz/cold-transaction.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp index 686a5e5f0..b81bf80fe 100644 --- a/tests/fuzz/fuzzer.cpp +++ b/tests/fuzz/fuzzer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/fuzzer.h b/tests/fuzz/fuzzer.h index a0a9c0173..2bf01914a 100644 --- a/tests/fuzz/fuzzer.h +++ b/tests/fuzz/fuzzer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/http-client.cpp b/tests/fuzz/http-client.cpp index 21560df21..cd52643d9 100644 --- a/tests/fuzz/http-client.cpp +++ b/tests/fuzz/http-client.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/levin.cpp b/tests/fuzz/levin.cpp index 2fd60ae50..2c3971470 100644 --- a/tests/fuzz/levin.cpp +++ b/tests/fuzz/levin.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/load_from_binary.cpp b/tests/fuzz/load_from_binary.cpp index 3c8dd177b..8f96c454f 100644 --- a/tests/fuzz/load_from_binary.cpp +++ b/tests/fuzz/load_from_binary.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/load_from_json.cpp b/tests/fuzz/load_from_json.cpp index 5d39c89a6..b0c1a9bf3 100644 --- a/tests/fuzz/load_from_json.cpp +++ b/tests/fuzz/load_from_json.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/parse_url.cpp b/tests/fuzz/parse_url.cpp index bf3a3bdd4..8812cf9c2 100644 --- a/tests/fuzz/parse_url.cpp +++ b/tests/fuzz/parse_url.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/signature.cpp b/tests/fuzz/signature.cpp index e7a0a53df..69fae84fa 100644 --- a/tests/fuzz/signature.cpp +++ b/tests/fuzz/signature.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/fuzz/transaction.cpp b/tests/fuzz/transaction.cpp index 294676404..b3349c383 100644 --- a/tests/fuzz/transaction.cpp +++ b/tests/fuzz/transaction.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/hash-target.cpp b/tests/hash-target.cpp index a26ae6059..2737ae30e 100644 --- a/tests/hash-target.cpp +++ b/tests/hash-target.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/hash/CMakeLists.txt b/tests/hash/CMakeLists.txt index 950df10b1..e2aca8517 100644 --- a/tests/hash/CMakeLists.txt +++ b/tests/hash/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/hash/main.cpp b/tests/hash/main.cpp index 5f8b7856d..aa928856a 100644 --- a/tests/hash/main.cpp +++ b/tests/hash/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/io.h b/tests/io.h index e1edfe369..ec5a9ee60 100644 --- a/tests/io.h +++ b/tests/io.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/libwallet_api_tests/CMakeLists.txt b/tests/libwallet_api_tests/CMakeLists.txt index 7da0d113e..ef066d340 100644 --- a/tests/libwallet_api_tests/CMakeLists.txt +++ b/tests/libwallet_api_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp index 25fa547f8..96e327ef1 100644 --- a/tests/libwallet_api_tests/main.cpp +++ b/tests/libwallet_api_tests/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt index 78d670c5f..1407bbf70 100644 --- a/tests/net_load_tests/CMakeLists.txt +++ b/tests/net_load_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/net_load_tests/clt.cpp b/tests/net_load_tests/clt.cpp index a5e5b7c0c..a65e02cab 100644 --- a/tests/net_load_tests/clt.cpp +++ b/tests/net_load_tests/clt.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h index ce9d8b6fe..7f3c6dfe9 100644 --- a/tests/net_load_tests/net_load_tests.h +++ b/tests/net_load_tests/net_load_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp index a987aa4e2..d91abd71c 100644 --- a/tests/net_load_tests/srv.cpp +++ b/tests/net_load_tests/srv.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/CMakeLists.txt b/tests/performance_tests/CMakeLists.txt index 1a0677925..8cbd71444 100644 --- a/tests/performance_tests/CMakeLists.txt +++ b/tests/performance_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/performance_tests/check_tx_signature.h b/tests/performance_tests/check_tx_signature.h index afc2bdc45..ec570e69d 100644 --- a/tests/performance_tests/check_tx_signature.h +++ b/tests/performance_tests/check_tx_signature.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/cn_fast_hash.h b/tests/performance_tests/cn_fast_hash.h index d02b32676..2ddaef269 100644 --- a/tests/performance_tests/cn_fast_hash.h +++ b/tests/performance_tests/cn_fast_hash.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/cn_slow_hash.h b/tests/performance_tests/cn_slow_hash.h index bf9eb7501..b484afa41 100644 --- a/tests/performance_tests/cn_slow_hash.h +++ b/tests/performance_tests/cn_slow_hash.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/construct_tx.h b/tests/performance_tests/construct_tx.h index e01ee5cfa..99c7f1b18 100644 --- a/tests/performance_tests/construct_tx.h +++ b/tests/performance_tests/construct_tx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/derive_public_key.h b/tests/performance_tests/derive_public_key.h index 7c9315ebe..35c4ff062 100644 --- a/tests/performance_tests/derive_public_key.h +++ b/tests/performance_tests/derive_public_key.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/derive_secret_key.h b/tests/performance_tests/derive_secret_key.h index f97deb974..c478a2a99 100644 --- a/tests/performance_tests/derive_secret_key.h +++ b/tests/performance_tests/derive_secret_key.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/ge_frombytes_vartime.h b/tests/performance_tests/ge_frombytes_vartime.h index ea72fcd26..ef9625d6b 100644 --- a/tests/performance_tests/ge_frombytes_vartime.h +++ b/tests/performance_tests/ge_frombytes_vartime.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/generate_key_derivation.h b/tests/performance_tests/generate_key_derivation.h index 67a1de3a5..3f6238265 100644 --- a/tests/performance_tests/generate_key_derivation.h +++ b/tests/performance_tests/generate_key_derivation.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/generate_key_image.h b/tests/performance_tests/generate_key_image.h index 7d17c2151..5155e64a5 100644 --- a/tests/performance_tests/generate_key_image.h +++ b/tests/performance_tests/generate_key_image.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/generate_key_image_helper.h b/tests/performance_tests/generate_key_image_helper.h index bc92303eb..869e595fd 100644 --- a/tests/performance_tests/generate_key_image_helper.h +++ b/tests/performance_tests/generate_key_image_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/generate_keypair.h b/tests/performance_tests/generate_keypair.h index 8f0b069da..f97f4c213 100644 --- a/tests/performance_tests/generate_keypair.h +++ b/tests/performance_tests/generate_keypair.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/is_out_to_acc.h b/tests/performance_tests/is_out_to_acc.h index c31897628..2aaf00b36 100644 --- a/tests/performance_tests/is_out_to_acc.h +++ b/tests/performance_tests/is_out_to_acc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index 51061dd6f..d1b79d026 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -160,14 +160,14 @@ int main(int argc, char** argv) TEST_PERFORMANCE1(filter, test_cn_fast_hash, 32); TEST_PERFORMANCE1(filter, test_cn_fast_hash, 16384); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 3, false); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 5, false); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 10, false); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 100, false); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 3, true); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 5, true); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 10, true); - TEST_PERFORMANCE3(test_ringct_mlsag, 1, 100, true); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, false); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, false); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, false); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, false); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 3, true); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 5, true); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 10, true); + TEST_PERFORMANCE3(filter, test_ringct_mlsag, 1, 100, true); std::cout << "Tests finished. Elapsed time: " << timer.elapsed_ms() / 1000 << " sec" << std::endl; diff --git a/tests/performance_tests/multi_tx_test_base.h b/tests/performance_tests/multi_tx_test_base.h index 92d0d7fd7..ae9d6ea7a 100644 --- a/tests/performance_tests/multi_tx_test_base.h +++ b/tests/performance_tests/multi_tx_test_base.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h index 589c34caf..29d296571 100644 --- a/tests/performance_tests/performance_tests.h +++ b/tests/performance_tests/performance_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h index 6bf45ff83..e46a7bce4 100644 --- a/tests/performance_tests/performance_utils.h +++ b/tests/performance_tests/performance_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/sc_reduce32.h b/tests/performance_tests/sc_reduce32.h index bb3ad1694..fc5606414 100644 --- a/tests/performance_tests/sc_reduce32.h +++ b/tests/performance_tests/sc_reduce32.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/single_tx_test_base.h b/tests/performance_tests/single_tx_test_base.h index f284b4198..365d25444 100644 --- a/tests/performance_tests/single_tx_test_base.h +++ b/tests/performance_tests/single_tx_test_base.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/performance_tests/subaddress_expand.h b/tests/performance_tests/subaddress_expand.h index fea92d54b..2896faebc 100644 --- a/tests/performance_tests/subaddress_expand.h +++ b/tests/performance_tests/subaddress_expand.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/CMakeLists.txt b/tests/unit_tests/CMakeLists.txt index ba3acef0c..9c58536c9 100644 --- a/tests/unit_tests/CMakeLists.txt +++ b/tests/unit_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/tests/unit_tests/address_from_url.cpp b/tests/unit_tests/address_from_url.cpp index f4ecbc295..f174738fd 100644 --- a/tests/unit_tests/address_from_url.cpp +++ b/tests/unit_tests/address_from_url.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/apply_permutation.cpp b/tests/unit_tests/apply_permutation.cpp index a008b74ee..e2420eb45 100644 --- a/tests/unit_tests/apply_permutation.cpp +++ b/tests/unit_tests/apply_permutation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp index 5af514643..4a3ab0bc3 100644 --- a/tests/unit_tests/ban.cpp +++ b/tests/unit_tests/ban.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/base58.cpp b/tests/unit_tests/base58.cpp index 75a1930b5..e90fa416d 100644 --- a/tests/unit_tests/base58.cpp +++ b/tests/unit_tests/base58.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/block_queue.cpp b/tests/unit_tests/block_queue.cpp index f05d5487a..f7b7c63fd 100644 --- a/tests/unit_tests/block_queue.cpp +++ b/tests/unit_tests/block_queue.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/block_reward.cpp b/tests/unit_tests/block_reward.cpp index e7d6f2c38..ca863ded9 100644 --- a/tests/unit_tests/block_reward.cpp +++ b/tests/unit_tests/block_reward.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp index 4ccd9c1c8..3a62fba69 100644 --- a/tests/unit_tests/blockchain_db.cpp +++ b/tests/unit_tests/blockchain_db.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/bulletproofs.cpp b/tests/unit_tests/bulletproofs.cpp index 3d3dba5e6..00595a4c7 100644 --- a/tests/unit_tests/bulletproofs.cpp +++ b/tests/unit_tests/bulletproofs.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/canonical_amounts.cpp b/tests/unit_tests/canonical_amounts.cpp index 1af817d50..227a64a7f 100644 --- a/tests/unit_tests/canonical_amounts.cpp +++ b/tests/unit_tests/canonical_amounts.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/chacha.cpp b/tests/unit_tests/chacha.cpp index eadebf9d8..699890522 100644 --- a/tests/unit_tests/chacha.cpp +++ b/tests/unit_tests/chacha.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/checkpoints.cpp b/tests/unit_tests/checkpoints.cpp index f6015db2f..ec09c596b 100644 --- a/tests/unit_tests/checkpoints.cpp +++ b/tests/unit_tests/checkpoints.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/command_line.cpp b/tests/unit_tests/command_line.cpp index 408b728b9..327fceefe 100644 --- a/tests/unit_tests/command_line.cpp +++ b/tests/unit_tests/command_line.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/crypto.cpp b/tests/unit_tests/crypto.cpp index 3a8e787ec..4bed06173 100644 --- a/tests/unit_tests/crypto.cpp +++ b/tests/unit_tests/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/decompose_amount_into_digits.cpp b/tests/unit_tests/decompose_amount_into_digits.cpp index c832510c1..11c6189e5 100644 --- a/tests/unit_tests/decompose_amount_into_digits.cpp +++ b/tests/unit_tests/decompose_amount_into_digits.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/dns_resolver.cpp b/tests/unit_tests/dns_resolver.cpp index 8ac86146e..c3807315e 100644 --- a/tests/unit_tests/dns_resolver.cpp +++ b/tests/unit_tests/dns_resolver.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/epee_boosted_tcp_server.cpp b/tests/unit_tests/epee_boosted_tcp_server.cpp index 1dfdcb27f..41554f948 100644 --- a/tests/unit_tests/epee_boosted_tcp_server.cpp +++ b/tests/unit_tests/epee_boosted_tcp_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index c749c2531..38a8360d7 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index a13081491..3969f50f6 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/fee.cpp b/tests/unit_tests/fee.cpp index 3013a8c0c..c5589ab96 100644 --- a/tests/unit_tests/fee.cpp +++ b/tests/unit_tests/fee.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/get_xtype_from_string.cpp b/tests/unit_tests/get_xtype_from_string.cpp index 37156a497..54ba473a6 100644 --- a/tests/unit_tests/get_xtype_from_string.cpp +++ b/tests/unit_tests/get_xtype_from_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 0a472a421..a2038ff0c 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/hashchain.cpp b/tests/unit_tests/hashchain.cpp index e764f6afc..df87f5df2 100644 --- a/tests/unit_tests/hashchain.cpp +++ b/tests/unit_tests/hashchain.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/http.cpp b/tests/unit_tests/http.cpp index 0e8f9f747..372448764 100644 --- a/tests/unit_tests/http.cpp +++ b/tests/unit_tests/http.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp index 073ac20fd..85c6cbed5 100644 --- a/tests/unit_tests/main.cpp +++ b/tests/unit_tests/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/memwipe.cpp b/tests/unit_tests/memwipe.cpp index 93dcc19f6..dd98b8142 100644 --- a/tests/unit_tests/memwipe.cpp +++ b/tests/unit_tests/memwipe.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/mnemonics.cpp b/tests/unit_tests/mnemonics.cpp index 39ec394a1..8fa3192b9 100644 --- a/tests/unit_tests/mnemonics.cpp +++ b/tests/unit_tests/mnemonics.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/mul_div.cpp b/tests/unit_tests/mul_div.cpp index 27f3b63a7..8408d0da1 100644 --- a/tests/unit_tests/mul_div.cpp +++ b/tests/unit_tests/mul_div.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/multisig.cpp b/tests/unit_tests/multisig.cpp index 8b2c7e5f8..f70bb91a3 100644 --- a/tests/unit_tests/multisig.cpp +++ b/tests/unit_tests/multisig.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/output_selection.cpp b/tests/unit_tests/output_selection.cpp index ccca0b799..fecd547f7 100644 --- a/tests/unit_tests/output_selection.cpp +++ b/tests/unit_tests/output_selection.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/parse_amount.cpp b/tests/unit_tests/parse_amount.cpp index 006051a88..eb8c925b1 100644 --- a/tests/unit_tests/parse_amount.cpp +++ b/tests/unit_tests/parse_amount.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp index 6956179c1..d90a14542 100644 --- a/tests/unit_tests/ringct.cpp +++ b/tests/unit_tests/ringct.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // @@ -177,7 +177,7 @@ TEST(ringct, range_proofs) ASSERT_TRUE(verRct(s)); //decode received amount - ASSERT_TRUE(decodeRct(s, amount_keys[1], 1, mask)); + decodeRct(s, amount_keys[1], 1, mask); // Ring CT with failing MG sig part should not verify! // Since sum of inputs != outputs @@ -194,7 +194,7 @@ TEST(ringct, range_proofs) ASSERT_FALSE(verRct(s)); //decode received amount - ASSERT_TRUE(decodeRct(s, amount_keys[1], 1, mask)); + decodeRct(s, amount_keys[1], 1, mask); } TEST(ringct, range_proofs_with_fee) @@ -241,7 +241,7 @@ TEST(ringct, range_proofs_with_fee) ASSERT_TRUE(verRct(s)); //decode received amount - ASSERT_TRUE(decodeRct(s, amount_keys[1], 1, mask)); + decodeRct(s, amount_keys[1], 1, mask); // Ring CT with failing MG sig part should not verify! // Since sum of inputs != outputs @@ -258,7 +258,7 @@ TEST(ringct, range_proofs_with_fee) ASSERT_FALSE(verRct(s)); //decode received amount - ASSERT_TRUE(decodeRct(s, amount_keys[1], 1, mask)); + decodeRct(s, amount_keys[1], 1, mask); } TEST(ringct, simple) @@ -316,7 +316,7 @@ TEST(ringct, simple) ASSERT_TRUE(verRctSimple(s)); //decode received amount corresponding to output pubkey index 1 - ASSERT_TRUE(decodeRctSimple(s, amount_keys[1], 1, mask)); + decodeRctSimple(s, amount_keys[1], 1, mask); } static rct::rctSig make_sample_rct_sig(int n_inputs, const uint64_t input_amounts[], int n_outputs, const uint64_t output_amounts[], bool last_is_fee) diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 8a75ac435..aa116da04 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/sha256.cpp b/tests/unit_tests/sha256.cpp index 0d657a1a9..0d1788f3e 100644 --- a/tests/unit_tests/sha256.cpp +++ b/tests/unit_tests/sha256.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/slow_memmem.cpp b/tests/unit_tests/slow_memmem.cpp index 6e1dcb85f..1c67f5b58 100644 --- a/tests/unit_tests/slow_memmem.cpp +++ b/tests/unit_tests/slow_memmem.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/subaddress.cpp b/tests/unit_tests/subaddress.cpp index ca950b25d..8ff4c5f0d 100644 --- a/tests/unit_tests/subaddress.cpp +++ b/tests/unit_tests/subaddress.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/test_peerlist.cpp b/tests/unit_tests/test_peerlist.cpp index 849020d25..c6572c6c2 100644 --- a/tests/unit_tests/test_peerlist.cpp +++ b/tests/unit_tests/test_peerlist.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/test_protocol_pack.cpp b/tests/unit_tests/test_protocol_pack.cpp index 83352d503..d385bbc42 100644 --- a/tests/unit_tests/test_protocol_pack.cpp +++ b/tests/unit_tests/test_protocol_pack.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/test_tx_utils.cpp b/tests/unit_tests/test_tx_utils.cpp index 4ce62e2f5..8a9f983e6 100644 --- a/tests/unit_tests/test_tx_utils.cpp +++ b/tests/unit_tests/test_tx_utils.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/unbound.cpp b/tests/unit_tests/unbound.cpp index 666f68127..3676e88f0 100644 --- a/tests/unit_tests/unbound.cpp +++ b/tests/unit_tests/unbound.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/unit_tests_utils.h b/tests/unit_tests/unit_tests_utils.h index a07eaf02b..49301f5a8 100644 --- a/tests/unit_tests/unit_tests_utils.h +++ b/tests/unit_tests/unit_tests_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/uri.cpp b/tests/unit_tests/uri.cpp index 0f727982b..1026cc85b 100644 --- a/tests/unit_tests/uri.cpp +++ b/tests/unit_tests/uri.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016, The Monero Project +// Copyright (c) 2016-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/varint.cpp b/tests/unit_tests/varint.cpp index 577ad4d26..db675c888 100644 --- a/tests/unit_tests/varint.cpp +++ b/tests/unit_tests/varint.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017, The Monero Project +// Copyright (c) 2014-2018, The Monero Project // // All rights reserved. // diff --git a/tests/unit_tests/vercmp.cpp b/tests/unit_tests/vercmp.cpp index 8f359585d..43045979e 100644 --- a/tests/unit_tests/vercmp.cpp +++ b/tests/unit_tests/vercmp.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt index a069daea9..db60190b1 100644 --- a/translations/CMakeLists.txt +++ b/translations/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2017, The Monero Project +# Copyright (c) 2017-2018, The Monero Project # # All rights reserved. # diff --git a/translations/generate_translations_header.c b/translations/generate_translations_header.c index 69671913e..008a1b75e 100644 --- a/translations/generate_translations_header.c +++ b/translations/generate_translations_header.c @@ -1,5 +1,5 @@ // Copyright (c) 2013, Sergey Lyubka -// Copyright (c) 2017, The Monero Project +// Copyright (c) 2017-2018, The Monero Project // All rights reserved. // Released under the MIT license. diff --git a/translations/monero.ts b/translations/monero.ts index 27f5e1c52..5ca882bb3 100644 --- a/translations/monero.ts +++ b/translations/monero.ts @@ -414,7 +414,7 @@ <name>cryptonote::rpc_args</name> <message> <location filename="../src/rpc/rpc_args.cpp" line="38"/> - <source>Specify ip to bind rpc server</source> + <source>Specify IP to bind RPC server</source> <translation type="unfinished"></translation> </message> <message> @@ -527,7 +527,7 @@ </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="710"/> - <source>sweep_below <amount_threshold> [mixin] address [payment_id] - Send all unlocked outputs below the threshold to an address</source> + <source>sweep_below <amount_threshold> [mixin] address [<payment_id>] - Send all unlocked outputs below the threshold to an address</source> <translation type="unfinished"></translation> </message> <message> @@ -851,7 +851,7 @@ This transaction will unlock on block %llu, in approximately %s days (assuming 2 </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="2921"/> - <source>missing amount threshold</source> + <source>missing threshold amount</source> <translation type="unfinished"></translation> </message> <message> @@ -896,7 +896,7 @@ This transaction will unlock on block %llu, in approximately %s days (assuming 2 </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="3137"/> - <source>daemon is busy. Please try later</source> + <source>daemon is busy. Please try again later</source> <translation type="unfinished"></translation> </message> <message> @@ -931,12 +931,12 @@ This transaction will unlock on block %llu, in approximately %s days (assuming 2 </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="525"/> - <source>priority must be 0, 1, 2, 3,or 4</source> + <source>priority must be 0, 1, 2, 3, or 4</source> <translation type="unfinished"></translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="540"/> - <source>priority must be 0, 1, 2 3,or 4</source> + <source>priority must be 0, 1, 2, 3, or 4</source> <translation type="unfinished"></translation> </message> <message> @@ -961,7 +961,7 @@ This transaction will unlock on block %llu, in approximately %s days (assuming 2 </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="709"/> - <source>sweep_all [mixin] address [payment_id] - Send all unlocked balance to an address</source> + <source>sweep_all [mixin] address [<payment_id>] - Send all unlocked balance to an address</source> <translation type="unfinished"></translation> </message> <message> @@ -1124,7 +1124,7 @@ This transaction will unlock on block %llu, in approximately %s days (assuming 2 </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1887"/> - <source>expected at least one payment_id</source> + <source>expected at least one payment ID</source> <translation type="unfinished"></translation> </message> <message> @@ -1340,7 +1340,7 @@ Warning: Some input keys being spent are from </source> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="706"/> - <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> + <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> <translation type="unfinished"></translation> </message> <message> @@ -1612,7 +1612,7 @@ Warning: Some input keys being spent are from </source> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1306"/> <location filename="../src/simplewallet/simplewallet.cpp" line="1311"/> - <source>invalid language choice passed. Please try again. + <source>invalid language choice entered. Please try again. </source> <translation type="unfinished"></translation> </message> @@ -2493,7 +2493,7 @@ Outputs per *: </source> </message> <message> <location filename="../src/wallet/wallet2.cpp" line="460"/> - <source>Enter new wallet password</source> + <source>Enter new password for the wallet</source> <translation type="unfinished"></translation> </message> <message> @@ -2651,13 +2651,13 @@ Outputs per *: </source> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1789"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1814"/> - <source>Storing wallet...</source> + <source>Saving wallet...</source> <translation type="unfinished"></translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1791"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1816"/> - <source>Stored ok</source> + <source>Saved ok</source> <translation type="unfinished"></translation> </message> <message> @@ -2672,22 +2672,22 @@ Outputs per *: </source> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1805"/> - <source>Failed to initialize wallet rpc server</source> + <source>Failed to initialize wallet RPC server</source> <translation type="unfinished"></translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1809"/> - <source>Starting wallet rpc server</source> + <source>Starting wallet RPC server</source> <translation type="unfinished"></translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1811"/> - <source>Stopped wallet rpc server</source> + <source>Stopped wallet RPC server</source> <translation type="unfinished"></translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1820"/> - <source>Failed to store wallet: </source> + <source>Failed to save wallet: </source> <translation type="unfinished"></translation> </message> </context> diff --git a/translations/monero_fr.ts b/translations/monero_fr.ts index 5cef15a92..c4e9a0f36 100644 --- a/translations/monero_fr.ts +++ b/translations/monero_fr.ts @@ -414,7 +414,7 @@ <name>cryptonote::rpc_args</name> <message> <location filename="../src/rpc/rpc_args.cpp" line="38"/> - <source>Specify ip to bind rpc server</source> + <source>Specify IP to bind RPC server</source> <translation>Spécifier l'IP à laquelle lier le serveur RPC</translation> </message> <message> @@ -527,8 +527,8 @@ </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="710"/> - <source>sweep_below <amount_threshold> [mixin] address [payment_id] - Send all unlocked outputs below the threshold to an address</source> - <translation>sweep_below <montant_seuil> [mixin] adresse [ID_paiement] - Envoyer toutes les sorties débloquées sous le seuil vers une adresse</translation> + <source>sweep_below <amount_threshold> [mixin] address [<payment_id>] - Send all unlocked outputs below the threshold to an address</source> + <translation>sweep_below <montant_seuil> [mixin] adresse [<ID_paiement>] - Envoyer toutes les sorties débloquées sous le seuil vers une adresse</translation> </message> <message> <source>Available options: seed language - set wallet seed language; always-confirm-transfers <1|0> - whether to confirm unsplit txes; print-ring-members <1|0> - whether to print detailed information about ring members during confirmation; store-tx-info <1|0> - whether to store outgoing tx info (destination address, payment ID, tx secret key) for future reference; default-mixin <n> - set default mixin (default is 4); auto-refresh <1|0> - whether to automatically sync new blocks from the daemon; refresh-type <full|optimize-coinbase|no-coinbase|default> - set wallet refresh behaviour; priority [0|1|2|3|4] - default/unimportant/normal/elevated/priority fee; confirm-missing-payment-id <1|0>; ask-password <1|0>; unit <monero|millinero|micronero|nanonero|piconero> - set default monero (sub-)unit; min-outputs-count [n] - try to keep at least that many outputs of value at least min-outputs-value; min-outputs-value [n] - try to keep at least min-outputs-count outputs of at least that value - merge-destinations <1|0> - whether to merge multiple payments to the same destination address</source> @@ -872,7 +872,7 @@ Cette transaction sera déverrouillée au bloc %llu, dans approximativement %s j </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="2921"/> - <source>missing amount threshold</source> + <source>missing threshold amount</source> <translation>montant seuil manquant</translation> </message> <message> @@ -917,7 +917,7 @@ Cette transaction sera déverrouillée au bloc %llu, dans approximativement %s j </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="3137"/> - <source>daemon is busy. Please try later</source> + <source>daemon is busy. Please try again later</source> <translation>le démon est occupé. Veuillez réessayer plus tard</translation> </message> <message> @@ -952,12 +952,12 @@ Cette transaction sera déverrouillée au bloc %llu, dans approximativement %s j </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="525"/> - <source>priority must be 0, 1, 2, 3,or 4</source> + <source>priority must be 0, 1, 2, 3, or 4</source> <translation>la priorité doit être 0, 1, 2, 3 ou 4</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="540"/> - <source>priority must be 0, 1, 2 3,or 4</source> + <source>priority must be 0, 1, 2, 3, or 4</source> <translation>la priorité doit être 0, 1, 2, 3 ou 4</translation> </message> <message> @@ -982,8 +982,8 @@ Cette transaction sera déverrouillée au bloc %llu, dans approximativement %s j </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="709"/> - <source>sweep_all [mixin] address [payment_id] - Send all unlocked balance to an address</source> - <translation>sweep_all [mixin] adresse [ID_paiement] - Envoyer tout le solde débloqué à une adresse</translation> + <source>sweep_all [mixin] address [<payment_id>] - Send all unlocked balance to an address</source> + <translation>sweep_all [mixin] adresse [<ID_paiement>] - Envoyer tout le solde débloqué à une adresse</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="711"/> @@ -1149,7 +1149,7 @@ Cette transaction sera déverrouillée au bloc %llu, dans approximativement %s j </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1887"/> - <source>expected at least one payment_id</source> + <source>expected at least one payment ID</source> <translation>au moins un ID de paiement attendu</translation> </message> <message> @@ -1371,7 +1371,7 @@ Attention : Certaines clés d'entrées étant dépensées sont issues de < </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="706"/> - <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> + <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> <translation>transfer [<priorité>] [<mixin>] <adresse> <montant> [<ID_paiement>] - Transférer <montant> à <adresse>. <priorité> est la priorité de la transaction. Plus la priorité est élevée, plues les frais de transaction seront élévés. Les valeurs de priorité valies sont dans l'ordre (de la plus basse à la plus élevée) : unimportant, normal, elevated, priority. Si ce paramètre est omis, la valeur par défaut (voir la commande "set priority") est utilisée. <mixin> est le nombre d'entrées supplémentaires à inclure pour l'intraçabilité. De multiples paiements peuvent être effectués d'un coup en ajoutant <adresse_2> <montant_2> et cetera (avant l'ID de paiement, s'il est inclus)</translation> </message> <message> @@ -1643,7 +1643,7 @@ Attention : Certaines clés d'entrées étant dépensées sont issues de < <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1306"/> <location filename="../src/simplewallet/simplewallet.cpp" line="1311"/> - <source>invalid language choice passed. Please try again. + <source>invalid language choice entered. Please try again. </source> <translation>choix de langue passé invalide. Veuillez réessayer. </translation> @@ -2543,7 +2543,7 @@ Sorties par * : </translation> </message> <message> <location filename="../src/wallet/wallet2.cpp" line="460"/> - <source>Enter new wallet password</source> + <source>Enter new password for the wallet</source> <translation>Entrez le mot de passe du portefeuille</translation> </message> <message> @@ -2701,14 +2701,14 @@ Sorties par * : </translation> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1789"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1814"/> - <source>Storing wallet...</source> + <source>Saving wallet...</source> <translation>Sauvegarde du portefeuille...</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1791"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1816"/> - <source>Stored ok</source> - <translation>Sauvegarde OK</translation> + <source>Saved ok</source> + <translation>Sauvegarde réussie</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1794"/> @@ -2722,22 +2722,22 @@ Sorties par * : </translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1805"/> - <source>Failed to initialize wallet rpc server</source> + <source>Failed to initialize wallet RPC server</source> <translation>Échec de l'initialisation du serveur RPC du portefeuille</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1809"/> - <source>Starting wallet rpc server</source> + <source>Starting wallet RPC server</source> <translation>Démarrage du serveur RPC du portefeuille</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1811"/> - <source>Stopped wallet rpc server</source> + <source>Stopped wallet RPC server</source> <translation>Arrêt du serveur RPC du portefeuille</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1820"/> - <source>Failed to store wallet: </source> + <source>Failed to save wallet: </source> <translation>Échec de la sauvegarde du portefeuille : </translation> </message> </context> diff --git a/translations/monero_it.ts b/translations/monero_it.ts index 3674b2a32..d0cc40304 100644 --- a/translations/monero_it.ts +++ b/translations/monero_it.ts @@ -414,8 +414,8 @@ <name>cryptonote::rpc_args</name> <message> <location filename="../src/rpc/rpc_args.cpp" line="38"/> - <source>Specify ip to bind rpc server</source> - <translation>Specificare ip da associare al server rpc</translation> + <source>Specify IP to bind RPC server</source> + <translation>Specificare IP da associare al server RPC</translation> </message> <message> <location filename="../src/rpc/rpc_args.cpp" line="39"/> @@ -527,8 +527,8 @@ </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="710"/> - <source>sweep_below <amount_threshold> [mixin] address [payment_id] - Send all unlocked outputs below the threshold to an address</source> - <translation>sweep_below <amount_threshold> [mixin] address [payment_id] - Invia tutti gli outputs sbloccati sotto la soglia specificata a un indirizzo</translation> + <source>sweep_below <amount_threshold> [mixin] address [<payment_id>] - Send all unlocked outputs below the threshold to an address</source> + <translation>sweep_below <amount_threshold> [mixin] address [<payment_id>] - Invia tutti gli outputs sbloccati sotto la soglia specificata a un indirizzo</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="727"/> @@ -887,7 +887,7 @@ Questa transazione verrà sbloccata al blocco %llu, in approssimativamente %s gi </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="3137"/> - <source>daemon is busy. Please try later</source> + <source>daemon is busy. Please try again later</source> <translation>il daemon è occupato. Prova più tardi</translation> </message> <message> @@ -922,13 +922,13 @@ Questa transazione verrà sbloccata al blocco %llu, in approssimativamente %s gi </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="525"/> - <source>priority must be 0, 1, 2, 3,or 4</source> - <translation>la priorità deve essere 0, 1, 2, 3,or 4</translation> + <source>priority must be 0, 1, 2, 3, or 4</source> + <translation>la priorità deve essere 0, 1, 2, 3, or 4</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="540"/> - <source>priority must be 0, 1, 2 3,or 4</source> - <translation>la priorità deve essere 0, 1, 2 3, or 4</translation> + <source>priority must be 0, 1, 2, 3, or 4</source> + <translation>la priorità deve essere 0, 1, 2, 3, or 4</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="623"/> @@ -952,8 +952,8 @@ Questa transazione verrà sbloccata al blocco %llu, in approssimativamente %s gi </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="709"/> - <source>sweep_all [mixin] address [payment_id] - Send all unlocked balance to an address</source> - <translation>sweep_all [mixin] address [payment_id] - Manda tutto il bilancio sbloccato ad un indirizzo</translation> + <source>sweep_all [mixin] address [<payment_id>] - Send all unlocked balance to an address</source> + <translation>sweep_all [mixin] address [<payment_id>] - Manda tutto il bilancio sbloccato ad un indirizzo</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="711"/> @@ -1115,8 +1115,8 @@ Questa transazione verrà sbloccata al blocco %llu, in approssimativamente %s gi </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1887"/> - <source>expected at least one payment_id</source> - <translation>deve esserci almeno un payment_id</translation> + <source>expected at least one payment ID</source> + <translation>deve esserci almeno un payment ID</translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1896"/> @@ -1336,7 +1336,7 @@ Avviso: alcune chiavi di input spese vengono da </translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="706"/> - <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the fee of the transaction. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> + <source>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> is the priority of the transaction. The higher the priority, the higher the transaction fee. Valid values in priority order (from lowest to highest) are: unimportant, normal, elevated, priority. If omitted, the default value (see the command "set priority") is used. <mixin_count> is the number of extra inputs to include for untraceability. Multiple payments can be made at once by adding <address_2> <amount_2> etcetera (before the payment ID, if it's included)</source> <translation>transfer [<priority>] [<mixin_count>] <address> <amount> [<payment_id>] - Transfer <amount> to <address>. <priority> è la priorità della transazione. Maggiore è la priorità, maggiori saranno le tasse per la transazione. Valori validi in ordini di priorità (dal più basso al più alto) sono:unimportant, normal, elevated, priority. se omesso, verrà usato il valore standard (vedi il comando "set priority"). <mixin_count> è il numero di inputs extra da inludere per intracciabilità. Puoi eseguire pagamenti multipli in una volta aggiungendo <address_2> <amount_2> etcetera (prima dell' ID pagamento, se incluso)</translation> </message> <message> @@ -1608,7 +1608,7 @@ Avviso: alcune chiavi di input spese vengono da </translation> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="1306"/> <location filename="../src/simplewallet/simplewallet.cpp" line="1311"/> - <source>invalid language choice passed. Please try again. + <source>invalid language choice entered. Please try again. </source> <translation>linguaggio selezionato scorretto. Prova di nuovo.</translation> </message> @@ -1755,7 +1755,7 @@ di nuovo il tuo portafoglio (le chiavi del tuo portafoglio NON sono a rischio in </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="2921"/> - <source>missing amount threshold</source> + <source>missing threshold amount</source> <translation>manca la soglia massima dell'ammontare</translation> </message> <message> @@ -2512,7 +2512,7 @@ Outputs per *: </source> </message> <message> <location filename="../src/wallet/wallet2.cpp" line="460"/> - <source>Enter new wallet password</source> + <source>Enter new password for the wallet</source> <translation>Inserisci una nuova password per il portafoglio</translation> </message> <message> @@ -2670,13 +2670,13 @@ Outputs per *: </source> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1789"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1814"/> - <source>Storing wallet...</source> + <source>Saving wallet...</source> <translation>Sto salvando il portafoglio...</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1791"/> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1816"/> - <source>Stored ok</source> + <source>Saved ok</source> <translation>Salvato con successo</translation> </message> <message> @@ -2691,22 +2691,22 @@ Outputs per *: </source> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1805"/> - <source>Failed to initialize wallet rpc server</source> - <translation>Inizializzazione server rpc portafoglio fallita</translation> + <source>Failed to initialize wallet RPC server</source> + <translation>Inizializzazione server RPC portafoglio fallita</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1809"/> - <source>Starting wallet rpc server</source> + <source>Starting wallet RPC server</source> <translation>Server RPC portafoglio in avvio</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1811"/> - <source>Stopped wallet rpc server</source> + <source>Stopped wallet RPC server</source> <translation>Server RPC portafoglio arrestato</translation> </message> <message> <location filename="../src/wallet/wallet_rpc_server.cpp" line="1820"/> - <source>Failed to store wallet: </source> + <source>Failed to save wallet: </source> <translation>Impossibile salvare portafoglio: </translation> </message> </context> diff --git a/translations/monero_sv.ts b/translations/monero_sv.ts index 0090857c0..7decd2f5a 100644 --- a/translations/monero_sv.ts +++ b/translations/monero_sv.ts @@ -2397,7 +2397,7 @@ Utgångar per *: </translation> </message> <message> <location filename="../src/simplewallet/simplewallet.cpp" line="122"/> - <source>Create non-deterministic view and spend keys</source> + <source>Generate non-deterministic view and spend keys</source> <translation>Skapa non-deterministic visnings- och spendernyckel</translation> </message> <message> @@ -2612,7 +2612,7 @@ Utgångar per *: </translation> </message> <message> <location filename="../src/wallet/wallet2.cpp" line="356"/> - <source>Cannot create deprecated wallets from JSON</source> + <source>Cannot generate deprecated wallets from JSON</source> <translation>Det går inte att skapa inaktuella plånböcker från JSON</translation> </message> <message> diff --git a/utils/build_scripts/windows.bat b/utils/build_scripts/windows.bat index c78086e6c..717324fab 100644 --- a/utils/build_scripts/windows.bat +++ b/utils/build_scripts/windows.bat @@ -1,4 +1,4 @@ -:: Copyright (c) 2014-2017, The Monero Project +:: Copyright (c) 2014-2018, The Monero Project :: :: All rights reserved. :: diff --git a/utils/munin_plugins/alt_blocks_count b/utils/munin_plugins/alt_blocks_count index bcdb01936..5f9e43671 100644 --- a/utils/munin_plugins/alt_blocks_count +++ b/utils/munin_plugins/alt_blocks_count @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/difficulty b/utils/munin_plugins/difficulty index 0c020ee8d..f9a72b0ca 100644 --- a/utils/munin_plugins/difficulty +++ b/utils/munin_plugins/difficulty @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/grey_peerlist_size b/utils/munin_plugins/grey_peerlist_size index 579918b03..52f5b99cb 100644 --- a/utils/munin_plugins/grey_peerlist_size +++ b/utils/munin_plugins/grey_peerlist_size @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/height b/utils/munin_plugins/height index e092ef6e1..470798b8f 100644 --- a/utils/munin_plugins/height +++ b/utils/munin_plugins/height @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/incoming_connections_count b/utils/munin_plugins/incoming_connections_count index 709be835e..3fea27fa2 100644 --- a/utils/munin_plugins/incoming_connections_count +++ b/utils/munin_plugins/incoming_connections_count @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/outgoing_connections_count b/utils/munin_plugins/outgoing_connections_count index 7055d7f84..49d8f4fc4 100644 --- a/utils/munin_plugins/outgoing_connections_count +++ b/utils/munin_plugins/outgoing_connections_count @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/tx_count b/utils/munin_plugins/tx_count index 21f7bc1c7..d63c8a9d1 100644 --- a/utils/munin_plugins/tx_count +++ b/utils/munin_plugins/tx_count @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/tx_pool_size b/utils/munin_plugins/tx_pool_size index 56a0a78a9..f01685a41 100644 --- a/utils/munin_plugins/tx_pool_size +++ b/utils/munin_plugins/tx_pool_size @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # diff --git a/utils/munin_plugins/white_peerlist_size b/utils/munin_plugins/white_peerlist_size index 5120ec011..bd7d7a3c5 100644 --- a/utils/munin_plugins/white_peerlist_size +++ b/utils/munin_plugins/white_peerlist_size @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2014-2017, The Monero Project +# Copyright (c) 2014-2018, The Monero Project # # All rights reserved. # |