diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | README.md | 38 | ||||
-rw-r--r-- | cmake/FindReadline.cmake | 12 | ||||
-rw-r--r-- | contrib/epee/include/storages/levin_abstract_invoke2.h | 26 | ||||
-rw-r--r-- | contrib/epee/include/storages/portable_storage_val_converters.h | 6 | ||||
-rw-r--r-- | contrib/epee/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | external/miniupnpc/CMakeLists.txt | 7 | ||||
-rw-r--r-- | external/unbound/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/common/apply_permutation.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 2 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 2 | ||||
-rw-r--r-- | src/daemon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/daemon/main.cpp | 2 | ||||
-rw-r--r-- | src/gen_multisig/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/rpc/zmq_server.cpp | 2 | ||||
-rw-r--r-- | src/simplewallet/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 9 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet_rpc_server_commands_defs.h | 2 |
19 files changed, 87 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b27c10bd..a0508adfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -868,5 +868,9 @@ option(INSTALL_VENDORED_LIBUNBOUND "Install libunbound binary built from source CHECK_C_COMPILER_FLAG(-std=c11 HAVE_C11) +include(CheckLibraryExists) +include(CheckFunctionExists) + check_library_exists(c memset_s "string.h" HAVE_MEMSET_S) check_library_exists(c explicit_bzero "strings.h" HAVE_EXPLICIT_BZERO) +check_function_exists(strptime HAVE_STRPTIME) @@ -163,25 +163,25 @@ sources are also used for statically-linked builds because distribution packages often include only shared library binaries (`.so`) but not static library archives (`.a`). -| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Optional | Purpose | -| -------------- | ------------- | ---------| ------------------ | -------------- | -------- | -------------- | -| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | NO | | -| CMake | 3.0.0 | NO | `cmake` | `cmake` | NO | | -| pkg-config | any | NO | `pkg-config` | `base-devel` | NO | | -| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | NO | C++ libraries | -| OpenSSL | basically any | NO | `libssl-dev` | `openssl` | NO | sha256 sum | -| libzmq | 3.0.0 | NO | `libzmq3-dev` | `zeromq` | NO | ZeroMQ library | -| libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | NO | DNS resolver | -| libsodium | ? | NO | `libsodium-dev` | ? | NO | libsodium | -| libminiupnpc | 2.0 | YES | `libminiupnpc-dev` | `miniupnpc` | YES | NAT punching | -| libunwind | any | NO | `libunwind8-dev` | `libunwind` | YES | Stack traces | -| liblzma | any | NO | `liblzma-dev` | `xz` | YES | For libunwind | -| libreadline | 6.3.0 | NO | `libreadline6-dev` | `readline` | YES | Input editing | -| ldns | 1.6.17 | NO | `libldns-dev` | `ldns` | YES | SSL toolkit | -| expat | 1.1 | NO | `libexpat1-dev` | `expat` | YES | XML parsing | -| GTest | 1.5 | YES | `libgtest-dev`^ | `gtest` | YES | Test suite | -| Doxygen | any | NO | `doxygen` | `doxygen` | YES | Documentation | -| Graphviz | any | NO | `graphviz` | `graphviz` | YES | Documentation | +| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Fedora | Optional | Purpose | +| ------------ | ------------- | -------- | ------------------ | ------------ | ----------------- | -------- | -------------- | +| GCC | 4.7.3 | NO | `build-essential` | `base-devel` | `gcc` | NO | | +| CMake | 3.0.0 | NO | `cmake` | `cmake` | `cmake` | NO | | +| pkg-config | any | NO | `pkg-config` | `base-devel` | `pkgconf` | NO | | +| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | `boost-devel` | NO | C++ libraries | +| OpenSSL | basically any | NO | `libssl-dev` | `openssl` | `openssl-devel` | NO | sha256 sum | +| libzmq | 3.0.0 | NO | `libzmq3-dev` | `zeromq` | `cppzmq-devel` | NO | ZeroMQ library | +| libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | `unbound-devel` | NO | DNS resolver | +| libsodium | ? | NO | `libsodium-dev` | ? | `libsodium-devel` | NO | libsodium | +| libminiupnpc | 2.0 | YES | `libminiupnpc-dev` | `miniupnpc` | `miniupnpc-devel` | YES | NAT punching | +| libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | YES | Stack traces | +| liblzma | any | NO | `liblzma-dev` | `xz` | `xz-devel` | YES | For libunwind | +| libreadline | 6.3.0 | NO | `libreadline6-dev` | `readline` | `readline-devel` | YES | Input editing | +| ldns | 1.6.17 | NO | `libldns-dev` | `ldns` | `ldns-devel` | YES | SSL toolkit | +| expat | 1.1 | NO | `libexpat1-dev` | `expat` | `expat-devel` | YES | XML parsing | +| GTest | 1.5 | YES | `libgtest-dev`^ | `gtest` | `gtest-devel` | YES | Test suite | +| Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | YES | Documentation | +| Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | YES | Documentation | [^] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake index 7a11a270a..87f8ccace 100644 --- a/cmake/FindReadline.cmake +++ b/cmake/FindReadline.cmake @@ -15,8 +15,11 @@ # # READLINE_FOUND System has readline, include and lib dirs found # GNU_READLINE_FOUND Version of readline found is GNU readline, not libedit! +# LIBEDIT_FOUND Version of readline found is libedit, not GNU readline! # Readline_INCLUDE_DIR The readline include directories. # Readline_LIBRARY The readline library. +# GNU_READLINE_LIBRARY The GNU readline library or empty string. +# LIBEDIT_LIBRARY The libedit library or empty string. find_path(Readline_ROOT_DIR NAMES include/readline/readline.h @@ -63,7 +66,6 @@ check_function_exists(rl_copy_text HAVE_COPY_TEXT) check_function_exists(rl_filename_completion_function HAVE_COMPLETION_FUNCTION) if(NOT HAVE_COMPLETION_FUNCTION) - unset(READLINE_FOUND) set(CMAKE_REQUIRED_LIBRARIES ${Readline_LIBRARY} ${Termcap_LIBRARY}) check_function_exists(rl_copy_text HAVE_COPY_TEXT_TC) check_function_exists(rl_filename_completion_function HAVE_COMPLETION_FUNCTION_TC) @@ -74,8 +76,14 @@ if(NOT HAVE_COMPLETION_FUNCTION) endif(HAVE_COMPLETION_FUNCTION) endif(NOT HAVE_COMPLETION_FUNCTION) +set(LIBEDIT_LIBRARY "") +set(GNU_READLINE_LIBRARY "") + if(HAVE_COMPLETION_FUNCTION AND HAVE_COPY_TEXT) set(GNU_READLINE_FOUND TRUE) - set(READLINE_FOUND TRUE) + set(GNU_READLINE_LIBRARY ${Readline_LIBRARY}) +elseif(READLINE_FOUND AND NOT HAVE_COPY_TEXT) + set(LIBEDIT_FOUND TRUE) + set(LIBEDIT_LIBRARY ${Readline_LIBRARY}) endif(HAVE_COMPLETION_FUNCTION AND HAVE_COPY_TEXT) diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h index 8ced9d689..b4f7abca8 100644 --- a/contrib/epee/include/storages/levin_abstract_invoke2.h +++ b/contrib/epee/include/storages/levin_abstract_invoke2.h @@ -60,8 +60,7 @@ namespace epee LOG_ERROR("Failed to load_from_binary on command " << command); return false; } - result_struct.load(stg_ret); - return true; + return result_struct.load(stg_ret); } template<class t_arg, class t_transport> @@ -105,9 +104,7 @@ namespace epee LOG_ERROR("Failed to load_from_binary on command " << command); return false; } - result_struct.load(stg_ret); - - return true; + return result_struct.load(stg_ret); } template<class t_result, class t_arg, class callback_t, class t_transport> @@ -133,7 +130,12 @@ namespace epee cb(LEVIN_ERROR_FORMAT, result_struct, context); return false; } - result_struct.load(stg_ret); + if (!result_struct.load(stg_ret)) + { + LOG_ERROR("Failed to load result struct on command " << command); + cb(LEVIN_ERROR_FORMAT, result_struct, context); + return false; + } cb(code, result_struct, context); return true; }, inv_timeout); @@ -176,7 +178,11 @@ namespace epee boost::value_initialized<t_in_type> in_struct; boost::value_initialized<t_out_type> out_struct; - static_cast<t_in_type&>(in_struct).load(strg); + if (!static_cast<t_in_type&>(in_struct).load(strg)) + { + LOG_ERROR("Failed to load in_struct in command " << command); + return -1; + } int res = cb(command, static_cast<t_in_type&>(in_struct), static_cast<t_out_type&>(out_struct), context); serialization::portable_storage strg_out; static_cast<t_out_type&>(out_struct).store(strg_out); @@ -200,7 +206,11 @@ namespace epee return -1; } boost::value_initialized<t_in_type> in_struct; - static_cast<t_in_type&>(in_struct).load(strg); + if (!static_cast<t_in_type&>(in_struct).load(strg)) + { + LOG_ERROR("Failed to load in_struct in notify " << command); + return -1; + } return cb(command, in_struct, context); } diff --git a/contrib/epee/include/storages/portable_storage_val_converters.h b/contrib/epee/include/storages/portable_storage_val_converters.h index 5d9664a65..36bb28627 100644 --- a/contrib/epee/include/storages/portable_storage_val_converters.h +++ b/contrib/epee/include/storages/portable_storage_val_converters.h @@ -150,8 +150,14 @@ POP_WARNINGS else if (boost::regex_match (from, boost::regex("\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\dZ"))) { // Convert to unix timestamp +#ifdef HAVE_STRPTIME struct tm tm; if (strptime(from.c_str(), "%Y-%m-%dT%H:%M:%S", &tm)) +#else + std::tm tm = {}; + std::istringstream ss(from); + if (ss >> std::get_time(&tm, "%Y-%m-%dT%H:%M:%S")) +#endif to = std::mktime(&tm); } else ASSERT_AND_THROW_WRONG_CONVERSION(); diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index 9d104ceeb..538c7ce91 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -64,5 +64,5 @@ if (USE_READLINE AND GNU_READLINE_FOUND) PUBLIC easylogging PRIVATE - ${Readline_LIBRARY}) + ${GNU_READLINE_LIBRARY}) endif() diff --git a/external/miniupnpc/CMakeLists.txt b/external/miniupnpc/CMakeLists.txt index bc9685699..2df8d474b 100644 --- a/external/miniupnpc/CMakeLists.txt +++ b/external/miniupnpc/CMakeLists.txt @@ -73,6 +73,13 @@ if (CMAKE_COMPILER_IS_GNUC) endif () endif() +# always add -fPIC +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fPIC") +set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fPIC") +set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fPIC") +set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -fPIC") + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/miniupnpcstrings.h) include_directories (${CMAKE_CURRENT_BINARY_DIR}) diff --git a/external/unbound/CMakeLists.txt b/external/unbound/CMakeLists.txt index 99ef62c5a..7d4da33e2 100644 --- a/external/unbound/CMakeLists.txt +++ b/external/unbound/CMakeLists.txt @@ -50,6 +50,7 @@ else() add_definitions(-D_GNU_SOURCE) endif() add_definitions(-std=c99) +add_definitions(-fPIC) option(USE_ECDSA "Use ECDSA algorithms" ON) option(USE_SHA2 "Enable SHA2 support" ON) diff --git a/src/common/apply_permutation.h b/src/common/apply_permutation.h index 4fd952686..8684f14ce 100644 --- a/src/common/apply_permutation.h +++ b/src/common/apply_permutation.h @@ -30,6 +30,8 @@ // This algorithm is adapted from Raymond Chen's code: // https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145 +#pragma once + #include <vector> #include <functional> #include "misc_log_ex.h" diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 4af987c3b..69288a2b7 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2933,7 +2933,7 @@ bool Blockchain::check_fee(size_t blob_size, uint64_t fee) const needed_fee += (blob_size % 1024) ? 1 : 0; needed_fee *= fee_per_kb; - if (fee < needed_fee * 0.98) // keep a little buffer on acceptance + if (fee < needed_fee - needed_fee / 50) // keep a little 2% buffer on acceptance - no integer overflow { MERROR_VER("transaction fee is not enough: " << print_money(fee) << ", minimum fee: " << print_money(needed_fee)); return false; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 5d25d1058..6c350775d 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -876,6 +876,8 @@ namespace cryptonote } context.m_remote_blockchain_height = arg.current_blockchain_height; + if (context.m_remote_blockchain_height > m_core.get_target_blockchain_height()) + m_core.set_target_blockchain_height(context.m_remote_blockchain_height); std::vector<crypto::hash> block_hashes; block_hashes.reserve(arg.blocks.size()); diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 49d3bc836..237105d06 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -102,7 +102,7 @@ target_link_libraries(daemon ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ZMQ_LIB} - ${Readline_LIBRARY} + ${GNU_READLINE_LIBRARY} ${EXTRA_LIBRARIES}) set_property(TARGET daemon PROPERTY diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 6ac47fcb2..a47e74c71 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -269,7 +269,7 @@ int main(int argc, char const * argv[]) } else { - std::cerr << "Unknown command" << std::endl; + std::cerr << "Unknown command: " << command.front() << std::endl; return 1; } } diff --git a/src/gen_multisig/CMakeLists.txt b/src/gen_multisig/CMakeLists.txt index ff3c46862..8c534d213 100644 --- a/src/gen_multisig/CMakeLists.txt +++ b/src/gen_multisig/CMakeLists.txt @@ -43,8 +43,8 @@ target_link_libraries(gen_multisig ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} - ${Readline_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} + ${GNU_READLINE_LIBRARY} ${EXTRA_LIBRARIES}) add_dependencies(gen_multisig version) diff --git a/src/rpc/zmq_server.cpp b/src/rpc/zmq_server.cpp index afdff2328..6f06f4497 100644 --- a/src/rpc/zmq_server.cpp +++ b/src/rpc/zmq_server.cpp @@ -102,7 +102,7 @@ bool ZmqServer::addTCPSocket(std::string address, std::string port) rep_socket.reset(new zmq::socket_t(context, ZMQ_REP)); - rep_socket->setsockopt(ZMQ_RCVTIMEO, DEFAULT_RPC_RECV_TIMEOUT_MS); + rep_socket->setsockopt(ZMQ_RCVTIMEO, &DEFAULT_RPC_RECV_TIMEOUT_MS, sizeof(DEFAULT_RPC_RECV_TIMEOUT_MS)); std::string bind_address = addr_prefix + address + std::string(":") + port; rep_socket->bind(bind_address.c_str()); diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt index beaacf0e9..f190ada8d 100644 --- a/src/simplewallet/CMakeLists.txt +++ b/src/simplewallet/CMakeLists.txt @@ -55,8 +55,8 @@ target_link_libraries(simplewallet ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} - ${Readline_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} + ${GNU_READLINE_LIBRARY} ${EXTRA_LIBRARIES}) set_property(TARGET simplewallet PROPERTY diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 96e1e561a..79f619ab8 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1780,11 +1780,11 @@ simple_wallet::simple_wallet() tr("Turn this wallet into a multisig wallet, extra step for N-1/N wallets")); m_cmd_binder.set_handler("export_multisig_info", boost::bind(&simple_wallet::export_multisig, this, _1), - tr("export_multisig <filename>"), + tr("export_multisig_info <filename>"), tr("Export multisig info for other participants")); m_cmd_binder.set_handler("import_multisig_info", boost::bind(&simple_wallet::import_multisig, this, _1), - tr("import_multisig <filename> [<filename>...]"), + tr("import_multisig_info <filename> [<filename>...]"), tr("Import multisig info from other participants")); m_cmd_binder.set_handler("sign_multisig", boost::bind(&simple_wallet::sign_multisig, this, _1), @@ -1796,7 +1796,7 @@ simple_wallet::simple_wallet() tr("Submit a signed multisig transaction from a file")); m_cmd_binder.set_handler("export_raw_multisig_tx", boost::bind(&simple_wallet::export_raw_multisig, this, _1), - tr("export_raw_multisig <filename>"), + tr("export_raw_multisig_tx <filename>"), tr("Export a signed multisig transaction to a file")); m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), @@ -6738,7 +6738,8 @@ int main(int argc, char* argv[]) std::vector<std::string> command = command_line::get_arg(*vm, arg_command); if (!command.empty()) { - w.process_command(command); + if (!w.process_command(command)) + fail_msg_writer() << tr("Unknown command: ") << command.front(); w.stop(); w.deinit(); } diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index e3a9c7eb5..3bb69f2be 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -258,6 +258,7 @@ namespace tools entry.note = m_wallet->get_tx_note(pd.m_tx_hash); entry.type = "in"; entry.subaddr_index = pd.m_subaddr_index; + entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index); } //------------------------------------------------------------------------------------------------------------------------------ void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) @@ -283,6 +284,7 @@ namespace tools entry.type = "out"; entry.subaddr_index = { pd.m_subaddr_account, 0 }; + entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0}); } //------------------------------------------------------------------------------------------------------------------------------ void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd) @@ -301,6 +303,7 @@ namespace tools entry.note = m_wallet->get_tx_note(txid); entry.type = is_failed ? "failed" : "pending"; entry.subaddr_index = { pd.m_subaddr_account, 0 }; + entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0}); } //------------------------------------------------------------------------------------------------------------------------------ void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &ppd) @@ -319,6 +322,7 @@ namespace tools entry.double_spend_seen = ppd.m_double_spend_seen; entry.type = "pool"; entry.subaddr_index = pd.m_subaddr_index; + entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index); } //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res, epee::json_rpc::error& er) diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h index 9c81f95cb..ac25e8e84 100644 --- a/src/wallet/wallet_rpc_server_commands_defs.h +++ b/src/wallet/wallet_rpc_server_commands_defs.h @@ -1114,6 +1114,7 @@ namespace wallet_rpc std::string type; uint64_t unlock_time; cryptonote::subaddress_index subaddr_index; + std::string address; bool double_spend_seen; BEGIN_KV_SERIALIZE_MAP() @@ -1128,6 +1129,7 @@ namespace wallet_rpc KV_SERIALIZE(type); KV_SERIALIZE(unlock_time) KV_SERIALIZE(subaddr_index); + KV_SERIALIZE(address); KV_SERIALIZE(double_spend_seen) END_KV_SERIALIZE_MAP() }; |