1
0
Fork 0
forked from lthn/blockchain

Merge branch 'tor' into develop

This commit is contained in:
cryptozoidberg 2022-04-20 19:17:00 +02:00
commit 6033828209
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
46 changed files with 652 additions and 497 deletions

5
.gitmodules vendored
View file

@ -7,3 +7,8 @@
[submodule "src/gui/qt-daemon/layout"]
path = src/gui/qt-daemon/layout
url = https://github.com/hyle-team/zano_ui.git
branch = main
[submodule "contrib/tor-connect"]
path = contrib/tor-connect
url = https://github.com/hyle-team/tor-connect.git
branch = main

View file

@ -56,18 +56,23 @@ if(APPLE)
endif()
set(USE_PCH FALSE CACHE BOOL "Use shared precompiled headers")
set(DISABLE_TOR FALSE CACHE BOOL "Disable TOR library(and related tor-connect submodule)")
set(TESTNET FALSE CACHE BOOL "Compile for testnet")
set(BUILD_GUI FALSE CACHE BOOL "Build qt-daemon")
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
add_definitions(-DSTATICLIB)
set(TESTNET FALSE CACHE BOOL "Compile for testnet")
if(TESTNET)
message("!!!!!! NOTICE: Project is building for TESTNET !!!!!!")
add_definitions(-DTESTNET)
endif()
set(BUILD_GUI FALSE CACHE BOOL "Build qt-daemon")
if(DISABLE_TOR)
message("NOTICE: Building with disabled TOR support!")
add_definitions(-DDISABLE_TOR)
endif()
set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
@ -197,7 +202,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(Boost_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}/${CMAKE_ANDROID_ARCH_ABI}/")
set(Boost_LIBRARIES "${Boost_LIBRARY_DIRS}libboost_system.a;${Boost_LIBRARY_DIRS}libboost_filesystem.a;${Boost_LIBRARY_DIRS}libboost_thread.a;${Boost_LIBRARY_DIRS}libboost_timer.a;${Boost_LIBRARY_DIRS}libboost_date_time.a;${Boost_LIBRARY_DIRS}libboost_chrono.a;${Boost_LIBRARY_DIRS}libboost_regex.a;${Boost_LIBRARY_DIRS}libboost_serialization.a;${Boost_LIBRARY_DIRS}libboost_atomic.a;${Boost_LIBRARY_DIRS}libboost_program_options.a")
else()
find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale)
find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale)
endif()

View file

@ -18,7 +18,8 @@ Be sure to clone the repository properly:\
| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2015 (14.0 update 1) | 2017 (15.9.0) | 2019 |
| [XCode](https://developer.apple.com/downloads/) (macOS) | 9.2 | 12.3 | 12.3 |
| [CMake](https://cmake.org/download/) | 2.8.6 | 3.15.5 | 3.20 |
| [Boost](https://www.boost.org/users/download/) | 1.56 | 1.68 | 1.76 |
| [Boost](https://www.boost.org/users/download/) | 1.70 | 1.70 | 1.76 |
| [OpenSSL](https://www.openssl.org/source/) | - | 1.1.1n | 1.1.1n |
| [Qt](https://download.qt.io/archive/qt/) (*only for GUI*) | 5.8.0 | 5.11.2 | 5.15.2 |
Note:\
@ -35,18 +36,18 @@ Recommended OS version: Ubuntu 18.04 LTS.
[*server version*]
sudo apt-get install -y build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev cmake git screen
sudo apt-get install -y build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev cmake git screen checkinstall zlib1g-dev
[*GUI version*]
sudo apt-get install -y build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev cmake git screen mesa-common-dev libglu1-mesa-dev
sudo apt-get install -y build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev cmake git screen checkinstall zlib1g-dev mesa-common-dev libglu1-mesa-dev
2. Download and build Boost
wget https://boostorg.jfrog.io/artifactory/main/release/1.68.0/source/boost_1_68_0.tar.bz2
tar -xjf boost_1_68_0.tar.bz2
cd boost_1_68_0
./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,chrono,regex,serialization,atomic,program_options,locale,timer
curl -OL https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.bz2
tar -xjf boost_1_70_0.tar.bz2
cd boost_1_70_0
./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,chrono,regex,serialization,atomic,program_options,locale,timer,log
./b2
3. Install Qt\
@ -54,28 +55,44 @@ Recommended OS version: Ubuntu 18.04 LTS.
[*GUI version*]
wget https://download.qt.io/new_archive/qt/5.11/5.11.2/qt-opensource-linux-x64-5.11.2.run
curl -OL https://download.qt.io/new_archive/qt/5.11/5.11.2/qt-opensource-linux-x64-5.11.2.run
chmod +x qt-opensource-linux-x64-5.11.2.run
./qt-opensource-linux-x64-5.11.2.run
Then follow the instructions in Wizard. Don't forget to tick the WebEngine module checkbox!
4. Set environment variables properly\
4. Install OpenSSL
We recommend installing OpenSSL v1.1.1n locally unless you would like to use the same version system-wide.
curl -OL https://www.openssl.org/source/openssl-1.1.1n.tar.gz
tar xaf openssl-1.1.1n.tar.gz
cd openssl-1.1.1n/
./config --prefix=/home/user/openssl --openssldir=/home/user/openssl shared zlib
make
make test
make install
5. Set environment variables properly\
For instance, by adding the following lines to `~/.bashrc`
[*server version*]
export BOOST_ROOT=/home/user/boost_1_68_0
export BOOST_ROOT=/home/user/boost_1_70_0
export OPENSSL_ROOT_DIR=/home/user/openssl
[*GUI version*]
export BOOST_ROOT=/home/user/boost_1_68_0
export BOOST_ROOT=/home/user/boost_1_70_0
export OPENSSL_ROOT_DIR=/home/user/openssl
export QT_PREFIX_PATH=/home/user/Qt5.11.2/5.11.2/gcc_64
5. Building binaries
1. Building daemon and simplewallet:
6. Build the binaries
1. Build daemon and simplewallet:
cd zano/ && make -j1
or
@ -88,7 +105,7 @@ For instance, by adding the following lines to `~/.bashrc`
**NOTICE 2**: If you'd like to build binaries for the testnet, use `cmake -D TESTNET=TRUE ..` instead of `cmake ..` .
1. Building GUI:
1. Build GUI:
cd zano
utils/build_sript_linux.sh
@ -99,9 +116,9 @@ For instance, by adding the following lines to `~/.bashrc`
### Windows
Recommended OS version: Windows 7 x64.
1. Install required prerequisites (Boost, Qt, CMake).
1. Install required prerequisites (Boost, Qt, CMake, OpenSSL).
2. Edit paths in `utils/configure_local_paths.cmd`.
3. Run `utils/configure_win64_msvs2015_gui.cmd` or `utils/configure_win64_msvs2017_gui.cmd` according to your MSVC version.
3. Run one of `utils/configure_win64_msvsNNNN_gui.cmd` according to your MSVC version.
4. Go to the build folder and open generated Zano.sln in MSVC.
5. Build.
@ -115,7 +132,7 @@ In order to correctly deploy Qt GUI application, you also need to do the followi
<br />
### macOS
Recommended OS version: macOS Sierra 10.15.4 x64.
Recommended OS version: macOS Big Sur 11.4 x64.
1. Install required prerequisites.
2. Set environment variables as stated in `utils/macosx_build_config.command`.
3. `mkdir build` <br> `cd build` <br> `cmake ..` <br> `make`

View file

@ -5,6 +5,10 @@ add_subdirectory(zlib)
add_subdirectory(db)
add_subdirectory(ethereum)
if( NOT DISABLE_TOR)
add_subdirectory(tor-connect)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
message("excluded upnp support for IOS build")
@ -17,6 +21,10 @@ set_property(TARGET libminiupnpc-static PROPERTY FOLDER "contrib")
set_property(TARGET zlibstatic PROPERTY FOLDER "contrib")
set_property(TARGET mdbx PROPERTY FOLDER "contrib")
set_property(TARGET lmdb PROPERTY FOLDER "contrib")
if( NOT DISABLE_TOR)
set_property(TARGET tor-connect PROPERTY FOLDER "contrib")
endif()
set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat PROPERTY FOLDER "unused")
if(MSVC)

View file

@ -31,6 +31,8 @@
#include <limits>
#include <set>
#include <iterator>
#include <algorithm>
#include <functional>
#include <boost/thread.hpp>
#include "include_base_utils.h"
#include "auto_val_init.h"
@ -111,17 +113,6 @@ namespace misc_utils
return (std::numeric_limits<t_type>::max)();
}
// TEMPLATE STRUCT less
template<class _Ty>
struct less_as_pod
: public std::binary_function<_Ty, _Ty, bool>
{ // functor for operator<
bool operator()(const _Ty& _Left, const _Ty& _Right) const
{ // apply operator< to operands
return memcmp(&_Left, &_Right, sizeof(_Left)) < 0;
}
};
template<class _Ty>
bool is_less_as_pod(const _Ty& _Left, const _Ty& _Right)
{ // apply operator< to operands

View file

@ -831,7 +831,7 @@ using namespace std;
return false;
}else
{ //Apparently there are no signs of the form of transfer, will receive data until the connection is closed
m_state = reciev_machine_state_error;
m_state = reciev_machine_state_body_connection_close;
LOG_PRINT("Undefinded transfer type, consider http_body_transfer_connection_close method. header: " << m_header_cache, LOG_LEVEL_2);
return false;
}

View file

@ -46,11 +46,12 @@ namespace levin
/************************************************************************/
/* */
/************************************************************************/
class levin_client_impl
template<typename transport_t>
class levin_client_impl_t
{
public:
levin_client_impl();
virtual ~levin_client_impl();
levin_client_impl_t();
virtual ~levin_client_impl_t();
bool connect(u_long ip, int port, unsigned int timeout, const std::string& bind_ip = "0.0.0.0");
bool connect(const std::string& addr, int port, unsigned int timeout, const std::string& bind_ip = "0.0.0.0");
@ -61,26 +62,30 @@ namespace levin
virtual int notify(int command, const std::string& in_buff);
protected:
net_utils::blocked_mode_client m_transport;
transport_t m_transport;
//net_utils::blocked_mode_client m_transport;
};
/************************************************************************/
/* */
/************************************************************************/
class levin_client_impl2: public levin_client_impl
template<typename transport_t>
class levin_client_impl2: public levin_client_impl_t<transport_t>
{
public:
int invoke(int command, const std::string& in_buff, std::string& buff_out);
int notify(int command, const std::string& in_buff);
transport_t& get_transport() {return this->m_transport;}
};
}
namespace net_utils
{
typedef levin::levin_client_impl levin_client;
typedef levin::levin_client_impl2 levin_client2;
typedef levin::levin_client_impl_t<net_utils::blocked_mode_client> levin_client;
typedef levin::levin_client_impl2<net_utils::blocked_mode_client> levin_client2;
}
}

View file

@ -32,175 +32,174 @@
#include "string_tools.h"
namespace epee
{
namespace levin
{
inline
bool levin_client_impl::connect(u_long ip, int port, unsigned int timeout, const std::string& bind_ip)
{
return m_transport.connect(string_tools::get_ip_string_from_int32(ip), port, timeout, timeout, bind_ip);
}
//------------------------------------------------------------------------------
inline
bool levin_client_impl::connect(const std::string& addr, int port, unsigned int timeout, const std::string& bind_ip)
{
return m_transport.connect(addr, port, timeout, timeout, bind_ip);
}
//------------------------------------------------------------------------------
inline
bool levin_client_impl::is_connected()
{
return m_transport.is_connected();
}
//------------------------------------------------------------------------------
inline
bool levin_client_impl::disconnect()
{
return m_transport.disconnect();
}
//------------------------------------------------------------------------------
inline
levin_client_impl::levin_client_impl()
{
}
//------------------------------------------------------------------------------
inline
levin_client_impl::~levin_client_impl()
{
disconnect();
}
//------------------------------------------------------------------------------
inline
int levin_client_impl::invoke(int command, const std::string& in_buff, std::string& buff_out)
{
if(!is_connected())
return -1;
bucket_head head = {0};
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = true;
head.m_command = command;
if(!m_transport.send(&head, sizeof(head)))
return -1;
if(!m_transport.send(in_buff))
return -1;
std::string local_buff;
if(!m_transport.recv_n(local_buff, sizeof(bucket_head)))
return -1;
head = *(bucket_head*)local_buff.data();
if(head.m_signature!=LEVIN_SIGNATURE)
{
LOG_PRINT_L0("Signature missmatch in response");
return -1;
}
if(!m_transport.recv_n(buff_out, head.m_cb))
return -1;
return head.m_return_code;
}
//------------------------------------------------------------------------------
inline
int levin_client_impl::notify(int command, const std::string& in_buff)
{
if(!is_connected())
return -1;
bucket_head head = {0};
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = false;
head.m_command = command;
if(!m_transport.send((const char*)&head, sizeof(head)))
return -1;
if(!m_transport.send(in_buff))
return -1;
return 1;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
inline
int levin_client_impl2::invoke(int command, const std::string& in_buff, std::string& buff_out)
{
if(!is_connected())
return -1;
bucket_head2 head = {0};
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = true;
head.m_command = static_cast<uint32_t>(command);
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_REQUEST;
if(!m_transport.send(&head, sizeof(head)))
return -1;
if(!m_transport.send(in_buff))
return -1;
//Since other side of connection could be running by async server,
//we can receive some unexpected notify(forwarded broadcast notifications for example).
//let's ignore every notify in the channel until we get invoke response
std::string local_buff;
while (true)
namespace levin
{
if (!m_transport.recv_n(local_buff, sizeof(bucket_head2)))
return LEVIN_ERROR_NET_ERROR;
head = *(bucket_head2*)local_buff.data();
if (head.m_signature != LEVIN_SIGNATURE)
template<typename transport_t>
bool levin_client_impl_t<transport_t>::connect(u_long ip, int port, unsigned int timeout, const std::string& bind_ip)
{
LOG_PRINT_L0("Signature missmatch in response");
return LEVIN_ERROR_SIGNATURE_MISMATCH;
return m_transport.connect(string_tools::get_ip_string_from_int32(ip), port, timeout, timeout, bind_ip);
}
if (!m_transport.recv_n(buff_out, head.m_cb))
return LEVIN_ERROR_NET_ERROR;
//now check if this is response to invoke (and extra validate if it's response to this(!) invoke)
if (head.m_flags&LEVIN_PACKET_RESPONSE)
//------------------------------------------------------------------------------
template<typename transport_t>
bool levin_client_impl_t<transport_t>::connect(const std::string& addr, int port, unsigned int timeout, const std::string& bind_ip)
{
//we got response, extra validate if its response to our request
CHECK_AND_ASSERT_MES(head.m_command == static_cast<uint32_t>(command), LEVIN_ERROR_PROTOCOL_INCONSISTENT, "command id missmatch in response: " << head.m_command << ", expected: " << command);
return m_transport.connect(addr, port, timeout, timeout, bind_ip);
}
//------------------------------------------------------------------------------
template<typename transport_t>
bool levin_client_impl_t<transport_t>::is_connected()
{
return m_transport.is_connected();
}
//------------------------------------------------------------------------------
template<typename transport_t>
bool levin_client_impl_t<transport_t>::disconnect()
{
return m_transport.disconnect();
}
//------------------------------------------------------------------------------
template<typename transport_t>
levin_client_impl_t<transport_t>::levin_client_impl_t()
{
}
//------------------------------------------------------------------------------
template<typename transport_t>
levin_client_impl_t<transport_t>::~levin_client_impl_t()
{
disconnect();
}
//------------------------------------------------------------------------------
template<typename transport_t>
int levin_client_impl_t<transport_t>::invoke(int command, const std::string& in_buff, std::string& buff_out)
{
if (!is_connected())
return -1;
bucket_head head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = true;
head.m_command = command;
if (!m_transport.send(&head, sizeof(head)))
return -1;
if (!m_transport.send(in_buff))
return -1;
std::string local_buff;
if (!m_transport.recv_n(local_buff, sizeof(bucket_head)))
return -1;
head = *(bucket_head*)local_buff.data();
if (head.m_signature != LEVIN_SIGNATURE)
{
LOG_PRINT_L0("Signature missmatch in response");
return -1;
}
if (!m_transport.recv_n(buff_out, head.m_cb))
return -1;
return head.m_return_code;
}
//------------------------------------------------------------------------------
template<typename transport_t>
int levin_client_impl_t<transport_t>::notify(int command, const std::string& in_buff)
{
if (!this->is_connected())
return -1;
bucket_head head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = false;
head.m_command = command;
if (!m_transport.send((const char*)&head, sizeof(head)))
return -1;
if (!m_transport.send(in_buff))
return -1;
return 1;
}
//------------------------------------------------------------------------------
template<typename transport_t>
int levin_client_impl2<transport_t>::invoke(int command, const std::string& in_buff, std::string& buff_out)
{
if (!this->is_connected())
return -1;
bucket_head2 head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = true;
head.m_command = static_cast<uint32_t>(command);
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_REQUEST;
if (!this->m_transport.send(&head, sizeof(head)))
return -1;
if (!this->m_transport.send(in_buff))
return -1;
//Since other side of connection could be running by async server,
//we can receive some unexpected notify(forwarded broadcast notifications for example).
//let's ignore every notify in the channel until we get invoke response
std::string local_buff;
while (true)
{
if (!this->m_transport.recv_n(local_buff, sizeof(bucket_head2)))
return LEVIN_ERROR_NET_ERROR;
head = *(bucket_head2*)local_buff.data();
if (head.m_signature != LEVIN_SIGNATURE)
{
LOG_PRINT_L0("Signature missmatch in response");
return LEVIN_ERROR_SIGNATURE_MISMATCH;
}
if (!this->m_transport.recv_n(buff_out, head.m_cb))
return LEVIN_ERROR_NET_ERROR;
//now check if this is response to invoke (and extra validate if it's response to this(!) invoke)
if (head.m_flags&LEVIN_PACKET_RESPONSE)
{
//we got response, extra validate if its response to our request
CHECK_AND_ASSERT_MES(head.m_command == static_cast<uint32_t>(command), LEVIN_ERROR_PROTOCOL_INCONSISTENT, "command id missmatch in response: " << head.m_command << ", expected: " << command);
return head.m_return_code;
}
}
//never comes here
return LEVIN_ERROR_INTERNAL;
}
//------------------------------------------------------------------------------
template<typename transport_t>
int levin_client_impl2<transport_t>::notify(int command, const std::string& in_buff)
{
if (!this->is_connected())
return -1;
bucket_head2 head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = false;
head.m_command = command;
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_REQUEST;
if (!this->m_transport.send((const char*)&head, sizeof(head)))
return -1;
if (!this->m_transport.send(in_buff))
return -1;
return 1;
}
}
//never comes here
return LEVIN_ERROR_INTERNAL;
}
//------------------------------------------------------------------------------
inline
int levin_client_impl2::notify(int command, const std::string& in_buff)
{
if(!is_connected())
return -1;
bucket_head2 head = {0};
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = in_buff.size();
head.m_have_to_return_data = false;
head.m_command = command;
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_REQUEST;
if(!m_transport.send((const char*)&head, sizeof(head)))
return -1;
if(!m_transport.send(in_buff))
return -1;
return 1;
}
}
}
//------------------------------------------------------------------------------

1
contrib/tor-connect Submodule

@ -0,0 +1 @@
Subproject commit aa509880f06292ac8078046f3d49ff854e400716

View file

@ -121,12 +121,11 @@ add_library(currency_core ${CURRENCY_CORE})
add_dependencies(currency_core version ${PCH_LIB_NAME})
ENABLE_SHARED_PCH(currency_core CURRENCY_CORE)
add_library(wallet ${WALLET})
if(CMAKE_SYSTEM_NAME STREQUAL "Android" )
add_library(wallet ${WALLET})
add_dependencies(wallet version ${PCH_LIB_NAME})
target_link_libraries(wallet currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} android log)
else()
add_library(wallet ${WALLET})
add_dependencies(wallet version ${PCH_LIB_NAME})
ENABLE_SHARED_PCH(wallet WALLET)
endif()
@ -170,8 +169,12 @@ ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL)
ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool)
add_executable(simplewallet ${SIMPLEWALLET})
add_dependencies(simplewallet version)
add_dependencies(simplewallet version)
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
if(NOT DISABLE_TOR)
target_link_libraries(simplewallet tor-connect)
endif()
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET)
ENABLE_SHARED_PCH_EXECUTABLE(simplewallet)
@ -196,6 +199,9 @@ if(BUILD_GUI)
find_package(Qt5PrintSupport REQUIRED)
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
if(NOT DISABLE_TOR)
target_link_libraries(Zano tor-connect)
endif()
if (UNIX AND NOT APPLE)
target_link_libraries(Zano rt)
endif()

View file

@ -51,11 +51,11 @@ namespace utils
int num_threads = std::thread::hardware_concurrency();
this->init(num_threads);
}
void init(unsigned int num_threads)
void init(size_t num_threads)
{
m_is_stop = false;
for (unsigned int i = 0; i < num_threads; i++)
for (size_t i = 0; i < num_threads; i++)
{
m_threads.push_back(std::thread([this]() {this->worker_func(); }));
}
@ -81,7 +81,7 @@ namespace utils
std::mutex batch_mutex;
std::atomic<size_t> cnt = 0;
std::atomic<size_t> cnt(0);
for (const auto& jb : cntr)
{
call_executor_base* pjob = jb.get();

17
src/common/tor_helper.h Normal file
View file

@ -0,0 +1,17 @@
// Copyright (c) 2014-2018 Zano Project
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include "tor-connect/torlib/tor_wrapper.h"
namespace tools
{
typedef epee::levin::levin_client_impl2<tools::tor::tor_transport> levin_over_tor_client;
}

View file

@ -640,7 +640,7 @@ bool handle_request_stat(po::variables_map& vm, peerid_type peer_id)
response_schema rs = AUTO_VAL_INIT(rs);
levin::levin_client_impl2 transport;
net_utils::levin_client2 transport;
if(!transport.connect(command_line::get_arg(vm, arg_ip), static_cast<int>(command_line::get_arg(vm, arg_port)), static_cast<int>(command_line::get_arg(vm, arg_timeout))))
{
std::cout << "{" << ENDL << " \"status\": \"ERROR: " << "Failed to connect to " << command_line::get_arg(vm, arg_ip) << ":" << command_line::get_arg(vm, arg_port) << "\"" << ENDL << "}" << ENDL;
@ -878,7 +878,7 @@ bool generate_and_print_keys()
}
//---------------------------------------------------------------------------------------------------------------
template<class command_t>
bool invoke_debug_command(po::variables_map& vm, const crypto::secret_key& sk, levin::levin_client_impl2& transport, peerid_type& peer_id, typename command_t::request& req, typename command_t::response& rsp)
bool invoke_debug_command(po::variables_map& vm, const crypto::secret_key& sk, net_utils::levin_client2& transport, peerid_type& peer_id, typename command_t::request& req, typename command_t::response& rsp)
{
if (!transport.is_connected())
{
@ -933,7 +933,7 @@ bool handle_set_peer_log_level(po::variables_map& vm)
return false;
}
levin::levin_client_impl2 transport;
net_utils::levin_client2 transport;
peerid_type peer_id = 0;
COMMAND_SET_LOG_LEVEL::request req = AUTO_VAL_INIT(req);
@ -982,7 +982,7 @@ bool handle_download_peer_log(po::variables_map& vm)
}
uint64_t start_offset = static_cast<uint64_t>(start_offset_signed);
levin::levin_client_impl2 transport;
net_utils::levin_client2 transport;
peerid_type peer_id = 0;
COMMAND_REQUEST_LOG::request req = AUTO_VAL_INIT(req);

View file

@ -250,6 +250,8 @@
static_assert(CURRENCY_MINER_TX_MAX_OUTS <= CURRENCY_TX_MAX_ALLOWED_OUTS, "Miner tx must obey normal tx max outs limit");
static_assert(PREMINE_AMOUNT / WALLET_MAX_ALLOWED_OUTPUT_AMOUNT < CURRENCY_MINER_TX_MAX_OUTS, "Premine can't be divided into reasonable number of outs");
#define CURRENCY_RELAY_TXS_MAX_COUNT 5

View file

@ -666,7 +666,7 @@ namespace currency
bool tx_memory_pool::force_relay_pool() const
{
LOG_PRINT_GREEN("Preparing relay message...", LOG_LEVEL_0);
NOTIFY_NEW_TRANSACTIONS::request r = AUTO_VAL_INIT(r);
NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request r = AUTO_VAL_INIT(r);
m_db_transactions.enumerate_items([&](uint64_t i, const crypto::hash& k, const tx_details& v)
{

View file

@ -71,7 +71,7 @@ namespace currency
/************************************************************************/
/* */
/************************************************************************/
struct NOTIFY_NEW_TRANSACTIONS
struct NOTIFY_OR_INVOKE_NEW_TRANSACTIONS
{
const static int ID = BC_COMMANDS_POOL_BASE + 2;
@ -83,6 +83,16 @@ namespace currency
KV_SERIALIZE(txs)
END_KV_SERIALIZE_MAP()
};
struct response
{
std::string code;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(code)
END_KV_SERIALIZE_MAP()
};
};
/************************************************************************/
/* */

View file

@ -35,14 +35,15 @@ namespace currency
typedef core_stat_info stat_info;
typedef t_currency_protocol_handler<t_core> currency_protocol_handler;
typedef CORE_SYNC_DATA payload_type;
typedef std::pair<NOTIFY_NEW_TRANSACTIONS::request, currency_connection_context> relay_que_entry;
typedef std::pair<NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request, currency_connection_context> relay_que_entry;
t_currency_protocol_handler(t_core& rcore, nodetool::i_p2p_endpoint<connection_context>* p_net_layout);
~t_currency_protocol_handler();
BEGIN_INVOKE_MAP2(currency_protocol_handler)
HANDLE_NOTIFY_T2(NOTIFY_NEW_BLOCK, &currency_protocol_handler::handle_notify_new_block)
HANDLE_NOTIFY_T2(NOTIFY_NEW_TRANSACTIONS, &currency_protocol_handler::handle_notify_new_transactions)
HANDLE_NOTIFY_T2(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS, &currency_protocol_handler::handle_notify_new_transactions)
HANDLE_INVOKE_T2(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS, &currency_protocol_handler::handle_invoke_new_transaction)
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_GET_OBJECTS, &currency_protocol_handler::handle_request_get_objects)
HANDLE_NOTIFY_T2(NOTIFY_RESPONSE_GET_OBJECTS, &currency_protocol_handler::handle_response_get_objects)
HANDLE_NOTIFY_T2(NOTIFY_REQUEST_CHAIN, &currency_protocol_handler::handle_request_chain)
@ -76,16 +77,18 @@ namespace currency
private:
//----------------- commands handlers ----------------------------------------------
int handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, currency_connection_context& context);
int handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& context);
int handle_notify_new_transactions(int command, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency_connection_context& context);
int handle_invoke_new_transaction(int command, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& req, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response& rsp, currency_connection_context& context);
int handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, currency_connection_context& context);
int handle_response_get_objects(int command, NOTIFY_RESPONSE_GET_OBJECTS::request& arg, currency_connection_context& context);
int handle_request_chain(int command, NOTIFY_REQUEST_CHAIN::request& arg, currency_connection_context& context);
int handle_response_chain_entry(int command, NOTIFY_RESPONSE_CHAIN_ENTRY::request& arg, currency_connection_context& context);
//----------------- i_bc_protocol_layout ---------------------------------------
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, currency_connection_context& exclude_context);
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context);
virtual bool relay_transactions(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context);
//----------------------------------------------------------------------------------
//bool get_payload_sync_data(HANDSHAKE_DATA::request& hshd, currency_connection_context& context);
bool request_missing_objects(currency_connection_context& context, bool check_having_blocks);
@ -93,7 +96,7 @@ namespace currency
void relay_que_worker();
void process_current_relay_que(const std::list<relay_que_entry>& que);
bool check_stop_flag_and_drop_cc(currency_connection_context& context);
int handle_new_transaction_from_net(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& req, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response& rsp, currency_connection_context& context, bool is_notify);
t_core& m_core;
nodetool::p2p_endpoint_stub<connection_context> m_p2p_stub;

View file

@ -369,45 +369,79 @@ namespace currency
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
int t_currency_protocol_handler<t_core>::handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& context)
int t_currency_protocol_handler<t_core>::handle_notify_new_transactions(int command, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency_connection_context& context)
{
NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response rsp_dummy = AUTO_VAL_INIT(rsp_dummy);
return this->handle_new_transaction_from_net(arg, rsp_dummy, context, true);
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
int t_currency_protocol_handler<t_core>::handle_invoke_new_transaction(int command, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& req, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response& rsp, currency_connection_context& context)
{
return this->handle_new_transaction_from_net(req, rsp, context, false);
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
int t_currency_protocol_handler<t_core>::handle_new_transaction_from_net(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response& rsp, currency_connection_context& context, bool is_notify)
{
//do not process requests if it comes from node wich is debugged
if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address)
{
rsp.code = API_RETURN_CODE_ACCESS_DENIED;
return 1;
}
if(context.m_state != currency_connection_context::state_normal)
//if(context.m_state != currency_connection_context::state_normal)
// return 1;
if (!this->is_synchronized())
{
rsp.code = API_RETURN_CODE_BUSY;
return 1;
}
uint64_t inital_tx_count = arg.txs.size();
if (inital_tx_count > CURRENCY_RELAY_TXS_MAX_COUNT)
{
LOG_PRINT_L1("NOTIFY_NEW_TRANSACTIONS: To many transactions in NOTIFY_OR_INVOKE_NEW_TRANSACTIONS(" << inital_tx_count << ")");
rsp.code = API_RETURN_CODE_OVERFLOW;
return 1;
}
TIME_MEASURE_START_MS(new_transactions_handle_time);
for(auto tx_blob_it = arg.txs.begin(); tx_blob_it!=arg.txs.end();)
for (auto tx_blob_it = arg.txs.begin(); tx_blob_it != arg.txs.end();)
{
currency::tx_verification_context tvc = AUTO_VAL_INIT(tvc);
m_core.handle_incoming_tx(*tx_blob_it, tvc, false);
if(tvc.m_verification_failed)
if (tvc.m_verification_failed)
{
LOG_PRINT_L0("NOTIFY_NEW_TRANSACTIONS: Tx verification failed, dropping connection");
m_p2p->drop_connection(context);
if(is_notify)
m_p2p->drop_connection(context);
else
rsp.code = API_RETURN_CODE_FAIL;
return 1;
}
if(tvc.m_should_be_relayed)
if (tvc.m_should_be_relayed)
++tx_blob_it;
else
arg.txs.erase(tx_blob_it++);
}
if(arg.txs.size())
if (arg.txs.size())
{
//TODO: add announce usage here
relay_transactions(arg, context);
}
TIME_MEASURE_FINISH_MS(new_transactions_handle_time);
LOG_PRINT_L2("NOTIFY_NEW_TRANSACTIONS: " << new_transactions_handle_time << "ms (inital_tx_count: " << inital_tx_count << ", relayed_tx_count: " << arg.txs.size() << ")");
return true;
LOG_PRINT_L2("NOTIFY_OR_INVOKE_NEW_TRANSACTIONS(is_notify=" << is_notify <<"): " << new_transactions_handle_time << "ms (inital_tx_count: " << inital_tx_count << ", relayed_tx_count: " << arg.txs.size() << ")");
rsp.code = API_RETURN_CODE_OK;
return 1;
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
int t_currency_protocol_handler<t_core>::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, currency_connection_context& context)
@ -756,7 +790,7 @@ namespace currency
m_p2p->get_connections(connections);
for (auto& cc : connections)
{
NOTIFY_NEW_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
for (auto& qe : que)
{
//exclude relaying to original sender
@ -766,7 +800,7 @@ namespace currency
}
if (req.txs.size())
{
post_notify<NOTIFY_NEW_TRANSACTIONS>(req, cc);
post_notify<NOTIFY_OR_INVOKE_NEW_TRANSACTIONS>(req, cc);
if (debug_ss.tellp())
debug_ss << ", ";
@ -944,7 +978,7 @@ namespace currency
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>
bool t_currency_protocol_handler<t_core>::relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context)
bool t_currency_protocol_handler<t_core>::relay_transactions(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context)
{
#ifdef ASYNC_RELAY_MODE
{
@ -956,7 +990,7 @@ namespace currency
//m_relay_que_cv.notify_all();
return true;
#else
return relay_post_notify<NOTIFY_NEW_TRANSACTIONS>(arg, exclude_context);
return relay_post_notify<NOTIFY_OR_INVOKE_NEW_TRANSACTIONS>(arg, exclude_context);
#endif
}
}

View file

@ -17,7 +17,7 @@ namespace currency
struct i_currency_protocol
{
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, currency_connection_context& exclude_context)=0;
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context)=0;
virtual bool relay_transactions(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency_connection_context& exclude_context)=0;
//virtual bool request_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, currency_connection_context& context)=0;
};
@ -30,7 +30,7 @@ namespace currency
{
return false;
}
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& /*arg*/, currency_connection_context& /*exclude_context*/)
virtual bool relay_transactions(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& /*arg*/, currency_connection_context& /*exclude_context*/)
{
return false;
}

View file

@ -100,6 +100,7 @@ MainWindow::MainWindow()
, m_system_shutdown(false)
, m_view(nullptr)
, m_channel(nullptr)
, m_ui_dispatch_id_counter(0)
{
#ifndef _MSC_VER
//workaround for macos broken tolower from std, very dirty hack
@ -415,7 +416,7 @@ bool MainWindow::init(const std::string& html_path)
//QtWebEngine::initialize();
init_tray_icon(html_path);
set_html_path(html_path);
m_threads_pool.init(2);
m_backend.subscribe_to_core_events(this);
bool r = QSslSocket::supportsSsl();
@ -920,6 +921,41 @@ QString MainWindow::start_backend(const QString& params)
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::sync_call(const QString& func_name, const QString& params)
{
if (func_name == "transfer")
{
return this->transfer(params);
}
else if (func_name == "test_call")
{
return params;
}
else
{
return QString(QString() + "{ \"status\": \"Method '" + func_name + "' not found\"}");
}
}
QString MainWindow::async_call(const QString& func_name, const QString& params)
{
uint64_t job_id = m_ui_dispatch_id_counter++;
QString method_name = func_name;
QString argements = params;
auto async_callback = [this, method_name, argements, job_id]()
{
QString res_str = this->sync_call(method_name, argements);
this->dispatch_async_call_result(std::to_string(job_id).c_str(), res_str); //general function
};
m_threads_pool.add_job(async_callback);
LOG_PRINT_L2("[UI_ASYNC_CALL]: started " << method_name.toStdString() << ", job id: " << job_id);
return QString::fromStdString(std::string("{ \"job_id\": ") + std::to_string(job_id) + "}");
}
bool MainWindow::update_wallet_status(const view::wallet_status_info& wsi)
{
TRY_ENTRY();
@ -947,6 +983,17 @@ bool MainWindow::set_options(const view::gui_options& opt)
CATCH_ENTRY2(false);
}
bool MainWindow::update_tor_status(const view::current_action_status& opt)
{
TRY_ENTRY();
std::string json_str;
epee::serialization::store_t_to_json(opt, json_str, 0, epee::serialization::eol_lf);
LOG_PRINT_L0("SENDING SIGNAL -> [HANDLE_CURRENT_ACTION_STATE]:" << std::endl << json_str);
QMetaObject::invokeMethod(this, "handle_current_action_state", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
return true;
CATCH_ENTRY2(false);
}
bool MainWindow::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
TRY_ENTRY();
@ -1654,6 +1701,20 @@ QString MainWindow::get_log_level(const QString& param)
CATCH_ENTRY_FAIL_API_RESPONCE();
}
QString MainWindow::set_enable_tor(const QString& param)
{
TRY_ENTRY();
LOG_API_TIMING();
PREPARE_ARG_FROM_JSON(currency::struct_with_one_t_type<bool>, enabl_tor);
m_backend.set_use_tor(enabl_tor.v);
//epee::log_space::get_set_log_detalisation_level(true, enabl_tor.v);
default_ar.error_code = API_RETURN_CODE_OK;
LOG_PRINT("[TOR]: Enable TOR set to " << enabl_tor.v, LOG_LEVEL_MIN);
return MAKE_RESPONSE(default_ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
// QString MainWindow::dump_all_offers()
// {
// LOG_API_TIMING();

View file

@ -18,6 +18,8 @@
#include "currency_core/offers_services_helpers.h"
#endif
#include "common/threads_pool.h"
QT_BEGIN_NAMESPACE
class QWebEngineView;
class QLineEdit;
@ -137,6 +139,7 @@ public:
QString stop_pos_mining(const QString& param);
QString set_log_level(const QString& param);
QString get_log_level(const QString& param);
QString set_enable_tor(const QString& param);
// QString dump_all_offers();
QString webkit_launched_script();
QString get_smart_wallet_info(const QString& param);
@ -179,6 +182,9 @@ public:
QString is_remnotenode_mode_preconfigured();
QString start_backend(const QString& params);
QString async_call(const QString& func_name, const QString& params);
QString sync_call(const QString& func_name, const QString& params);
//for test purposes onlys
QString request_dummy();
@ -192,11 +198,11 @@ signals:
void wallet_sync_progress(const QString str);
void handle_internal_callback(const QString str, const QString callback_name);
void update_pos_mining_text(const QString str);
void do_dispatch(const QString status, const QString params); //general function
void on_core_event(const QString method_name); //general function
void set_options(const QString str); //general function
void get_wallet_name();
void handle_deeplink_click(const QString str);
void handle_current_action_state(const QString str);
void dispatch_async_call_result(const QString id, const QString resp); //general function
private:
//-------------------- i_core_event_handler --------------------
@ -216,6 +222,7 @@ private:
virtual bool init(const std::string& path);
virtual bool pos_block_found(const currency::block& block_found);
virtual bool set_options(const view::gui_options& opt);
virtual bool update_tor_status(const view::current_action_status& opt);
//--------- QAbstractNativeEventFilter ---------------------------
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
//----------------------------------------------
@ -257,6 +264,8 @@ private:
std::atomic<bool> m_gui_deinitialize_done_1;
std::atomic<bool> m_backend_stopped_2;
std::atomic<bool> m_system_shutdown;
std::atomic<uint64_t> m_ui_dispatch_id_counter;
utils::threads_pool m_threads_pool;
std::string m_master_password;

View file

@ -705,7 +705,7 @@ namespace currency
}
NOTIFY_NEW_TRANSACTIONS::request r;
NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request r;
r.txs.push_back(tx_blob);
m_core.get_protocol()->relay_transactions(r, fake_context);
//TODO: make sure that tx has reached other nodes here, probably wait to receive reflections from other nodes
@ -716,7 +716,7 @@ namespace currency
bool core_rpc_server::on_force_relaey_raw_txs(const COMMAND_RPC_FORCE_RELAY_RAW_TXS::request& req, COMMAND_RPC_FORCE_RELAY_RAW_TXS::response& res, connection_context& cntx)
{
CHECK_CORE_READY();
NOTIFY_NEW_TRANSACTIONS::request r = AUTO_VAL_INIT(r);
NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request r = AUTO_VAL_INIT(r);
for (const auto& t : req.txs_as_hex)
{

View file

@ -56,6 +56,7 @@ namespace
const command_line::arg_descriptor<bool> arg_offline_mode = { "offline-mode", "Don't connect to daemon, work offline (for cold-signing process)", false, true };
const command_line::arg_descriptor<std::string> arg_scan_for_wallet = { "scan-for-wallet", "", "", true };
const command_line::arg_descriptor<std::string> arg_addr_to_compare = { "addr-to-compare", "", "", true };
const command_line::arg_descriptor<bool> arg_disable_tor_relay = { "disable-tor-relay", "Do PoS mining", false, false };
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
@ -124,17 +125,9 @@ namespace
m_flush = false;
LOG_PRINT(m_oss.str(), m_log_level)
if (epee::log_space::console_color_default == m_color)
{
std::cout << m_oss.str();
}
else
{
epee::log_space::set_console_color(m_color, m_bright);
std::cout << m_oss.str();
epee::log_space::reset_console_color();
}
epee::log_space::set_console_color(m_color, m_bright);
std::cout << m_oss.str();
epee::log_space::reset_console_color();
std::cout << std::endl;
}
@ -230,6 +223,8 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this,ph::_1), "sign_transfer <unsgined_tx_file> <signed_tx_file> - sign unsigned tx from a watch-only wallet");
m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this,ph::_1), "submit_transfer <signed_tx_file> - broadcast signed tx");
m_cmd_binder.set_handler("export_history", boost::bind(&simple_wallet::submit_transfer, this,ph::_1), "Export transaction history in CSV file");
m_cmd_binder.set_handler("tor_enable", boost::bind(&simple_wallet::tor_enable, this, _1), "Enable relaying transactions over TOR network(enabled by default)");
m_cmd_binder.set_handler("tor_disable", boost::bind(&simple_wallet::tor_disable, this, _1), "Enable relaying transactions over TOR network(enabled by default)");
}
//----------------------------------------------------------------------------------------------------
simple_wallet::~simple_wallet()
@ -362,6 +357,11 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
bool r = open_wallet(m_wallet_file, pwd_container.password());
CHECK_AND_ASSERT_MES(r, false, "could not open account");
}
if (m_disable_tor)
{
m_wallet->set_disable_tor_relay(true);
message_writer(epee::log_space::console_color_default, true, std::string(), LOG_LEVEL_0) << "Notice: Relaying transactions over TOR disabled with command line parameter";
}
return true;
}
@ -385,6 +385,7 @@ void simple_wallet::handle_command_line(const boost::program_options::variables_
m_do_not_set_date = command_line::get_arg(vm, arg_dont_set_date);
m_do_pos_mining = command_line::get_arg(vm, arg_do_pos_mining);
m_restore_wallet = command_line::get_arg(vm, arg_restore_wallet);
m_disable_tor = command_line::get_arg(vm, arg_disable_tor_relay);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::try_connect_to_daemon()
@ -659,6 +660,34 @@ void simple_wallet::on_message(i_wallet2_callback::message_severity severity, co
message_writer(color, true, std::string()) << m;
}
//----------------------------------------------------------------------------------------------------
void simple_wallet::on_tor_status_change(const std::string& state)
{
std::string human_message;
if (state == TOR_LIB_STATE_INITIALIZING)
human_message = "Initializing...";
else if (state == TOR_LIB_STATE_DOWNLOADING_CONSENSUS)
human_message = "Downloading consensus...";
else if (state == TOR_LIB_STATE_MAKING_TUNNEL_A)
human_message = "Building tunnel to A...";
else if (state == TOR_LIB_STATE_MAKING_TUNNEL_B)
human_message = "Building tunnel to B...";
else if (state == TOR_LIB_STATE_CREATING_STREAM)
human_message = "Creating stream...";
else if (state == TOR_LIB_STATE_SUCCESS)
human_message = "Successfully created stream";
else if (state == TOR_LIB_STATE_FAILED)
human_message = "Failed created stream";
else if (state == WALLET_LIB_STATE_SENDING)
human_message = "Sending transaction...";
else if (state == WALLET_LIB_SENT_SUCCESS)
human_message = "Successfully sent!";
else if (state == WALLET_LIB_SEND_FAILED)
human_message = "Sending failed";
message_writer(epee::log_space::console_color_yellow, true, std::string("[TOR]: ")) << human_message;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::refresh(const std::vector<std::string>& args)
{
if (m_offline_mode)
@ -1711,6 +1740,21 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args)
}
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::tor_enable(const std::vector<std::string> &args)
{
success_msg_writer(true) << "TOR relaying enabled";
m_wallet->set_disable_tor_relay(false);
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::tor_disable(const std::vector<std::string> &args)
{
m_wallet->set_disable_tor_relay(true);
success_msg_writer(true) << "TOR relaying disabled";
return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::sweep_below(const std::vector<std::string> &args)
{
@ -1961,6 +2005,8 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_params, command_line::arg_log_level);
command_line::add_arg(desc_params, arg_scan_for_wallet);
command_line::add_arg(desc_params, arg_addr_to_compare);
command_line::add_arg(desc_params, arg_disable_tor_relay);
tools::wallet_rpc_server::init_options(desc_params);
@ -2155,6 +2201,13 @@ int main(int argc, char* argv[])
}
else // if(command_line::has_arg(vm, tools::wallet_rpc_server::arg_rpc_bind_port))
{
if (command_line::get_arg(vm, arg_do_pos_mining))
{
// PoS mining can be turned on only in RPC server mode, please provide --rpc-bind-port to make this
fail_msg_writer() << "PoS mining can be turned on only in RPC server mode, please provide --rpc-bind-port=PORT_NO to enable staking in simplewallet";
return EXIT_FAILURE;
}
//runs wallet with console interface
sw->set_offline_mode(offline_mode);
r = sw->init(vm);

View file

@ -86,6 +86,8 @@ namespace currency
bool sign_transfer(const std::vector<std::string> &args);
bool submit_transfer(const std::vector<std::string> &args);
bool sweep_below(const std::vector<std::string> &args);
bool tor_enable(const std::vector<std::string> &args);
bool tor_disable(const std::vector<std::string> &args);
bool validate_wrap_status(uint64_t amount);
bool get_alias_from_daemon(const std::string& alias_name, currency::extra_alias_entry_base& ai);
@ -98,6 +100,7 @@ namespace currency
virtual void on_new_block(uint64_t height, const currency::block& block) override;
virtual void on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) override;
virtual void on_message(i_wallet2_callback::message_severity severity, const std::string& m) override;
virtual void on_tor_status_change(const std::string& state) override;
//----------------------------------------------------------
@ -166,6 +169,7 @@ namespace currency
bool m_do_not_set_date;
bool m_do_pos_mining;
bool m_offline_mode;
bool m_disable_tor;
std::string m_restore_wallet;
epee::console_handlers_binder m_cmd_binder;

View file

@ -600,6 +600,18 @@ public:
END_KV_SERIALIZE_MAP()
};
struct current_action_status
{
uint64_t wallet_id;
std::string status;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(wallet_id)
KV_SERIALIZE(status)
END_KV_SERIALIZE_MAP()
};
struct wallet_sync_status_info
{
bool is_daemon_connected;
@ -828,6 +840,7 @@ public:
virtual bool pos_block_found(const currency::block& block_found){ return true; }
virtual bool money_transfer_cancel(const transfer_event_info& wsi){ return true; }
virtual bool set_options(const gui_options& opt){ return true; }
virtual bool update_tor_status(const current_action_status & opt) { return true; }
};
}

View file

@ -13,6 +13,7 @@
#include <iostream>
#include <boost/utility/value_init.hpp>
#include "include_base_utils.h"
#include "net/levin_client.h"
using namespace epee;
#include "string_coding.h"
@ -30,8 +31,16 @@ using namespace epee;
#include "version.h"
#include "common/encryption_filter.h"
#include "crypto/bitcoin/sha256_helper.h"
#ifndef DISABLE_TOR
#include "common/tor_helper.h"
#endif
#include "storages/levin_abstract_invoke2.h"
using namespace currency;
#define MINIMUM_REQUIRED_WALLET_FREE_SPACE_BYTES (100*1024*1024) // 100 MB
#undef LOG_DEFAULT_CHANNEL
@ -53,7 +62,8 @@ namespace tools
m_minimum_height(WALLET_MINIMUM_HEIGHT_UNSET_CONST),
m_pos_mint_packing_size(WALLET_DEFAULT_POS_MINT_PACKING_SIZE),
m_current_wallet_file_size(0),
m_use_deffered_global_outputs(false)
m_use_deffered_global_outputs(false),
m_disable_tor_relay(false)
{
m_core_runtime_config = currency::get_default_core_runtime_config();
}
@ -4582,22 +4592,76 @@ uint64_t wallet2::get_needed_money(uint64_t fee, const std::vector<currency::tx_
}
return needed_money;
}
//----------------------------------------------------------------------------------------------------------------
void wallet2::set_disable_tor_relay(bool disable)
{
m_disable_tor_relay = disable;
}
//----------------------------------------------------------------------------------------------------------------
void wallet2::notify_state_change(const std::string& state_code, const std::string& details)
{
m_wcallback->on_tor_status_change(state_code);
}
//----------------------------------------------------------------------------------------------------------------
void wallet2::send_transaction_to_network(const transaction& tx)
{
COMMAND_RPC_SEND_RAW_TX::request req;
req.tx_as_hex = epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(tx));
COMMAND_RPC_SEND_RAW_TX::response daemon_send_resp;
bool r = m_core_proxy->call_COMMAND_RPC_SEND_RAW_TX(req, daemon_send_resp);
THROW_IF_TRUE_WALLET_EX(!r, error::no_connection_to_daemon, "sendrawtransaction");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status == API_RETURN_CODE_BUSY, error::daemon_busy, "sendrawtransaction");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status == API_RETURN_CODE_DISCONNECTED, error::no_connection_to_daemon, "Transfer attempt while daemon offline");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status != API_RETURN_CODE_OK, error::tx_rejected, tx, daemon_send_resp.status);
#ifndef DISABLE_TOR
if (!m_disable_tor_relay)
{
//TODO check that core synchronized
//epee::net_utils::levin_client2 p2p_client;
//make few attempts
tools::levin_over_tor_client p2p_client;
p2p_client.get_transport().set_notifier(this);
bool succeseful_sent = false;
for (size_t i = 0; i != 3; i++)
{
if (!p2p_client.connect("144.76.183.143", 2121, 10000))
{
continue;//THROW_IF_FALSE_WALLET_EX(false, error::no_connection_to_daemon, "Failed to connect to TOR node");
}
currency::NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request p2p_req = AUTO_VAL_INIT(p2p_req);
currency::NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::response p2p_rsp = AUTO_VAL_INIT(p2p_rsp);
p2p_req.txs.push_back(t_serializable_object_to_blob(tx));
this->notify_state_change(WALLET_LIB_STATE_SENDING);
epee::net_utils::invoke_remote_command2(NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::ID, p2p_req, p2p_rsp, p2p_client);
p2p_client.disconnect();
if (p2p_rsp.code == API_RETURN_CODE_OK)
{
this->notify_state_change(WALLET_LIB_SENT_SUCCESS);
succeseful_sent = true;
break;
}
this->notify_state_change(WALLET_LIB_SEND_FAILED);
//checking if transaction got relayed to other nodes and
//return;
}
if (!succeseful_sent)
{
this->notify_state_change(WALLET_LIB_SEND_FAILED);
THROW_IF_FALSE_WALLET_EX(succeseful_sent, error::no_connection_to_daemon, "Faile to build TOR stream");
}
}
else
#endif //
{
COMMAND_RPC_SEND_RAW_TX::request req;
req.tx_as_hex = epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(tx));
COMMAND_RPC_SEND_RAW_TX::response daemon_send_resp;
bool r = m_core_proxy->call_COMMAND_RPC_SEND_RAW_TX(req, daemon_send_resp);
THROW_IF_TRUE_WALLET_EX(!r, error::no_connection_to_daemon, "sendrawtransaction");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status == API_RETURN_CODE_BUSY, error::daemon_busy, "sendrawtransaction");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status == API_RETURN_CODE_DISCONNECTED, error::no_connection_to_daemon, "Transfer attempt while daemon offline");
THROW_IF_TRUE_WALLET_EX(daemon_send_resp.status != API_RETURN_CODE_OK, error::tx_rejected, tx, daemon_send_resp.status);
WLT_LOG_L2("transaction " << get_transaction_hash(tx) << " generated ok and sent to daemon:" << ENDL << currency::obj_to_json_str(tx));
}
WLT_LOG_L2("transaction " << get_transaction_hash(tx) << " generated ok and sent to daemon:" << ENDL << currency::obj_to_json_str(tx));
}
//----------------------------------------------------------------------------------------------------------------
void wallet2::add_sent_tx_detailed_info(const transaction& tx,
const std::vector<currency::tx_destination_entry>& destinations,
const std::vector<uint64_t>& selected_transfers)

View file

@ -41,6 +41,7 @@
#include "currency_core/bc_escrow_service.h"
#include "common/pod_array_file_container.h"
#include "wallet_chain_shortener.h"
#include "tor-connect/torlib/tor_lib_iface.h"
#define WALLET_DEFAULT_TX_SPENDABLE_AGE 10
@ -121,6 +122,7 @@ namespace tools
virtual void on_sync_progress(const uint64_t& /*percents*/) {}
virtual void on_transfer_canceled(const wallet_public::wallet_transfer_info& wti) {}
virtual void on_message(message_severity /*severity*/, const std::string& /*m*/) {}
virtual void on_tor_status_change(const std::string& state) {}
};
struct tx_dust_policy
@ -338,7 +340,7 @@ namespace tools
// END_SERIALIZE()
// };
class wallet2
class wallet2: public tools::tor::t_transport_state_notifier
{
wallet2(const wallet2&) = delete;
public:
@ -861,6 +863,7 @@ namespace tools
uint64_t get_wallet_file_size()const;
void set_use_deffered_global_outputs(bool use);
construct_tx_param get_default_construct_tx_param_inital();
void set_disable_tor_relay(bool disable);
void export_transaction_history(std::ostream& ss, const std::string& format, bool include_pos_transactions = true);
@ -876,6 +879,11 @@ namespace tools
bool check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& origin, crypto::hash& redeem_tx_id);
private:
// -------- t_transport_state_notifier ------------------------------------------------
virtual void notify_state_change(const std::string& state_code, const std::string& details = std::string());
// ------------------------------------------------------------------------------------
void add_transfers_to_expiration_list(const std::vector<uint64_t>& selected_transfers, uint64_t expiration, uint64_t change_amount, const crypto::hash& related_tx_id);
void remove_transfer_from_expiration_list(uint64_t transfer_index);
void load_keys(const std::string& keys_file_name, const std::string& password, uint64_t file_signature, keys_file_data& kf_data);
@ -1060,6 +1068,7 @@ private:
mutable uint64_t m_current_wallet_file_size;
bool m_use_deffered_global_outputs;
bool m_disable_tor_relay;
//this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions
friend class test_generator;

View file

@ -16,6 +16,12 @@
// TODO: get rid of all these types, leave only wallet_error with a string message and string/enum error designator
#define WALLET_LIB_STATE_SENDING "STATE_SENDING"
#define WALLET_LIB_SENT_SUCCESS "STATE_SENT_SUCCESS"
#define WALLET_LIB_SEND_FAILED "STATE_SEND_FAILED"
namespace tools
{
namespace error

View file

@ -16,6 +16,7 @@ public:
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/) {}
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/) {}
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti) {}
virtual void on_tor_status_change(size_t wallet_id, const std::string& state) {}
};
struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
@ -39,6 +40,11 @@ struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
virtual void on_transfer_canceled(const tools::wallet_public::wallet_transfer_info& wti) {
m_pbackend->on_transfer_canceled(m_wallet_id, wti);
}
virtual void on_tor_status_change(const std::string& state)
{
m_pbackend->on_tor_status_change(m_wallet_id, state);
}
private:
i_backend_wallet_callback* m_pbackend;
size_t m_wallet_id;

View file

@ -81,7 +81,8 @@ wallets_manager::wallets_manager():m_pview(&m_view_stub),
m_is_pos_allowed(false),
m_qt_logs_enbaled(false),
m_dont_save_wallet_at_stop(false),
m_use_deffered_global_outputs(false)
m_use_deffered_global_outputs(false),
m_use_tor(true)
{
#ifndef MOBILE_WALLET_BUILD
m_offers_service.set_disabled(true);
@ -162,17 +163,17 @@ bool wallets_manager::init_command_line(int argc, char* argv[], std::string& fai
command_line::add_arg(desc_cmd_only, command_line::arg_version);
command_line::add_arg(desc_cmd_only, command_line::arg_os_version);
// tools::get_default_data_dir() can't be called during static initialization
command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, tools::get_default_data_dir());
command_line::add_arg(desc_cmd_sett, command_line::arg_data_dir, tools::get_default_data_dir());
command_line::add_arg(desc_cmd_only, command_line::arg_stop_after_height);
command_line::add_arg(desc_cmd_only, command_line::arg_config_file);
command_line::add_arg(desc_cmd_sett, command_line::arg_log_dir);
command_line::add_arg(desc_cmd_sett, command_line::arg_log_level);
command_line::add_arg(desc_cmd_sett, command_line::arg_console);
command_line::add_arg(desc_cmd_sett, command_line::arg_show_details);
command_line::add_arg(desc_cmd_only, command_line::arg_show_details);
command_line::add_arg(desc_cmd_sett, arg_alloc_win_console);
command_line::add_arg(desc_cmd_sett, arg_html_folder);
command_line::add_arg(desc_cmd_sett, arg_xcode_stub);
command_line::add_arg(desc_cmd_only, arg_xcode_stub);
command_line::add_arg(desc_cmd_sett, arg_enable_gui_debug_mode);
command_line::add_arg(desc_cmd_sett, arg_qt_remote_debugging_port);
command_line::add_arg(desc_cmd_sett, arg_remote_node);
@ -183,7 +184,7 @@ bool wallets_manager::init_command_line(int argc, char* argv[], std::string& fai
command_line::add_arg(desc_cmd_sett, command_line::arg_force_predownload);
command_line::add_arg(desc_cmd_sett, command_line::arg_validate_predownload);
command_line::add_arg(desc_cmd_sett, command_line::arg_predownload_link);
command_line::add_arg(desc_cmd_sett, command_line::arg_deeplink);
command_line::add_arg(desc_cmd_only, command_line::arg_deeplink);
command_line::add_arg(desc_cmd_sett, command_line::arg_disable_ntp);
@ -791,6 +792,8 @@ void wallets_manager::init_wallet_entry(wallet_vs_options& wo, uint64_t id)
m_wallet_log_prefixes.resize(id + 1);
m_wallet_log_prefixes[id] = std::string("[") + epee::string_tools::num_to_string_fast(id) + ":" + wo.w->get()->get_account().get_public_address_str().substr(0, 6) + "] ";
}
wo.w->get()->set_disable_tor_relay(!m_use_tor);
}
@ -1842,6 +1845,17 @@ void wallets_manager::on_pos_block_found(size_t wallet_id, const currency::block
{
m_pview->pos_block_found(b);
}
bool wallets_manager::set_use_tor(bool use_tor)
{
m_use_tor = use_tor;
SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock);
for (auto& w : m_wallets)
{
w.second.w->get()->set_disable_tor_relay(!m_use_tor);
}
return true;
}
void wallets_manager::on_sync_progress(size_t wallet_id, const uint64_t& percents)
{
// do not lock m_wallets_lock down the callstack! It will lead to a deadlock, because wallet locked_object is aready locked
@ -1871,6 +1885,13 @@ void wallets_manager::on_transfer_canceled(size_t wallet_id, const tools::wallet
}
m_pview->money_transfer_cancel(tei);
}
void wallets_manager::on_tor_status_change(size_t wallet_id, const std::string& state)
{
view::current_action_status tsu = { wallet_id , state };
m_pview->update_tor_status(tsu);
}
void wallets_manager::wallet_vs_options::worker_func()
{
LOG_PRINT_GREEN("[WALLET_HANDLER] Wallet handler thread started, addr: " << w->get()->get_account().get_public_address_str(), LOG_LEVEL_0);

View file

@ -163,7 +163,7 @@ public:
bool is_qt_logs_enabled() const { return m_qt_logs_enbaled; }
std::string get_qt_dev_tools_option() const { return m_qt_dev_tools; }
void set_use_deffered_global_outputs(bool use) { m_use_deffered_global_outputs = use; }
bool set_use_tor(bool use_tor);
private:
void main_worker(const po::variables_map& vm);
bool init_local_daemon();
@ -187,6 +187,8 @@ private:
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/);
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/);
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti);
virtual void on_tor_status_change(size_t wallet_id, const std::string& state);
std::thread m_main_worker_thread;
@ -224,6 +226,7 @@ private:
bool m_qt_logs_enbaled;
std::string m_qt_dev_tools;
std::atomic<bool> m_is_pos_allowed;
std::atomic<bool> m_use_tor;
std::map<size_t, wallet_vs_options> m_wallets;

View file

@ -51,7 +51,7 @@ public:
//----------------- i_currency_protocol ---------------------------------------
virtual bool relay_block(currency::NOTIFY_NEW_BLOCK::request& /*arg*/, currency::currency_connection_context& /*exclude_context*/) override { return false; }
virtual bool relay_transactions(currency::NOTIFY_NEW_TRANSACTIONS::request& arg, currency::currency_connection_context& /*exclude_context*/) override
virtual bool relay_transactions(currency::NOTIFY_OR_INVOKE_NEW_TRANSACTIONS::request& arg, currency::currency_connection_context& /*exclude_context*/) override
{
if (m_core_listener)
{

View file

@ -3,16 +3,19 @@
# Environment prerequisites:
# 1) QT_PREFIX_PATH should be set to Qt libs folder
# 2) BOOST_ROOT should be set to the root of Boost
# 3) OPENSSL_ROOT_DIR should be set to the root of OpenSSL
#
# for example, place these lines to the end of your ~/.bashrc :
#
# export BOOST_ROOT=/home/user/boost_1_66_0
# export QT_PREFIX_PATH=/home/user/Qt5.10.1/5.10.1/gcc_64
# export OPENSSL_ROOT_DIR=/home/user/openssl
ARCHIVE_NAME_PREFIX=zano-linux-x64-
: "${BOOST_ROOT:?BOOST_ROOT should be set to the root of Boost, ex.: /home/user/boost_1_66_0}"
: "${QT_PREFIX_PATH:?QT_PREFIX_PATH should be set to Qt libs folder, ex.: /home/user/Qt5.10.1/5.10.1/gcc_64}"
: "${OPENSSL_ROOT_DIR:?OPENSSL_ROOT_DIR should be set to OpenSSL root folder, ex.: /home/user/openssl}"
if [ -n "$build_prefix" ]; then
ARCHIVE_NAME_PREFIX=${ARCHIVE_NAME_PREFIX}${build_prefix}-
@ -40,7 +43,7 @@ echo "--------------------------------------------------"
echo "Building...."
rm -rf build; mkdir -p build/release; cd build/release;
cmake $testnet_def -D STATIC=true -D ARCH=x86-64 -D BUILD_GUI=TRUE -D CMAKE_PREFIX_PATH="$QT_PREFIX_PATH" -D CMAKE_BUILD_TYPE=Release ../..
cmake $testnet_def -D STATIC=true -D ARCH=x86-64 -D BUILD_GUI=TRUE -D OPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" -D CMAKE_PREFIX_PATH="$QT_PREFIX_PATH" -D CMAKE_BUILD_TYPE=Release ../..
if [ $? -ne 0 ]; then
echo "Failed to run cmake"
exit 1

View file

@ -8,6 +8,7 @@ curr_path=${BASH_SOURCE%/*}
: "${ZANO_BOOST_LIBS_PATH:?variable not set, see also macosx_build_config.command}"
: "${ZANO_BUILD_DIR:?variable not set, see also macosx_build_config.command}"
: "${CMAKE_OSX_SYSROOT:?CMAKE_OSX_SYSROOT should be set to macOS SDK path, e.g.: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk}"
: "${OPENSSL_ROOT_DIR:?variable not set, see also macosx_build_config.command}"
ARCHIVE_NAME_PREFIX=zano-macos-x64-
@ -30,7 +31,7 @@ fi
rm -rf $ZANO_BUILD_DIR; mkdir -p "$ZANO_BUILD_DIR/release"; cd "$ZANO_BUILD_DIR/release"
cmake $testnet_def -D CMAKE_OSX_SYSROOT=$CMAKE_OSX_SYSROOT -D BUILD_GUI=TRUE -D CMAKE_PREFIX_PATH="$ZANO_QT_PATH/clang_64" -D CMAKE_BUILD_TYPE=Release -D BOOST_ROOT="$ZANO_BOOST_ROOT" -D BOOST_LIBRARYDIR="$ZANO_BOOST_LIBS_PATH" ../..
cmake $testnet_def -D OPENSSL_ROOT_DIR=$OPENSSL_ROOT_DIR -D CMAKE_OSX_SYSROOT=$CMAKE_OSX_SYSROOT -D BUILD_GUI=TRUE -D CMAKE_PREFIX_PATH="$ZANO_QT_PATH/clang_64" -D CMAKE_BUILD_TYPE=Release -D BOOST_ROOT="$ZANO_BOOST_ROOT" -D BOOST_LIBRARYDIR="$ZANO_BOOST_LIBS_PATH" ../..
if [ $? -ne 0 ]; then
echo "Failed to cmake"
exit 1

View file

@ -1,10 +1,10 @@
SET QT_PREFIX_PATH=C:\dev\_sdk\Qt5.11.2\5.11.2\msvc2017_64
SET INNOSETUP_PATH=C:\Program Files (x86)\Inno Setup 5\ISCC.exe
SET ETC_BINARIES_PATH=C:\dev\deploy\etc-binaries
SET BUILDS_PATH=C:\dev\deploy\zano
call configure_local_paths.cmd
;; MSVC version-specific paths
SET LOCAL_BOOST_LIB_PATH=%LOCAL_BOOST_PATH%\lib64-msvc-14.1
SET QT_MSVC_PATH=%QT_PREFIX_PATH%\msvc2017_64
SET ACHIVE_NAME_PREFIX=zano-win-x64-
SET LOCAL_BOOST_PATH=C:\dev\_sdk\boost_1_68_0
SET LOCAL_BOOST_LIB_PATH=C:\dev\_sdk\boost_1_68_0\lib64-msvc-14.1
SET MY_PATH=%~dp0
SET SOURCES_PATH=%MY_PATH:~0,-7%
@ -44,7 +44,7 @@ cd %SOURCES_PATH%
rmdir build /s /q
mkdir build
cd build
cmake %TESTNET_DEF% -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%" -D BUILD_GUI=TRUE -D STATIC=FALSE -G "Visual Studio 15 2017 Win64" -T host=x64 ..
cmake %TESTNET_DEF% -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_MSVC_PATH%" -D BUILD_GUI=TRUE -D STATIC=FALSE -G "Visual Studio 15 2017 Win64" -T host=x64 ..
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@ -108,7 +108,7 @@ copy /Y zanod.exe bunch
copy /Y simplewallet.exe bunch
copy /Y *.pdb bunch
%QT_PREFIX_PATH%\bin\windeployqt.exe bunch\Zano.exe
%QT_MSVC_PATH%\bin\windeployqt.exe bunch\Zano.exe
cd bunch

View file

@ -1,184 +0,0 @@
SET QT32_PREFIX_PATH=C:\Qt\Qt5.9.1\5.9.1\msvc2015
SET INNOSETUP_PATH=C:\Program Files (x86)\Inno Setup 5\ISCC.exe
SET ETC32_BINARIES_PATH=C:\home\deploy\etc-binaries-32
SET BUILDS_PATH=C:\home\deploy\zano
SET ACHIVE_NAME_PREFIX=zano-win-x32-webengine-
SET SOURCES_PATH=C:\home\deploy\zano\src
SET LOCAL_BOOST_PATH_32=C:\local\boost_1_62_0
SET LOCAL_BOOST_LIB_PATH_32=C:\local\boost_1_62_0\lib32-msvc-14.0
@echo on
set BOOST_ROOT=%LOCAL_BOOST_PATH_32%
set BOOST_LIBRARYDIR=%LOCAL_BOOST_LIB_PATH_32%
@echo "---------------- PREPARING BINARIES ---------------------------"
@echo "---------------------------------------------------------------"
cd %SOURCES_PATH%
git pull
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@echo "---------------- BUILDING APPLICATIONS ------------------------"
@echo "---------------------------------------------------------------"
rmdir build /s /q
mkdir build
cd build
cmake -D CMAKE_PREFIX_PATH="%QT32_PREFIX_PATH%" -D BUILD_GUI=TRUE -D STATIC=FALSE -G "Visual Studio 14" ..
IF %ERRORLEVEL% NEQ 0 (
goto error
)
setLocal
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
msbuild version.vcxproj /p:Configuration=Release /t:Build
IF %ERRORLEVEL% NEQ 0 (
goto error
)
msbuild src/daemon.vcxproj /p:Configuration=Release /t:Build
IF %ERRORLEVEL% NEQ 0 (
goto error
)
msbuild src/simplewallet.vcxproj /p:Configuration=Release /t:Build
IF %ERRORLEVEL% NEQ 0 (
goto error
)
msbuild src/zano.vcxproj /p:Configuration=Release /t:Build
IF %ERRORLEVEL% NEQ 0 (
goto error
)
endlocal
@echo on
echo "sources are built"
cd %SOURCES_PATH%/build
set cmd=src\Release\simplewallet.exe --version
FOR /F "tokens=3" %%a IN ('%cmd%') DO set version=%%a
set version=%version:~0,-2%
echo '%version%'
cd src\release
@echo on
mkdir bunch
copy /Y zano.exe bunch
copy /Y zanod.exe bunch
copy /Y simplewallet.exe bunch
copy /Y zano.exe bunch
%QT32_PREFIX_PATH%\bin\windeployqt.exe bunch\Zano.exe
cd bunch
zip -r %BUILDS_PATH%\builds\%ACHIVE_NAME_PREFIX%%version%.zip *.*
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@echo "Add html"
cd %SOURCES_PATH%\src\gui\qt-daemon\
zip -r %BUILDS_PATH%\builds\%ACHIVE_NAME_PREFIX%%version%.zip html
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@echo "Add runtime stuff"
cd %ETC32_BINARIES_PATH%
zip -r %BUILDS_PATH%\builds\%ACHIVE_NAME_PREFIX%%version%.zip *.*
IF %ERRORLEVEL% NEQ 0 (
goto error
)
cd %SOURCES_PATH%\build
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@echo "---------------------------------------------------------------"
@echo "-------------------Building installer--------------------------"
@echo "---------------------------------------------------------------"
mkdir installer_src
unzip %BUILDS_PATH%\builds\%ACHIVE_NAME_PREFIX%%version%.zip -d installer_src
IF %ERRORLEVEL% NEQ 0 (
goto error
)
"%INNOSETUP_PATH%" /dBinariesPath=../build/installer_src /DMyAppVersion=%version% /o%BUILDS_PATH%\builds\ /f%ACHIVE_NAME_PREFIX%%version%-installer ..\utils\setup_32.iss
IF %ERRORLEVEL% NEQ 0 (
goto error
)
@echo "---------------------------------------------------------------"
@echo "---------------------------------------------------------------"
@echo " UPLOADING TO SERVER ...."
pscp -i C:\Users\Administrator\.ssh\putty.ppk %BUILDS_PATH%\builds\%ACHIVE_NAME_PREFIX%%version%-installer.exe root@95.216.11.16:/usr/share/nginx/html/%ACHIVE_NAME_PREFIX%%version%-installer.exe
IF %ERRORLEVEL% NEQ 0 (
@echo "FAILED TO UPLOAD TO SERVER"
goto error
)
echo "New build available at loaction: http://95.216.11.16/%ACHIVE_NAME_PREFIX%%version%-installer.exe"
goto success
:error
echo "BUILD FAILED"
exit /B %ERRORLEVEL%
:success
echo "BUILD SUCCESS"
cd ..

View file

@ -1,24 +0,0 @@
call utils/build_script_windows.bat
IF %ERRORLEVEL% NEQ 0 (
@echo "FAILED TO build_script_windows.bat"
goto error
)
call utils/build_script_windows32.bat
IF %ERRORLEVEL% NEQ 0 (
@echo "FAILED TO build_script_windows32.bat"
goto error
)
goto success
:error
echo "BUILD FAILED"
exit /B %ERRORLEVEL%
:success
echo "BUILD SUCCESS"

View file

@ -5,4 +5,9 @@ rem Rename to configure_local_paths.cmd and do not commit.
rem
set QT_PREFIX_PATH=C:\dev\_sdk\Qt5.11.2\5.11.2
set BOOST_ROOT=C:\dev\_sdk\boost_1_66_0
set INNOSETUP_PATH=C:\Program Files (x86)\Inno Setup 5\ISCC.exe
set ETC_BINARIES_PATH=C:\dev\deploy\etc-binaries
set BUILDS_PATH=C:\dev\deploy\zano
set LOCAL_BOOST_PATH=C:\dev\_sdk\boost_1_70_0
set OPENSSL_ROOT_DIR=C:\dev\_sdk\OpenSSL-Win64
set BOOST_ROOT=%LOCAL_BOOST_PATH%

View file

@ -6,3 +6,4 @@ rem
set QT_PREFIX_PATH=C:\dev\_sdk\Qt5.15.2\5.15.2
set BOOST_ROOT=C:\dev\_sdk\boost_1_76_0
set OPENSSL_ROOT_DIR=C:\dev\_sdk\OpenSSL-Win64

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2015_32
cd build_msvc2015_32
cmake -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib32-msvc-14.0" -G "Visual Studio 14 2015" ".."
cmake -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib32-msvc-14.0" -G "Visual Studio 14 2015" ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2013_64
cd build_msvc2013_64
cmake -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2013_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-12.0" -G "Visual Studio 12 2013 Win64" ".."
cmake -D BUILD_TESTS=TRUE -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2013_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-12.0" -G "Visual Studio 12 2013 Win64" ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2015_64
cd build_msvc2015_64
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.0" -G "Visual Studio 14 2015 Win64" -T host=x64 ".."
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2015_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.0" -G "Visual Studio 14 2015 Win64" -T host=x64 ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2017_64
cd build_msvc2017_64
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."
cmake -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2017_64_tn
cd build_msvc2017_64_tn
cmake -D TESTNET=TRUE -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."
cmake -D TESTNET=TRUE -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2017_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -T host=x64 ".."

View file

@ -4,4 +4,4 @@ cd ..
@mkdir build_msvc2019_64_tn
cd build_msvc2019_64_tn
cmake -D TESTNET=TRUE -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2019_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.2" -G "Visual Studio 16 2019" -A x64 -T host=x64 ".."
cmake -D TESTNET=TRUE -D USE_PCH=TRUE -D BUILD_TESTS=TRUE -D OPENSSL_ROOT_DIR="%OPENSSL_ROOT_DIR%" -D CMAKE_PREFIX_PATH="%QT_PREFIX_PATH%"\msvc2019_64 -D BUILD_GUI=TRUE -D STATIC=FALSE -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_ROOT%\lib64-msvc-14.2" -G "Visual Studio 16 2019" -A x64 -T host=x64 ".."

View file

@ -9,3 +9,4 @@ export ZANO_QT_PATH="/Users/roky/Qt5.6.0/5.6"
export ZANO_BOOST_ROOT="/Users/roky/boost_1_60_0"
export ZANO_BOOST_LIBS_PATH="$ZANO_BOOST_ROOT/stage/lib"
export ZANO_BUILD_DIR="build_mac_osx_64"
export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"