From a8f1e99424c43726006b20bf15c98bea82c440eb Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 9 Jan 2020 02:25:46 +0100 Subject: [PATCH 01/28] shortent mobile version libraries --- src/CMakeLists.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 630a41c0..8766375a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,7 @@ - +if(CMAKE_SYSTEM_NAME STREQL iOS) +{ + return() +} if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() @@ -99,10 +102,19 @@ endif() add_library(crypto ${CRYPTO}) +add_library(wallet ${WALLET}) +add_dependencies(wallet version ${PCH_LIB_NAME}) +ENABLE_SHARED_PCH(WALLET) + add_library(currency_core ${CURRENCY_CORE}) add_dependencies(currency_core version rpc ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(CURRENCY_CORE) +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + message("Generating for iOS: finished") + return() +endif() + add_library(rpc ${RPC}) add_dependencies(rpc version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(RPC) @@ -111,9 +123,6 @@ add_library(stratum ${STRATUM}) add_dependencies(stratum version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(STRATUM) -add_library(wallet ${WALLET}) -add_dependencies(wallet version ${PCH_LIB_NAME}) -ENABLE_SHARED_PCH(WALLET) target_link_libraries(currency_core lmdb mdbx) From cab160112c94a4fc359efb237115fb43cb427ec2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 9 Jan 2020 17:06:02 +0100 Subject: [PATCH 02/28] inital preparation for mobile native library(very dirty) --- .gitignore | 1 + CMakeLists.txt | 18 ++++++++++------- contrib/CMakeLists.txt | 8 +++++++- contrib/db/CMakeLists.txt | 7 +++++++ contrib/zlib/CMakeLists.txt | 40 ++++++++++++++++++------------------- src/CMakeLists.txt | 7 ++----- 6 files changed, 48 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index bf6dbac1..c4630d95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /build* +/_builds/* /tags .DS_Store ._.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index 76b5f69b..0d9a5646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(VERSION "1.0") cmake_policy(SET CMP0020 OLD) endif() - +set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "Andrey Sabelnikov") set_property(GLOBAL PROPERTY USE_FOLDERS ON) # build types @@ -24,7 +24,7 @@ if (UNIX AND NOT APPLE) endif() else() # multi configurations for MSVC and XCode - set(CMAKE_CONFIGURATION_TYPES "Debug;Release") + set(CMAKE_CONFIGURATION_TYPES "Release") endif() message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}") @@ -78,7 +78,7 @@ else() else() set(ARCH_FLAG "-march=${ARCH}") endif() - set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-aggregate-return") + set(WARNINGS "-Wno-implicit-function-declaration -Wall -Wextra -Wpointer-arith -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-aggregate-return") # if(NOT APPLE) # set(WARNINGS "${WARNINGS} -Werror") # endif() @@ -161,10 +161,14 @@ if(STATIC) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) endif() -find_package(Boost 1.53 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) -if(MSVC AND (${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54)) - message(SEND_ERROR "Boost version 1.54 is unsupported, more details are available here http://goo.gl/RrCFmA") -endif() + + +#find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options ) #locale +set(Boost_INCLUDE_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/include") +set(Boost_LIBRARY_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/ios/") +set(Boost_LIBRARIES "libboost.a") +set(Boost_VERSION "ofxiOSBoost 1.60.0") + message(STATUS "Boost: ${Boost_VERSION} from ${Boost_LIBRARY_DIRS}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index df753f9a..86365e5a 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -1,12 +1,18 @@ set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library") set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library") set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables") -add_subdirectory(miniupnp/miniupnpc) add_subdirectory(zlib) add_subdirectory(db) add_subdirectory(ethereum) +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + message("excluded db support for IOS build") + return() +endif() +add_subdirectory(miniupnp/miniupnpc) + + set_property(TARGET libminiupnpc-static PROPERTY FOLDER "contrib") set_property(TARGET zlibstatic PROPERTY FOLDER "contrib") set_property(TARGET mdbx PROPERTY FOLDER "contrib") diff --git a/contrib/db/CMakeLists.txt b/contrib/db/CMakeLists.txt index 9497760e..ad19848c 100644 --- a/contrib/db/CMakeLists.txt +++ b/contrib/db/CMakeLists.txt @@ -1,4 +1,11 @@ + +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + message("excluded db support for IOS build") + return() +endif() + + message("DB ENGINE: lmdb") add_subdirectory(liblmdb) if(MSVC) diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index 0fe939df..696b9f52 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -183,10 +183,10 @@ if(MINGW) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) endif(MINGW) -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +#add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -set_target_properties(zlib PROPERTIES SOVERSION 1) +# set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +# set_target_properties(zlib PROPERTIES SOVERSION 1) if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -196,22 +196,22 @@ if(NOT CYGWIN) # # This has no effect with MSVC, on that platform the version info for # the DLL comes from the resource file win32/zlib1.rc - set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) +# set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) endif() if(UNIX) # On unix-like platforms the library is almost always called libz - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) + set_target_properties( zlibstatic PROPERTIES OUTPUT_NAME z) if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") + #set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") endif() elseif(BUILD_SHARED_LIBS AND WIN32) # Creates zlib1.dll when building shared library version - set_target_properties(zlib PROPERTIES SUFFIX "1.dll") + # set_target_properties(zlib PROPERTIES SUFFIX "1.dll") endif() if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) - install(TARGETS zlib zlibstatic + install(TARGETS zlibstatic RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) @@ -230,20 +230,20 @@ endif() # Example binaries #============================================================================ -add_executable(example test/example.c) -target_link_libraries(example zlib) -add_test(example example) +#add_executable(example test/example.c) +#target_link_libraries(example zlib) +#add_test(example example) -add_executable(minigzip test/minigzip.c) -target_link_libraries(minigzip zlib) +#add_executable(minigzip test/minigzip.c) +#target_link_libraries(minigzip zlib) if(HAVE_OFF64_T) - add_executable(example64 test/example.c) - target_link_libraries(example64 zlib) - set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") - add_test(example64 example64) +# add_executable(example64 test/example.c) +# target_link_libraries(example64 zlib) +# set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") +# add_test(example64 example64) - add_executable(minigzip64 test/minigzip.c) - target_link_libraries(minigzip64 zlib) - set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") +# add_executable(minigzip64 test/minigzip.c) +# target_link_libraries(minigzip64 zlib) +# set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8766375a..e6ea1362 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,4 @@ -if(CMAKE_SYSTEM_NAME STREQL iOS) -{ - return() -} + if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() @@ -107,7 +104,7 @@ add_dependencies(wallet version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(WALLET) add_library(currency_core ${CURRENCY_CORE}) -add_dependencies(currency_core version rpc ${PCH_LIB_NAME}) +add_dependencies(currency_core version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(CURRENCY_CORE) if(CMAKE_SYSTEM_NAME STREQUAL "iOS") From 41d4a9b0d39f29dbdb1d54050fcc8c0cc3812541 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 14 Jan 2020 23:27:05 +0100 Subject: [PATCH 03/28] added class drafts for plain wallet api for mobile app --- src/CMakeLists.txt | 5 ++++- src/currency_core/difficulty.cpp | 4 ++-- src/currency_core/tx_pool.cpp | 4 +--- src/currency_core/tx_pool.h | 1 - src/rpc/core_rpc_server.h | 1 - src/wallet/wallet_rpc_server.cpp | 4 ++-- src/wallet/wallet_rpc_server.h | 2 -- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6ea1362..eec8f613 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,7 @@ - +if(CMAKE_SYSTEM_NAME STREQL iOS) +{ + return() +} if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() diff --git a/src/currency_core/difficulty.cpp b/src/currency_core/difficulty.cpp index 18003b62..7e217c00 100644 --- a/src/currency_core/difficulty.cpp +++ b/src/currency_core/difficulty.cpp @@ -25,8 +25,8 @@ namespace currency { using std::vector; #if defined(_MSC_VER) -#include -#include +//#include +//#include static inline void mul(uint64_t a, uint64_t b, uint64_t &low, uint64_t &high) { boost::multiprecision::uint128_t res = boost::multiprecision::uint128_t(a) * b; diff --git a/src/currency_core/tx_pool.cpp b/src/currency_core/tx_pool.cpp index 09eb40b0..a506325c 100644 --- a/src/currency_core/tx_pool.cpp +++ b/src/currency_core/tx_pool.cpp @@ -1165,7 +1165,7 @@ namespace currency uint64_t cache_size_l1 = CACHE_SIZE; LOG_PRINT_GREEN("Using pool db file cache size(L1): " << cache_size_l1, LOG_LEVEL_0); - // remove old incompartible DB + // remove old incompatible DB const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_POOLDATA_FOLDERNAME_OLD; if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path))) { @@ -1192,8 +1192,6 @@ namespace currency res = m_db_transactions.init(TRANSACTION_POOL_CONTAINER_TRANSACTIONS); CHECK_AND_ASSERT_MES(res, false, "Unable to init db container"); -// res = m_db_key_images_set.init(TRANSACTION_POOL_CONTAINER_KEY_IMAGES); -// CHECK_AND_ASSERT_MES(res, false, "Unable to init db container"); res = m_db_black_tx_list.init(TRANSACTION_POOL_CONTAINER_BLACK_TX_LIST); CHECK_AND_ASSERT_MES(res, false, "Unable to init db container"); res = m_db_alias_names.init(TRANSACTION_POOL_CONTAINER_ALIAS_NAMES); diff --git a/src/currency_core/tx_pool.h b/src/currency_core/tx_pool.h index af140a66..c468f57e 100644 --- a/src/currency_core/tx_pool.h +++ b/src/currency_core/tx_pool.h @@ -171,7 +171,6 @@ namespace currency transactions_container m_db_transactions; hash_container m_db_black_tx_list; - //key_images_container m_db_key_images_set; aliases_container m_db_alias_names; address_to_aliases_container m_db_alias_addresses; solo_options_container m_db_solo_options; diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h index 03851812..b58373dc 100644 --- a/src/rpc/core_rpc_server.h +++ b/src/rpc/core_rpc_server.h @@ -155,7 +155,6 @@ namespace currency MAP_JON_RPC ("get_current_core_tx_expiration_median", on_get_current_core_tx_expiration_median, COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN) // MAP_JON_RPC_WE("marketplace_global_get_offers_ex", on_get_offers_ex, COMMAND_RPC_GET_OFFERS_EX) - //remote miner rpc MAP_JON_RPC_N(on_login, mining::COMMAND_RPC_LOGIN) MAP_JON_RPC_N(on_getjob, mining::COMMAND_RPC_GETJOB) diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 19d8ee78..335d024a 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -53,7 +53,7 @@ namespace tools //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::run(bool do_mint, bool offline_mode, const currency::account_public_address& miner_address) { - static const uint64_t wallet_rpt_idle_work_period_ms = 2000; + static const uint64_t wallet_rpc_idle_work_period_ms = 2000; m_do_mint = do_mint; @@ -97,7 +97,7 @@ namespace tools } return true; - }, wallet_rpt_idle_work_period_ms); + }, wallet_rpc_idle_work_period_ms); } //DO NOT START THIS SERVER IN MORE THEN 1 THREADS WITHOUT REFACTORING diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 0da4f17c..95eaaad4 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -33,8 +33,6 @@ namespace tools static void init_options(boost::program_options::options_description& desc); bool init(const boost::program_options::variables_map& vm); bool run(bool do_mint, bool offline_mode, const currency::account_public_address& miner_address); - - bool handle_http_request(const epee::net_utils::http::http_request_info& query_info, epee::net_utils::http::http_response_info& response, connection_context& m_conn_context); BEGIN_URI_MAP2() From dc215dacb417c018fd646c594b0df6fa247c40a9 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 14 Jan 2020 23:27:49 +0100 Subject: [PATCH 04/28] added class drafts for plain wallet api for mobile app - added missing files --- src/wallet/plain_wallet_api.cpp | 39 ++++++++++++++++++++++++++++ src/wallet/plain_wallet_api.h | 20 ++++++++++++++ src/wallet/plain_wallet_api_impl.cpp | 13 ++++++++++ src/wallet/plain_wallet_api_impl.h | 22 ++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 src/wallet/plain_wallet_api.cpp create mode 100644 src/wallet/plain_wallet_api.h create mode 100644 src/wallet/plain_wallet_api_impl.cpp create mode 100644 src/wallet/plain_wallet_api_impl.h diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp new file mode 100644 index 00000000..c73cf54c --- /dev/null +++ b/src/wallet/plain_wallet_api.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2014-2020 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +#include "plain_wallet_api.h" +#include "plain_wallet_api_impl.h" + +namespace wallet +{ + hwallet create_instance(const std::string port, const std::string ip) + { + + } + void destroy_instance(hwallet) + { + + } + std::string open(const std::string& path, const std::string password) + { + + } + void start_sync_thread(hwallet) + { + + } + std::string get_sync_status(hwallet) + { + + } + std::string sync(hwallet) + { + + } + std::string invoke(hwallet h, const std::string& params) + { + + } +} \ No newline at end of file diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h new file mode 100644 index 00000000..3540856b --- /dev/null +++ b/src/wallet/plain_wallet_api.h @@ -0,0 +1,20 @@ +// Copyright (c) 2014-2020 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 + +namespace wallet +{ + typedef void* hwallet; + hwallet create_instance(const std::string port, const std::string ip); + void destroy_instance(hwallet); + std::string open(const std::string& path, const std::string password); + void start_sync_thread(hwallet); + std::string get_sync_status(hwallet); + std::string sync(hwallet); + std::string invoke(hwallet h, const std::string& params); +} \ No newline at end of file diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp new file mode 100644 index 00000000..bc430f3b --- /dev/null +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -0,0 +1,13 @@ +// 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. + +#include "plain_wallet_api_impl.h" + +namespace wallet +{ + bool plain_wallet_api_impl::init(const std::string ip, const std::string port) + { + return true;//TODO + } +} \ No newline at end of file diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h new file mode 100644 index 00000000..3ebe2437 --- /dev/null +++ b/src/wallet/plain_wallet_api_impl.h @@ -0,0 +1,22 @@ +// Copyright (c) 2014-2020 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 +#include "wallet2.h" + + +namespace wallet +{ + class plain_wallet_api_impl + { + public: + bool init(const std::string ip, const std::string port); + private: + std::shared_ptr m_wallet; + }; + +} \ No newline at end of file From e4dfa7d5194f0bc34a590d6e7e4e419ff994e00a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 15 Jan 2020 22:06:49 +0100 Subject: [PATCH 05/28] implementation of the plain wallet api guts(in progress) --- contrib/epee/include/sync_locked_object.h | 7 +++ .../qt-daemon/application/daemon_backend.cpp | 11 ++-- src/wallet/plain_wallet_api.cpp | 41 ++++++++---- src/wallet/plain_wallet_api.h | 16 +++-- src/wallet/plain_wallet_api_defs.h | 32 ++++++++++ src/wallet/plain_wallet_api_impl.cpp | 63 ++++++++++++++++++- src/wallet/plain_wallet_api_impl.h | 19 +++++- src/wallet/wallet_helpers.h | 24 +++++++ 8 files changed, 182 insertions(+), 31 deletions(-) create mode 100644 src/wallet/plain_wallet_api_defs.h create mode 100644 src/wallet/wallet_helpers.h diff --git a/contrib/epee/include/sync_locked_object.h b/contrib/epee/include/sync_locked_object.h index 09e85178..4bedf549 100644 --- a/contrib/epee/include/sync_locked_object.h +++ b/contrib/epee/include/sync_locked_object.h @@ -82,6 +82,13 @@ namespace epee template friend class locked_object_proxy; public: + std::shared_ptr> lock() + { + std::shared_ptr> res; + res.reset(new locked_object_proxy(t, m)); + return res; + } + std::shared_ptr> try_lock() { std::shared_ptr> res; diff --git a/src/gui/qt-daemon/application/daemon_backend.cpp b/src/gui/qt-daemon/application/daemon_backend.cpp index c707766b..cbe21106 100644 --- a/src/gui/qt-daemon/application/daemon_backend.cpp +++ b/src/gui/qt-daemon/application/daemon_backend.cpp @@ -10,6 +10,7 @@ #include "string_coding.h" #include "currency_core/core_tools.h" #include "common/callstack_helper.h" +#include "wallet/wallet_helpers.h" #define GET_WALLET_OPT_BY_ID(wallet_id, name) \ CRITICAL_REGION_LOCAL(m_wallets_lock); \ @@ -1342,14 +1343,12 @@ std::string daemon_backend::run_wallet(uint64_t wallet_id) wo.miner_thread = std::thread(boost::bind(&daemon_backend::wallet_vs_options::worker_func, &wo)); return API_RETURN_CODE_OK; } + std::string daemon_backend::get_wallet_info(wallet_vs_options& wo, view::wallet_info& wi) { - wi = view::wallet_info(); - wi.address = wo.w->get()->get_account().get_public_address_str(); - wi.tracking_hey = string_tools::pod_to_hex(wo.w->get()->get_account().get_keys().m_view_secret_key); - uint64_t fake = 0; - wi.balance = wo.w->get()->balance(wi.unlocked_balance, fake, fake, wi.mined_total); - wi.path = epee::string_encoding::wstring_to_utf8(wo.w->get()->get_wallet_path()); + auto locker_object = wo.w.lock(); + tools::wallet2& rw = *(*(*locker_object)); //this looks a bit crazy, i know + tools::get_wallet_info(rw, wi); return API_RETURN_CODE_OK; } diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index c73cf54c..cdc21f25 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -6,34 +6,49 @@ #include "plain_wallet_api.h" #include "plain_wallet_api_impl.h" -namespace wallet +namespace plain_wallet { hwallet create_instance(const std::string port, const std::string ip) { - + return new plain_wallet_api_impl(port, ip); } - void destroy_instance(hwallet) + void destroy_instance(hwallet h) { - + delete ((plain_wallet_api_impl*)h); } - std::string open(const std::string& path, const std::string password) + std::string open(hwallet h, const std::string& path, const std::string password) { - + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + return pimpl->open(path, password); } - void start_sync_thread(hwallet) + std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string password) { - + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + return pimpl->restore(seed, path, password); } - std::string get_sync_status(hwallet) + std::string generate(hwallet h, const std::string& path, const std::string password) { - + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + return pimpl->generate(path, password); } - std::string sync(hwallet) + void start_sync_thread(hwallet h) { - + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + pimpl->start_sync_thread(); + } + std::string get_sync_status(hwallet h) + { + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + pimpl->get_sync_status(); + } + std::string sync(hwallet h) + { + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + pimpl->sync(); } std::string invoke(hwallet h, const std::string& params) { - + plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + pimpl->invoke(params); } } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 3540856b..11002e13 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -7,14 +7,18 @@ #include -namespace wallet +namespace plain_wallet { typedef void* hwallet; hwallet create_instance(const std::string port, const std::string ip); - void destroy_instance(hwallet); - std::string open(const std::string& path, const std::string password); - void start_sync_thread(hwallet); - std::string get_sync_status(hwallet); - std::string sync(hwallet); + void destroy_instance(hwallet h); + + std::string open(hwallet h, const std::string& path, const std::string password); + std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string password); + std::string generate(hwallet h, const std::string& path, const std::string password); + + void start_sync_thread(hwallet h); + std::string get_sync_status(hwallet h); + std::string sync(hwallet h); std::string invoke(hwallet h, const std::string& params); } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api_defs.h b/src/wallet/plain_wallet_api_defs.h new file mode 100644 index 00000000..afe733dc --- /dev/null +++ b/src/wallet/plain_wallet_api_defs.h @@ -0,0 +1,32 @@ +// Copyright (c) 2014-2020 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 "net/http_server_handlers_map2.h" +#include "gui/qt-daemon/application/view_iface.h" + +namespace plain_wallet +{ + struct error + { + std::string code; + std::string message; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(code) + KV_SERIALIZE(message) + END_KV_SERIALIZE_MAP() + }; + + + struct open_wallet_response + { + view::transfers_array recent_history; + view::wallet_info wi; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(wallet_id) + KV_SERIALIZE(recent_history) + KV_SERIALIZE(wi) + END_KV_SERIALIZE_MAP() + } +} // namespace tools diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index bc430f3b..8f566ed1 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -4,10 +4,67 @@ #include "plain_wallet_api_impl.h" -namespace wallet +namespace plain_wallet { - bool plain_wallet_api_impl::init(const std::string ip, const std::string port) + typedef epee::json_rpc::response error_response; + + plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port) { - return true;//TODO + m_wallet.reset(new tools::wallet2()); + m_wallet->init(ip + ":" + port); + m_rpc_wrapper.reset(new tools::wallet_rpc_server(*m_wallet)); } + std::string plain_wallet_api_impl::open(const std::string& path, const std::string password) + { + error_response err_result = AUTO_VAL_INIT(err_result); + try + { + m_wallet->load(epee::string_encoding::utf8_to_wstring(path), password); + } + catch (const tools::error::wallet_load_notice_wallet_restored& e) + { + LOG_ERROR("Wallet initialize was with problems, but still worked : " << e.what()); + err_result.error.code = API_RETURN_CODE_FILE_RESTORED; + return epee::serialization::store_t_to_json(err_result); + } + catch (const std::exception& e) + { + LOG_ERROR("Wallet initialize failed: " << e.what()); + err_result.error.code = API_RETURN_CODE_FAIL; + return epee::serialization::store_t_to_json(err_result); + } + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + m_wallet->get_recent_transfers_history(ok_response.result.recent_history.history, 0, 20, ok_response.result.recent_history.total_history_items); + m_wallet->get_unconfirmed_transfers(ok_response.result.recent_history.history); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); + } + std::string plain_wallet_api_impl::restore(const std::string& seed, const std::string& path, const std::string password) + { + + } + std::string plain_wallet_api_impl::generate(const std::string& path, const std::string password) + { + + } + + bool plain_wallet_api_impl::start_sync_thread() + { + + } + std::string plain_wallet_api_impl::get_sync_status() + { + + } + + std::string plain_wallet_api_impl::sync() + { + + } + std::string plain_wallet_api_impl::invoke(const std::string& params) + { + + } + + } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index 3ebe2437..feb74205 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -7,16 +7,29 @@ #include #include "wallet2.h" +#include "wallet_rpc_server.h" +#include "plain_wallet_api_defs.h" - -namespace wallet +namespace plain_wallet { class plain_wallet_api_impl { public: - bool init(const std::string ip, const std::string port); + plain_wallet_api_impl(const std::string ip, const std::string port); + std::string open(const std::string& path, const std::string password); + std::string restore(const std::string& seed, const std::string& path, const std::string password); + std::string generate(const std::string& path, const std::string password); + + bool start_sync_thread(); + std::string get_sync_status(); + + std::string sync(); + std::string invoke(const std::string& params); private: + bool get_wallet_info(view::wallet_info& wi); + std::shared_ptr m_wallet; + std::shared_ptr m_rpc_wrapper; }; } \ No newline at end of file diff --git a/src/wallet/wallet_helpers.h b/src/wallet/wallet_helpers.h new file mode 100644 index 00000000..22fc59c7 --- /dev/null +++ b/src/wallet/wallet_helpers.h @@ -0,0 +1,24 @@ +// Copyright (c) 2014-2020 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 "wallet2.h" +#include "gui/qt-daemon/application/view_iface.h" + + +namespace tools +{ + inline bool get_wallet_info(wallet2& w, view::wallet_info& wi) + { + wi = AUTO_VAL_INIT_T(view::wallet_info); + wi.address = w.get_account().get_public_address_str(); + wi.tracking_hey = string_tools::pod_to_hex(w.get_account().get_keys().m_view_secret_key); + uint64_t fake = 0; + wi.balance = w.balance(wi.unlocked_balance, fake, fake, wi.mined_total); + wi.path = epee::string_encoding::wstring_to_utf8(w.get_wallet_path()); + return API_RETURN_CODE_OK; + } +} \ No newline at end of file From 068bda9052db4f8e94f4713075f54b034e6d34fd Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 16 Jan 2020 23:52:29 +0100 Subject: [PATCH 06/28] implemented restore and generate wallet --- src/wallet/plain_wallet_api_impl.cpp | 58 ++++++++++++++++++++++++++-- src/wallet/plain_wallet_api_impl.h | 4 +- src/wallet/wallet2.h | 4 +- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index 8f566ed1..9e2d5e39 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -8,12 +8,19 @@ namespace plain_wallet { typedef epee::json_rpc::response error_response; - plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port) + plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port):m_stop(false) { m_wallet.reset(new tools::wallet2()); m_wallet->init(ip + ":" + port); m_rpc_wrapper.reset(new tools::wallet_rpc_server(*m_wallet)); } + + plain_wallet_api_impl::~plain_wallet_api_impl() + { + if (m_sync_thread.joinable()) + m_sync_thread.join(); + } + std::string plain_wallet_api_impl::open(const std::string& path, const std::string password) { error_response err_result = AUTO_VAL_INIT(err_result); @@ -39,18 +46,61 @@ namespace plain_wallet tools::get_wallet_info(*m_wallet, ok_response.result.wi); return epee::serialization::store_t_to_json(ok_response); } + std::string plain_wallet_api_impl::restore(const std::string& seed, const std::string& path, const std::string password) { - + error_response err_result = AUTO_VAL_INIT(err_result); + try + { + m_wallet->restore(epee::string_encoding::utf8_to_wstring(path), password, seed); + } + catch (const tools::error::wallet_load_notice_wallet_restored& e) + { + LOG_ERROR("Wallet initialize was with problems, but still worked : " << e.what()); + err_result.error.code = API_RETURN_CODE_FILE_RESTORED; + return epee::serialization::store_t_to_json(err_result); + } + catch (const std::exception& e) + { + LOG_ERROR("Wallet initialize failed: " << e.what()); + err_result.error.code = API_RETURN_CODE_FAIL; + return epee::serialization::store_t_to_json(err_result); + } + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); } + std::string plain_wallet_api_impl::generate(const std::string& path, const std::string password) { - + error_response err_result = AUTO_VAL_INIT(err_result); + try + { + m_wallet->generate(epee::string_encoding::utf8_to_wstring(path), password); + } + catch (const tools::error::wallet_load_notice_wallet_restored& e) + { + LOG_ERROR("Wallet initialize was with problems, but still worked : " << e.what()); + err_result.error.code = API_RETURN_CODE_FILE_RESTORED; + return epee::serialization::store_t_to_json(err_result); + } + catch (const std::exception& e) + { + LOG_ERROR("Wallet initialize failed: " << e.what()); + err_result.error.code = API_RETURN_CODE_FAIL; + return epee::serialization::store_t_to_json(err_result); + } + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); } bool plain_wallet_api_impl::start_sync_thread() { - + m_sync_thread = std::thread([&]() + { + + }); } std::string plain_wallet_api_impl::get_sync_status() { diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index feb74205..3a27abf7 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -27,7 +27,9 @@ namespace plain_wallet std::string invoke(const std::string& params); private: bool get_wallet_info(view::wallet_info& wi); - + std::thread m_sync_thread; + std::atomic m_stop; + std::atomic m_sync_finished; std::shared_ptr m_wallet; std::shared_ptr m_rpc_wrapper; }; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index e03c8d55..2b65d049 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -452,9 +452,9 @@ namespace tools END_SERIALIZE() }; void assign_account(const currency::account_base& acc); - void generate(const std::wstring& wallet, const std::string& password); + void generate(const std::wstring& path, const std::string& password); void restore(const std::wstring& path, const std::string& pass, const std::string& restore_key); - void load(const std::wstring& wallet, const std::string& password); + void load(const std::wstring& path, const std::string& password); void store(); void store(const std::wstring& path); void store(const std::wstring& path, const std::string& password); From cbce45285ca5915b75ad3e2458afb6a409d27f27 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 17 Jan 2020 23:44:22 +0100 Subject: [PATCH 07/28] implemented synchronyzation thread --- src/wallet/plain_wallet_api_impl.cpp | 14 ++++++++++---- src/wallet/plain_wallet_api_impl.h | 1 + src/wallet/wallet2.cpp | 5 +++++ src/wallet/wallet2.h | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index 9e2d5e39..5b4b83b9 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -99,21 +99,27 @@ namespace plain_wallet { m_sync_thread = std::thread([&]() { - + m_wallet->refresh(m_stop); }); } + + bool plain_wallet_api_impl::cancel_sync_thread() + { + m_stop = true; + } + std::string plain_wallet_api_impl::get_sync_status() { - + m_wallet->get_sync_progress(); } std::string plain_wallet_api_impl::sync() { - + m_wallet->refresh(m_stop); } std::string plain_wallet_api_impl::invoke(const std::string& params) { - + m_rpc_wrapper->handle_http_request_map() } diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index 3a27abf7..ff1f5473 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -21,6 +21,7 @@ namespace plain_wallet std::string generate(const std::string& path, const std::string password); bool start_sync_thread(); + bool cancel_sync_thread(); std::string get_sync_status(); std::string sync(); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d66fead1..abaea6aa 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1236,6 +1236,11 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop WLT_LOG_L1("[PULL BLOCKS] " << res.start_height << " --> " << m_blockchain.size()); } //---------------------------------------------------------------------------------------------------- +uint64_t wallet2::get_sync_progress() +{ + return m_last_sync_percent; +} +//---------------------------------------------------------------------------------------------------- void wallet2::refresh() { size_t blocks_fetched = 0; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 2b65d049..7654bba7 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -744,7 +744,7 @@ namespace tools std::string get_log_prefix() const { return m_log_prefix; } static uint64_t get_max_unlock_time_from_receive_indices(const currency::transaction& tx, const money_transfer2_details& td); bool get_utxo_distribution(std::map& distribution); - + uint64_t get_sync_progress(); private: void add_transfers_to_expiration_list(const std::vector& 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); @@ -895,7 +895,7 @@ private: std::shared_ptr m_core_proxy; std::shared_ptr m_wcallback; uint64_t m_height_of_start_sync; - uint64_t m_last_sync_percent; + std::atomic m_last_sync_percent; uint64_t m_last_pow_block_h; currency::core_runtime_config m_core_runtime_config; escrow_contracts_container m_contracts; From e6dd2d28a5ea7b79e15886834afa7b619c7a5a25 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 18 Jan 2020 23:23:47 +0100 Subject: [PATCH 08/28] implemented invoke for plain_wallet amd fixed return codes to json --- src/gui/qt-daemon/application/view_iface.h | 8 ++-- src/wallet/plain_wallet_api_defs.h | 22 ++++++++- src/wallet/plain_wallet_api_impl.cpp | 56 ++++++++++++++++++---- src/wallet/plain_wallet_api_impl.h | 5 +- src/wallet/wallet_helpers.h | 2 +- 5 files changed, 76 insertions(+), 17 deletions(-) diff --git a/src/gui/qt-daemon/application/view_iface.h b/src/gui/qt-daemon/application/view_iface.h index 52591e8e..2b814adc 100644 --- a/src/gui/qt-daemon/application/view_iface.h +++ b/src/gui/qt-daemon/application/view_iface.h @@ -6,9 +6,9 @@ #pragma once -#include -#include -#ifndef Q_MOC_RUN +// #include +// #include +// #ifndef Q_MOC_RUN #include "warnings.h" PUSH_VS_WARNINGS @@ -22,7 +22,7 @@ DISABLE_VS_WARNINGS(4503) #include "currency_core/basic_api_response_codes.h" POP_VS_WARNINGS -#endif +//#endif namespace view { diff --git a/src/wallet/plain_wallet_api_defs.h b/src/wallet/plain_wallet_api_defs.h index afe733dc..1ad93c56 100644 --- a/src/wallet/plain_wallet_api_defs.h +++ b/src/wallet/plain_wallet_api_defs.h @@ -24,9 +24,27 @@ namespace plain_wallet view::transfers_array recent_history; view::wallet_info wi; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(wallet_id) KV_SERIALIZE(recent_history) KV_SERIALIZE(wi) END_KV_SERIALIZE_MAP() - } + }; + + struct sync_status_response + { + bool finished; + uint64_t progress; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(finished) + KV_SERIALIZE(progress) + END_KV_SERIALIZE_MAP() + }; + + struct basic_status_response + { + std::string status; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(status) + END_KV_SERIALIZE_MAP() + }; + } // namespace tools diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index 5b4b83b9..5476efc9 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "plain_wallet_api_impl.h" +#include "wallet/wallet_helpers.h" namespace plain_wallet { @@ -95,32 +96,71 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } - bool plain_wallet_api_impl::start_sync_thread() + std::string plain_wallet_api_impl::start_sync_thread() { m_sync_thread = std::thread([&]() { - m_wallet->refresh(m_stop); + + try + { + m_wallet->refresh(m_stop); + } + catch (const std::exception& e) + { + LOG_ERROR("Wallet refresh failed: " << e.what()); + return; + } + m_sync_finished = true; }); + basic_status_response bsr = AUTO_VAL_INIT(bsr); + bsr.status = API_RETURN_CODE_OK; + return epee::serialization::store_t_to_json(bsr); } - bool plain_wallet_api_impl::cancel_sync_thread() + std::string plain_wallet_api_impl::cancel_sync_thread() { m_stop = true; + if (m_sync_thread.joinable()) + m_sync_thread.join(); + basic_status_response bsr = AUTO_VAL_INIT(bsr); + bsr.status = API_RETURN_CODE_OK; + return epee::serialization::store_t_to_json(bsr); + } std::string plain_wallet_api_impl::get_sync_status() { - m_wallet->get_sync_progress(); + sync_status_response ssr = AUTO_VAL_INIT(ssr); + ssr.finished = m_sync_finished; + ssr.progress = m_wallet->get_sync_progress(); + return epee::serialization::store_t_to_json(ssr); } std::string plain_wallet_api_impl::sync() { - m_wallet->refresh(m_stop); + basic_status_response bsr = AUTO_VAL_INIT(bsr); + try + { + m_wallet->refresh(m_stop); + } + catch (const std::exception& e) + { + LOG_ERROR("Wallet refresh failed: " << e.what()); + bsr.status = API_RETURN_CODE_FAIL; + return epee::serialization::store_t_to_json(bsr); + } + bsr.status = API_RETURN_CODE_OK; + return epee::serialization::store_t_to_json(bsr); } std::string plain_wallet_api_impl::invoke(const std::string& params) { - m_rpc_wrapper->handle_http_request_map() + epee::net_utils::http::http_request_info query_info = AUTO_VAL_INIT(query_info); + epee::net_utils::http::http_response_info response_info = AUTO_VAL_INIT(response_info); + epee::net_utils::connection_context_base stub_conn_context = AUTO_VAL_INIT(stub_conn_context); + std::string reference_stub; + bool call_found = false; + query_info.m_body = params; + m_rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found, reference_stub); + return response_info.m_body; } - - } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index ff1f5473..dba03a77 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -16,12 +16,13 @@ namespace plain_wallet { public: plain_wallet_api_impl(const std::string ip, const std::string port); + ~plain_wallet_api_impl(); std::string open(const std::string& path, const std::string password); std::string restore(const std::string& seed, const std::string& path, const std::string password); std::string generate(const std::string& path, const std::string password); - bool start_sync_thread(); - bool cancel_sync_thread(); + std::string start_sync_thread(); + std::string cancel_sync_thread(); std::string get_sync_status(); std::string sync(); diff --git a/src/wallet/wallet_helpers.h b/src/wallet/wallet_helpers.h index 22fc59c7..e3a5ccb3 100644 --- a/src/wallet/wallet_helpers.h +++ b/src/wallet/wallet_helpers.h @@ -15,7 +15,7 @@ namespace tools { wi = AUTO_VAL_INIT_T(view::wallet_info); wi.address = w.get_account().get_public_address_str(); - wi.tracking_hey = string_tools::pod_to_hex(w.get_account().get_keys().m_view_secret_key); + wi.tracking_hey = epee::string_tools::pod_to_hex(w.get_account().get_keys().m_view_secret_key); uint64_t fake = 0; wi.balance = w.balance(wi.unlocked_balance, fake, fake, wi.mined_total); wi.path = epee::string_encoding::wstring_to_utf8(w.get_wallet_path()); From c0f1d7b577df5d2c914a247a159e5673327193a5 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 21 Jan 2020 01:31:16 +0100 Subject: [PATCH 09/28] fixed cmake, fixed compilation problems, implemented plain_api test draft --- CMakeLists.txt | 14 ++++-- contrib/CMakeLists.txt | 2 +- src/CMakeLists.txt | 5 +- src/wallet/plain_wallet_api.cpp | 6 +-- tests/functional_tests/plain_wallet_tests.cpp | 47 +++++++++++++++++++ tests/functional_tests/plain_wallet_tests.h | 9 ++++ 6 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 tests/functional_tests/plain_wallet_tests.cpp create mode 100644 tests/functional_tests/plain_wallet_tests.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d9a5646..e873e6d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,11 +163,15 @@ if(STATIC) endif() -#find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options ) #locale -set(Boost_INCLUDE_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/include") -set(Boost_LIBRARY_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/ios/") -set(Boost_LIBRARIES "libboost.a") -set(Boost_VERSION "ofxiOSBoost 1.60.0") +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(Boost_INCLUDE_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/include") + set(Boost_LIBRARY_DIRS "/Users/roky/projects/Zano/mobile_repo/ofxiOSBoost/libs/boost/ios/") + set(Boost_LIBRARIES "libboost.a") + set(Boost_VERSION "ofxiOSBoost 1.60.0") +else() + find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options ) #locale +endif() + message(STATUS "Boost: ${Boost_VERSION} from ${Boost_LIBRARY_DIRS}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 86365e5a..853e70d4 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -17,7 +17,7 @@ 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") -set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat minigzip zlib example PROPERTY FOLDER "unused") +#set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat minigzip zlib PROPERTY FOLDER "unused") if(MSVC) set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eec8f613..ca9d8f47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ -if(CMAKE_SYSTEM_NAME STREQL iOS) -{ +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") return() -} +endif() if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index cdc21f25..33adf229 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -39,16 +39,16 @@ namespace plain_wallet std::string get_sync_status(hwallet h) { plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; - pimpl->get_sync_status(); + return pimpl->get_sync_status(); } std::string sync(hwallet h) { plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; - pimpl->sync(); + return pimpl->sync(); } std::string invoke(hwallet h, const std::string& params) { plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; - pimpl->invoke(params); + return pimpl->invoke(params); } } \ No newline at end of file diff --git a/tests/functional_tests/plain_wallet_tests.cpp b/tests/functional_tests/plain_wallet_tests.cpp new file mode 100644 index 00000000..287b95cc --- /dev/null +++ b/tests/functional_tests/plain_wallet_tests.cpp @@ -0,0 +1,47 @@ +// 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. + +#include +#include +#include +#include +#include + +#include "include_base_utils.h" +using namespace epee; +#include "misc_language.h" +#include "wallet/plain_wallet_api.h" +#include "wallet/wallet_helpers.h" +#include "wallet/plain_wallet_api_defs.h" + + +void run_plain_wallet_api_test() +{ + LOG_PRINT_L0("Creating instance..."); + plain_wallet::hwallet hw = plain_wallet::create_instance("11211", "127.0.0.1."); + LOG_PRINT_L0("Creating instance..." << std::hex << hw); + + LOG_PRINT_L0("Generating wallet..."); + std::string rsp = plain_wallet::generate(hw, "E:\\tmp\\sdsd", ""); + LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + epee::serialization::load_t_from_json(ok_response, rsp); + + plain_wallet::start_sync_thread(hw); + LOG_PRINT_L0("Started sync thread."); + + while (true) + { + std::string prog = plain_wallet::get_sync_status(hw); + plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); + epee::serialization::load_t_from_json(ssr, prog); + LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); + if (ssr.finished) + break; + epee::misc_utils::sleep_no_w(100); + } + + + +} \ No newline at end of file diff --git a/tests/functional_tests/plain_wallet_tests.h b/tests/functional_tests/plain_wallet_tests.h new file mode 100644 index 00000000..f6e23c51 --- /dev/null +++ b/tests/functional_tests/plain_wallet_tests.h @@ -0,0 +1,9 @@ +// 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. + + + +void run_plain_wallet_api_test(); + + From 03f04c9dd9aab58d0eafe56cdc168d7b803d88c1 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 23 Jan 2020 03:26:25 +0100 Subject: [PATCH 10/28] implemented exented wallet api, finished plain wallet test(but not tested yet) --- CMakeLists.txt | 9 ++-- src/currency_core/blockchain_storage.cpp | 1 - src/currency_core/currency_config.h | 2 + src/currency_core/tx_pool.cpp | 1 - src/wallet/wallet2.cpp | 5 +++ src/wallet/wallet2.h | 1 + src/wallet/wallet_public_structs_defs.h | 31 +++++++++++++ src/wallet/wallet_rpc_server.cpp | 23 ++++++++++ src/wallet/wallet_rpc_server.h | 2 + .../core_concurrency_test.cpp | 4 +- tests/functional_tests/main.cpp | 10 ++++- tests/functional_tests/plain_wallet_tests.cpp | 43 ++++++++++++++++++- 12 files changed, 122 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e873e6d6..e58f253e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,6 @@ set(VERSION "1.0") cmake_policy(SET CMP0020 OLD) endif() -set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "Andrey Sabelnikov") set_property(GLOBAL PROPERTY USE_FOLDERS ON) # build types @@ -24,7 +23,11 @@ if (UNIX AND NOT APPLE) endif() else() # multi configurations for MSVC and XCode - set(CMAKE_CONFIGURATION_TYPES "Release") + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + set(CMAKE_CONFIGURATION_TYPES "Release") + else() + set(CMAKE_CONFIGURATION_TYPES "Debug;Release") + endif() endif() message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built type: ${CMAKE_BUILD_TYPE}") @@ -169,7 +172,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(Boost_LIBRARIES "libboost.a") set(Boost_VERSION "ofxiOSBoost 1.60.0") 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.55 REQUIRED COMPONENTS system filesystem locale thread timer date_time chrono regex serialization atomic program_options ) #locale endif() diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 7ecc4a3a..f35823c7 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -70,7 +70,6 @@ using namespace currency; #endif #define BLOCK_POS_STRICT_SEQUENCE_LIMIT 20 -#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v1" DISABLE_VS_WARNINGS(4267) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 6e38c59d..8d2e667c 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -192,7 +192,9 @@ #define CURRENCY_POOLDATA_FOLDERNAME_PREFIX "poolstate_" +#define CURRENCY_POOLDATA_FOLDERNAME_SUFFIX "_v1" #define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX "blockchain_" +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v1" #define P2P_NET_DATA_FILENAME "p2pstate.bin" #define MINER_CONFIG_FILENAME "miner_conf.json" diff --git a/src/currency_core/tx_pool.cpp b/src/currency_core/tx_pool.cpp index a506325c..5e1f7640 100644 --- a/src/currency_core/tx_pool.cpp +++ b/src/currency_core/tx_pool.cpp @@ -32,7 +32,6 @@ DISABLE_VS_WARNINGS(4244 4345 4503) //'boost::foreach_detail_::or_' : decorated #define TRANSACTION_POOL_OPTIONS_ID_STORAGE_MAJOR_COMPATIBILITY_VERSION 92 // DON'T CHANGE THIS, if you need to resync db! Change TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION instead! #define TRANSACTION_POOL_MAJOR_COMPATIBILITY_VERSION BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION + 1 -#define CURRENCY_POOLDATA_FOLDERNAME_SUFFIX "_v1" #define CONFLICT_KEY_IMAGE_SPENT_DEPTH_TO_REMOVE_TX_FROM_POOL 50 // if there's a conflict in key images between tx in the pool and in the blockchain this much depth in required to remove correspongin tx from pool diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index abaea6aa..0a6a8c70 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2589,6 +2589,11 @@ uint64_t wallet2::get_recent_transfers_total_count() return m_transfer_history.size(); } //---------------------------------------------------------------------------------------------------- +uint64_t wallet2::get_transfer_entries_count() +{ + return m_transfers.size(); +} +//---------------------------------------------------------------------------------------------------- void wallet2::get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total) { if (offset >= m_transfer_history.size()) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 7654bba7..f1e10186 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -466,6 +466,7 @@ namespace tools void get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total); uint64_t get_recent_transfers_total_count(); + uint64_t get_transfer_entries_count(); void get_unconfirmed_transfers(std::vector& trs); void init(const std::string& daemon_address = "http://localhost:8080"); bool deinit(); diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index b24e92c2..d2b3862a 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -206,6 +206,37 @@ namespace wallet_public }; }; + + + struct COMMAND_RPC_GET_WALLET_INFO + { + struct request + { + BEGIN_KV_SERIALIZE_MAP() + END_KV_SERIALIZE_MAP() + }; + + struct response + { + std::string address; + std::string path; + uint64_t transfers_count; + uint64_t transfer_entries_count; + bool is_whatch_only; + std::vector utxo_distribution; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(address) + KV_SERIALIZE(path) + KV_SERIALIZE(transfers_count) + KV_SERIALIZE(transfer_entries_count) + KV_SERIALIZE(is_whatch_only) + KV_SERIALIZE(utxo_distribution) + END_KV_SERIALIZE_MAP() + }; + }; + + struct trnsfer_destination { uint64_t amount; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 335d024a..a90de9dd 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -186,6 +186,29 @@ namespace tools } return true; } + bool wallet_rpc_server::on_getwallet_info(const wallet_public::COMMAND_RPC_GET_WALLET_INFO::request& req, wallet_public::COMMAND_RPC_GET_WALLET_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx) + { + try + { + res.address = m_wallet.get_account().get_public_address_str(); + res.is_whatch_only = m_wallet.is_watch_only(); + res.path = epee::string_encoding::convert_to_ansii(m_wallet.get_wallet_path()); + res.transfers_count = m_wallet.get_recent_transfers_total_count(); + res.transfer_entries_count = m_wallet.get_transfer_entries_count(); + std::map distribution; + m_wallet.get_utxo_distribution(distribution); + for (const auto& ent : distribution) + res.utxo_distribution.push_back(std::to_string(ent.first) + ":" + std::to_string(ent.second)); + + return true; + } + catch (std::exception& e) + { + er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; + er.message = e.what(); + return false; + } + } //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_transfer(const wallet_public::COMMAND_RPC_TRANSFER::request& req, wallet_public::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx) { diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 95eaaad4..a3f1e19a 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -39,6 +39,7 @@ namespace tools BEGIN_JSON_RPC_MAP("/json_rpc") MAP_JON_RPC_WE("getbalance", on_getbalance, wallet_public::COMMAND_RPC_GET_BALANCE) MAP_JON_RPC_WE("getaddress", on_getaddress, wallet_public::COMMAND_RPC_GET_ADDRESS) + MAP_JON_RPC_WE("get_wallet_info", on_getwallet_info, wallet_public::COMMAND_RPC_GET_WALLET_INFO) MAP_JON_RPC_WE("transfer", on_transfer, wallet_public::COMMAND_RPC_TRANSFER) MAP_JON_RPC_WE("store", on_store, wallet_public::COMMAND_RPC_STORE) MAP_JON_RPC_WE("get_payments", on_get_payments, wallet_public::COMMAND_RPC_GET_PAYMENTS) @@ -66,6 +67,7 @@ namespace tools //json_rpc bool on_getbalance(const wallet_public::COMMAND_RPC_GET_BALANCE::request& req, wallet_public::COMMAND_RPC_GET_BALANCE::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_getaddress(const wallet_public::COMMAND_RPC_GET_ADDRESS::request& req, wallet_public::COMMAND_RPC_GET_ADDRESS::response& res, epee::json_rpc::error& er, connection_context& cntx); + bool on_getwallet_info(const wallet_public::COMMAND_RPC_GET_WALLET_INFO::request& req, wallet_public::COMMAND_RPC_GET_WALLET_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_transfer(const wallet_public::COMMAND_RPC_TRANSFER::request& req, wallet_public::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_store(const wallet_public::COMMAND_RPC_STORE::request& req, wallet_public::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_get_payments(const wallet_public::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_public::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er, connection_context& cntx); diff --git a/tests/functional_tests/core_concurrency_test.cpp b/tests/functional_tests/core_concurrency_test.cpp index dbd48447..d72cf983 100644 --- a/tests/functional_tests/core_concurrency_test.cpp +++ b/tests/functional_tests/core_concurrency_test.cpp @@ -284,8 +284,10 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_ bool clean_data_directory(boost::program_options::variables_map& vm) { std::string config_folder = command_line::get_arg(vm, command_line::arg_data_dir); + const std::string bch_db_folder_path = config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + "lmdb" + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX; + const std::string pool_db_folder_path = config_folder + ("/" CURRENCY_POOLDATA_FOLDERNAME_PREFIX) + "lmdb" + CURRENCY_POOLDATA_FOLDERNAME_SUFFIX; - static const char* const files[] = { CURRENCY_BLOCKCHAINDATA_FOLDERNAME, CURRENCY_POOLDATA_FOLDERNAME, MINER_CONFIG_FILENAME }; + static const char* const files[] = { bch_db_folder_path.c_str(), pool_db_folder_path.c_str(), MINER_CONFIG_FILENAME }; for (size_t i = 0; i < sizeof files / sizeof files[0]; ++i) { boost::filesystem::path filename(config_folder + "/" + files[i]); diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index 47222857..b9da8288 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -18,6 +18,7 @@ using namespace epee; #include "generate_test_genesis.h" #include "deadlock_guard_test.h" #include "difficulty_analysis.h" +#include "plain_wallet_tests.h" namespace po = boost::program_options; @@ -53,6 +54,7 @@ namespace const command_line::arg_descriptor arg_generate_test_genesis_json = { "generate-test-genesis-json", "generates test genesis json, specify amount of accounts", 0, true }; const command_line::arg_descriptor arg_deadlock_guard = { "test-deadlock-guard", "Do deadlock guard test", false, true }; const command_line::arg_descriptor arg_difficulty_analysis = { "difficulty-analysis", "Do difficulty analysis", "", true }; + const command_line::arg_descriptor arg_test_plain_wallet = { "test-plainwallet", "Do testing of plain wallet interface", false, true }; } @@ -104,8 +106,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_options, arg_max_tx_in_pool); command_line::add_arg(desc_options, arg_deadlock_guard); command_line::add_arg(desc_options, arg_difficulty_analysis); - - + command_line::add_arg(desc_options, arg_test_plain_wallet); test_serialization(); @@ -190,6 +191,11 @@ int main(int argc, char* argv[]) do_deadlock_test_main(); return 1; } + else if (command_line::has_arg(vm, arg_deadlock_guard)) + { + run_plain_wallet_api_test(); + return 1; + } else if (command_line::get_arg(vm, arg_test_core_concurrency)) { for (size_t i = 0; i != repeat_count; i++) diff --git a/tests/functional_tests/plain_wallet_tests.cpp b/tests/functional_tests/plain_wallet_tests.cpp index 287b95cc..20892e7b 100644 --- a/tests/functional_tests/plain_wallet_tests.cpp +++ b/tests/functional_tests/plain_wallet_tests.cpp @@ -23,7 +23,7 @@ void run_plain_wallet_api_test() LOG_PRINT_L0("Creating instance..." << std::hex << hw); LOG_PRINT_L0("Generating wallet..."); - std::string rsp = plain_wallet::generate(hw, "E:\\tmp\\sdsd", ""); + std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", ""); LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); epee::serialization::load_t_from_json(ok_response, rsp); @@ -39,9 +39,48 @@ void run_plain_wallet_api_test() LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); if (ssr.finished) break; - epee::misc_utils::sleep_no_w(100); + epee::misc_utils::sleep_no_w(1000); + } + LOG_PRINT_L0("Sync finished OK"); + + { + //request get wallet info: + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "get_wallet_info"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " + << ENDL << res); } + { + //request balance + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "getbalance"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " + << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); + } + + { + //request balance + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "store"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " + << ENDL << res); } } \ No newline at end of file From cfe9837ba8646f2eeb7225d0a621f79a606fdbda Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 20:57:12 +0100 Subject: [PATCH 11/28] tested plain wallet interface, and fixed errors --- src/wallet/plain_wallet_api.cpp | 4 +- src/wallet/plain_wallet_api.h | 2 +- src/wallet/plain_wallet_api_impl.cpp | 5 +- tests/functional_tests/main.cpp | 2 +- tests/functional_tests/plain_wallet_tests.cpp | 83 ++++++++++++++++++- 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 33adf229..5e0c32a7 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -8,9 +8,9 @@ namespace plain_wallet { - hwallet create_instance(const std::string port, const std::string ip) + hwallet create_instance(const std::string ip, const std::string port) { - return new plain_wallet_api_impl(port, ip); + return new plain_wallet_api_impl(ip, port); } void destroy_instance(hwallet h) { diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 11002e13..6e503bb3 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -10,7 +10,7 @@ namespace plain_wallet { typedef void* hwallet; - hwallet create_instance(const std::string port, const std::string ip); + hwallet create_instance(const std::string ip, const std::string port); void destroy_instance(hwallet h); std::string open(hwallet h, const std::string& path, const std::string password); diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index 5476efc9..c4b10ddf 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -9,7 +9,9 @@ namespace plain_wallet { typedef epee::json_rpc::response error_response; - plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port):m_stop(false) + plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port): + m_stop(false), + m_sync_finished(false) { m_wallet.reset(new tools::wallet2()); m_wallet->init(ip + ":" + port); @@ -159,6 +161,7 @@ namespace plain_wallet epee::net_utils::connection_context_base stub_conn_context = AUTO_VAL_INIT(stub_conn_context); std::string reference_stub; bool call_found = false; + query_info.m_URI = "/json_rpc"; query_info.m_body = params; m_rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found, reference_stub); return response_info.m_body; diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index b9da8288..a7870627 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -191,7 +191,7 @@ int main(int argc, char* argv[]) do_deadlock_test_main(); return 1; } - else if (command_line::has_arg(vm, arg_deadlock_guard)) + else if (command_line::has_arg(vm, arg_test_plain_wallet)) { run_plain_wallet_api_test(); return 1; diff --git a/tests/functional_tests/plain_wallet_tests.cpp b/tests/functional_tests/plain_wallet_tests.cpp index 20892e7b..c843c3fe 100644 --- a/tests/functional_tests/plain_wallet_tests.cpp +++ b/tests/functional_tests/plain_wallet_tests.cpp @@ -19,11 +19,11 @@ using namespace epee; void run_plain_wallet_api_test() { LOG_PRINT_L0("Creating instance..."); - plain_wallet::hwallet hw = plain_wallet::create_instance("11211", "127.0.0.1."); + plain_wallet::hwallet hw = plain_wallet::create_instance("127.0.0.1", "11211"); LOG_PRINT_L0("Creating instance..." << std::hex << hw); LOG_PRINT_L0("Generating wallet..."); - std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", ""); + std::string rsp = plain_wallet::open(hw, std::string("E:\\tmp\\zano_testwallet_74565030.zan"), ""); LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); epee::serialization::load_t_from_json(ok_response, rsp); @@ -53,7 +53,7 @@ void run_plain_wallet_api_test() std::string res = plain_wallet::invoke(hw, req_str); epee::serialization::load_t_from_json(gbres, res); - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " << ENDL << res); } @@ -82,5 +82,80 @@ void run_plain_wallet_api_test() epee::serialization::load_t_from_json(gbres, res); LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " - << ENDL << res); } + << ENDL << res); + } + + plain_wallet::destroy_instance(hw); + + + return; + //------- + { + LOG_PRINT_L0("Creating instance..."); + plain_wallet::hwallet hw = plain_wallet::create_instance("127.0.0.1", "11211"); + LOG_PRINT_L0("Creating instance..." << std::hex << hw); + + LOG_PRINT_L0("Generating wallet..."); + std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", ""); + LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + epee::serialization::load_t_from_json(ok_response, rsp); + + plain_wallet::start_sync_thread(hw); + LOG_PRINT_L0("Started sync thread."); + + while (true) + { + std::string prog = plain_wallet::get_sync_status(hw); + plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); + epee::serialization::load_t_from_json(ssr, prog); + LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); + if (ssr.finished) + break; + epee::misc_utils::sleep_no_w(1000); + } + LOG_PRINT_L0("Sync finished OK"); + + { + //request get wallet info: + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "get_wallet_info"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " + << ENDL << res); + } + + { + //request balance + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "getbalance"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " + << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); + } + + { + //request balance + epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); + gbreq.method = "store"; + epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); + std::string req_str = epee::serialization::store_t_to_json(gbreq); + + std::string res = plain_wallet::invoke(hw, req_str); + epee::serialization::load_t_from_json(gbres, res); + + LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " + << ENDL << res); + } + } } \ No newline at end of file From 0eac604ef893fd3fbb07d87c39f2bbd75865ffad Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 21:46:40 +0100 Subject: [PATCH 12/28] added install instructions --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ca9d8f47..4456cb1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,6 +110,7 @@ add_dependencies(currency_core version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(CURRENCY_CORE) if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + install(TARGETS wallet currency_core crypto common DESTINATION lib) message("Generating for iOS: finished") return() endif() From 5d70ada83e5f40842007994f9007cf8f4d4fc80c Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 21:53:00 +0100 Subject: [PATCH 13/28] disabled policies --- CMakeLists.txt | 12 ++++++------ src/CMakeLists.txt | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e58f253e..9584c58d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,13 +5,13 @@ PROJECT(Zano) set(VERSION "1.0") - if(POLICY CMP0043) - cmake_policy(SET CMP0043 OLD) - endif() +# if(POLICY CMP0043) +# cmake_policy(SET CMP0043 OLD) +# endif() - if(POLICY CMP0020) - cmake_policy(SET CMP0020 OLD) - endif() +# if(POLICY CMP0020) +# cmake_policy(SET CMP0020 OLD) +# endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4456cb1b..d792d71e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") return() endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 OLD) -endif() +# if(POLICY CMP0043) +# cmake_policy(SET CMP0043 OLD) +# endif() ########### # using shared PCH -- this is unusual case for MSVC... so mystery, such hack, many wow. See also: https://stackoverflow.com/questions/645747/sharing-precompiled-headers-between-projects-in-visual-studio/4170902#4170902 From b1dbb8867e35860002ac9f87249192db56221977 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 22:16:44 +0100 Subject: [PATCH 14/28] fixed wrong line in cmake --- src/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d792d71e..b11fa25d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,3 @@ -if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - return() -endif() # if(POLICY CMP0043) # cmake_policy(SET CMP0043 OLD) # endif() From ccb304dce95eb2a3aba3ec60076f0102432022e1 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 22:20:22 +0100 Subject: [PATCH 15/28] added preprocessor defintion for ios --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9584c58d..c5b2348a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,11 @@ set(VERSION "1.0") # cmake_policy(SET CMP0020 OLD) # endif() +if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + add_definitions(-DIOS_BUILD) +endif() + + set_property(GLOBAL PROPERTY USE_FOLDERS ON) # build types From ef856d01cc64c1b03e8531f5355ce1e207721e2e Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 27 Jan 2020 22:42:18 +0100 Subject: [PATCH 16/28] diff switched to more portable ver --- src/currency_core/difficulty.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/currency_core/difficulty.cpp b/src/currency_core/difficulty.cpp index 7e217c00..68d82c15 100644 --- a/src/currency_core/difficulty.cpp +++ b/src/currency_core/difficulty.cpp @@ -24,7 +24,7 @@ namespace currency { using std::uint64_t; using std::vector; -#if defined(_MSC_VER) +//#if defined(_MSC_VER) //#include //#include @@ -36,7 +36,7 @@ namespace currency { //low = UnsignedMultiply128(a, b, &high); } -#else +/* #else static inline void mul(uint64_t a, uint64_t b, uint64_t &low, uint64_t &high) { typedef unsigned __int128 uint128_t; @@ -45,7 +45,7 @@ namespace currency { high = (uint64_t)(res >> 64); } -#endif +#endif */ static inline bool cadd(uint64_t a, uint64_t b) { return a + b < a; From 4729cffbaeb64b6a29e5f0a3ba67e5eb73cd57cf Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 00:47:44 +0100 Subject: [PATCH 17/28] changed plain wallet iface to avoid pointers --- src/wallet/plain_wallet_api.cpp | 64 ++++++++++++++++++++++------ src/wallet/plain_wallet_api.h | 12 +++--- src/wallet/plain_wallet_api_impl.cpp | 8 ++-- src/wallet/plain_wallet_api_impl.h | 8 ++-- 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 5e0c32a7..65dcd585 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -6,49 +6,85 @@ #include "plain_wallet_api.h" #include "plain_wallet_api_impl.h" +//TODO: global objects, need refactoring. Just temporary solution +std::map ginstances; +epee::critical_section ginstances_lock; +std::atomic gcounter = 1; + +#define GENERAL_INTERNAL_ERRROR_INSTANCE "GENERAL_INTERNAL_ERROR: WALLET INSTNACE NOT FOUND" + +#define GET_INSTANCE(var_name, instance_handle) plain_wallet_api_impl* var_name = nullptr;\ + CRITICAL_REGION_BEGIN(ginstances_lock);\ + auto it = ginstances.find(instance_handle);\ + if (it == ginstances.end())\ + {\ + LOG_ERROR("Internall error: attempt to delete wallet with wrong instance id: " << instance_handle);\ + return GENERAL_INTERNAL_ERRROR_INSTANCE;\ + }\ + var_name = it->second;\ + CRITICAL_REGION_END(); + + namespace plain_wallet { - hwallet create_instance(const std::string ip, const std::string port) + hwallet create_instance(const std::string& ip, const std::string& port) { - return new plain_wallet_api_impl(ip, port); + plain_wallet_api_impl* ptr = new plain_wallet_api_impl(ip, port); + hwallet new_h = gcounter++; + CRITICAL_REGION_BEGIN(ginstances_lock); + ginstances[new_h] = ptr; + CRITICAL_REGION_END(); + return new_h; } + void destroy_instance(hwallet h) { - delete ((plain_wallet_api_impl*)h); + plain_wallet_api_impl* instance_ptr = nullptr; + CRITICAL_REGION_BEGIN(ginstances_lock); + auto it = ginstances.find(h); + if (it == ginstances.end()) + { + LOG_ERROR("Internall error: attempt to delete wallet with wrong instance id: " << h); + } + instance_ptr = it->second; + ginstances.erase(instance_ptr); + CRITICAL_REGION_END(); + delete instance_ptr; } - std::string open(hwallet h, const std::string& path, const std::string password) + std::string open(hwallet h, const std::string& path, const std::string& password) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->open(path, password); } - std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string password) + std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->restore(seed, path, password); } - std::string generate(hwallet h, const std::string& path, const std::string password) + std::string generate(hwallet h, const std::string& path, const std::string& password) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->generate(path, password); } - void start_sync_thread(hwallet h) + std::string start_sync_thread(hwallet h) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); pimpl->start_sync_thread(); + return ""; } std::string get_sync_status(hwallet h) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->get_sync_status(); } std::string sync(hwallet h) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->sync(); } std::string invoke(hwallet h, const std::string& params) { - plain_wallet_api_impl* pimpl = (plain_wallet_api_impl*)h; + GET_INSTANCE(pimpl, h); return pimpl->invoke(params); } } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 6e503bb3..836b0f2d 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -9,15 +9,15 @@ namespace plain_wallet { - typedef void* hwallet; - hwallet create_instance(const std::string ip, const std::string port); + typedef int64_t hwallet; + hwallet create_instance(const std::string& ip, const std::string& port); void destroy_instance(hwallet h); - std::string open(hwallet h, const std::string& path, const std::string password); - std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string password); - std::string generate(hwallet h, const std::string& path, const std::string password); + std::string open(hwallet h, const std::string& path, const std::string& password); + std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password); + std::string generate(hwallet h, const std::string& path, const std::string& password); - void start_sync_thread(hwallet h); + std::string start_sync_thread(hwallet h); std::string get_sync_status(hwallet h); std::string sync(hwallet h); std::string invoke(hwallet h, const std::string& params); diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index c4b10ddf..15614968 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -9,7 +9,7 @@ namespace plain_wallet { typedef epee::json_rpc::response error_response; - plain_wallet_api_impl::plain_wallet_api_impl(const std::string ip, const std::string port): + plain_wallet_api_impl::plain_wallet_api_impl(const std::string& ip, const std::string& port): m_stop(false), m_sync_finished(false) { @@ -24,7 +24,7 @@ namespace plain_wallet m_sync_thread.join(); } - std::string plain_wallet_api_impl::open(const std::string& path, const std::string password) + std::string plain_wallet_api_impl::open(const std::string& path, const std::string& password) { error_response err_result = AUTO_VAL_INIT(err_result); try @@ -50,7 +50,7 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } - std::string plain_wallet_api_impl::restore(const std::string& seed, const std::string& path, const std::string password) + std::string plain_wallet_api_impl::restore(const std::string& seed, const std::string& path, const std::string& password) { error_response err_result = AUTO_VAL_INIT(err_result); try @@ -74,7 +74,7 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } - std::string plain_wallet_api_impl::generate(const std::string& path, const std::string password) + std::string plain_wallet_api_impl::generate(const std::string& path, const std::string& password) { error_response err_result = AUTO_VAL_INIT(err_result); try diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index dba03a77..2aede346 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -15,11 +15,11 @@ namespace plain_wallet class plain_wallet_api_impl { public: - plain_wallet_api_impl(const std::string ip, const std::string port); + plain_wallet_api_impl(const std::string& ip, const std::string& port); ~plain_wallet_api_impl(); - std::string open(const std::string& path, const std::string password); - std::string restore(const std::string& seed, const std::string& path, const std::string password); - std::string generate(const std::string& path, const std::string password); + std::string open(const std::string& path, const std::string& password); + std::string restore(const std::string& seed, const std::string& path, const std::string& password); + std::string generate(const std::string& path, const std::string& password); std::string start_sync_thread(); std::string cancel_sync_thread(); From 98f2d5e1554deabe5f8584d7fe0f9f8e4efbc934 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 00:49:12 +0100 Subject: [PATCH 18/28] fixed compilation issue --- src/wallet/plain_wallet_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 65dcd585..363e936d 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -47,7 +47,7 @@ namespace plain_wallet LOG_ERROR("Internall error: attempt to delete wallet with wrong instance id: " << h); } instance_ptr = it->second; - ginstances.erase(instance_ptr); + ginstances.erase(it); CRITICAL_REGION_END(); delete instance_ptr; } From 488be10664849bfc35effbf6df6ec9114f5cade7 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 00:58:48 +0100 Subject: [PATCH 19/28] added macos workaround for 'invokes deleted constructor' --- src/wallet/plain_wallet_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 363e936d..6744999d 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -9,7 +9,7 @@ //TODO: global objects, need refactoring. Just temporary solution std::map ginstances; epee::critical_section ginstances_lock; -std::atomic gcounter = 1; +std::atomic gcounter(1); #define GENERAL_INTERNAL_ERRROR_INSTANCE "GENERAL_INTERNAL_ERROR: WALLET INSTNACE NOT FOUND" From e690673498ba1518b5dde8067525aefaf0021600 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 18:23:09 +0100 Subject: [PATCH 20/28] added logs initializaion --- src/wallet/plain_wallet_api.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 6744999d..b7d0847d 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -5,11 +5,14 @@ #include "plain_wallet_api.h" #include "plain_wallet_api_impl.h" +#include "currency_core/currency_config.h" +#include "version.h" //TODO: global objects, need refactoring. Just temporary solution std::map ginstances; epee::critical_section ginstances_lock; std::atomic gcounter(1); +std::atomic glogs_initialized(false); #define GENERAL_INTERNAL_ERRROR_INSTANCE "GENERAL_INTERNAL_ERROR: WALLET INSTNACE NOT FOUND" @@ -25,10 +28,29 @@ std::atomic gcounter(1); CRITICAL_REGION_END(); + + namespace plain_wallet { + void initialize_logs() + { + char buffer[1000] = {}; + strcpy(buffer, getenv("HOME")); + std::string log_dir = buffer; + log_dir += "/Documents"; + epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2); + epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); + epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str()); + LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG); + + glogs_initialized = true; + } + hwallet create_instance(const std::string& ip, const std::string& port) { + if (!glogs_initialized) + initialize_logs(); + plain_wallet_api_impl* ptr = new plain_wallet_api_impl(ip, port); hwallet new_h = gcounter++; CRITICAL_REGION_BEGIN(ginstances_lock); From 47ef958d7e4522efc0701b24220ccebea7ba08a4 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 21:37:04 +0100 Subject: [PATCH 21/28] added library version --- src/wallet/plain_wallet_api.cpp | 5 +++++ src/wallet/plain_wallet_api.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index b7d0847d..d49100f1 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -46,6 +46,11 @@ namespace plain_wallet glogs_initialized = true; } + std::string get_version() + { + return PROJECT_VERSION_LONG; + } + hwallet create_instance(const std::string& ip, const std::string& port) { if (!glogs_initialized) diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 836b0f2d..dd481299 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -12,6 +12,7 @@ namespace plain_wallet typedef int64_t hwallet; hwallet create_instance(const std::string& ip, const std::string& port); void destroy_instance(hwallet h); + std::string get_version(); std::string open(hwallet h, const std::string& path, const std::string& password); std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password); From 6ff8669843e0ba1f6d22f7177d0bb260e72d8ffe Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 28 Jan 2020 21:56:17 +0100 Subject: [PATCH 22/28] added wallets list api --- src/wallet/plain_wallet_api.cpp | 31 +++++++++++++++++++++++++++---- src/wallet/plain_wallet_api.h | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index d49100f1..5fbd09a3 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -32,16 +32,21 @@ std::atomic glogs_initialized(false); namespace plain_wallet { + std::string get_bundle_root_dir() + { + char buffer[1000] = {0}; + strcpy(buffer, getenv("HOME")); + return buffer; + } + void initialize_logs() { - char buffer[1000] = {}; - strcpy(buffer, getenv("HOME")); - std::string log_dir = buffer; + std::string log_dir = get_bundle_root_dir(); log_dir += "/Documents"; epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2); epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str()); - LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG); + LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ", log location: " << log_dir + "/plain_wallet.log"); glogs_initialized = true; } @@ -51,6 +56,24 @@ namespace plain_wallet return PROJECT_VERSION_LONG; } + struct strings_list + { + std::list items; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(items) + END_KV_SERIALIZE_MAP() + + }; + + std::string get_wallet_files() + { + std::string wallet_files_path = get_bundle_root_dir() + "/Documents"; + strings_list sl = AUTO_VAL_INIT(sl); + epee::file_io_utils::get_folder_content(wallet_files_path, sl.items, true); + return epee::serialization::store_t_to_json(sl); + } + hwallet create_instance(const std::string& ip, const std::string& port) { if (!glogs_initialized) diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index dd481299..0b9bb92a 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -13,6 +13,7 @@ namespace plain_wallet hwallet create_instance(const std::string& ip, const std::string& port); void destroy_instance(hwallet h); std::string get_version(); + std::string get_wallet_files(); std::string open(hwallet h, const std::string& path, const std::string& password); std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password); From c2ca2c8177651835e48d87f1518b7271ef316690 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 1 Feb 2020 19:43:57 +0100 Subject: [PATCH 23/28] extended api for working with filenames and bundle dir --- src/wallet/plain_wallet_api.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 5fbd09a3..abaf493d 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -38,6 +38,11 @@ namespace plain_wallet strcpy(buffer, getenv("HOME")); return buffer; } + + std::string get_wallets_folder() + { + return get_bundle_root_dir() + "/Documents"; + } void initialize_logs() { @@ -68,7 +73,7 @@ namespace plain_wallet std::string get_wallet_files() { - std::string wallet_files_path = get_bundle_root_dir() + "/Documents"; + std::string wallet_files_path = get_wallets_folder(); strings_list sl = AUTO_VAL_INIT(sl); epee::file_io_utils::get_folder_content(wallet_files_path, sl.items, true); return epee::serialization::store_t_to_json(sl); @@ -104,17 +109,20 @@ namespace plain_wallet std::string open(hwallet h, const std::string& path, const std::string& password) { GET_INSTANCE(pimpl, h); - return pimpl->open(path, password); + std::string full_path = get_wallets_folder() + "/" + path; + return pimpl->open(full_path, password); } std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password) { GET_INSTANCE(pimpl, h); - return pimpl->restore(seed, path, password); + std::string full_path = get_wallets_folder() + "/" + path; + return pimpl->restore(seed, full_path, password); } std::string generate(hwallet h, const std::string& path, const std::string& password) { GET_INSTANCE(pimpl, h); - return pimpl->generate(path, password); + std::string full_path = get_wallets_folder() + "/" + path; + return pimpl->generate(full_path, password); } std::string start_sync_thread(hwallet h) { From 5a0dc75aab863baadf407607b81d2245e40ddd19 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 1 Feb 2020 23:47:37 +0100 Subject: [PATCH 24/28] extended plain wallet api for interruptin sync thread --- src/wallet/plain_wallet_api.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index abaf493d..b5241548 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -135,6 +135,12 @@ namespace plain_wallet GET_INSTANCE(pimpl, h); return pimpl->get_sync_status(); } + + std::string cancel_sync_thread(hwallet h) + { + GET_INSTANCE(pimpl, h); + return pimpl->cancel_sync_thread(); + } std::string sync(hwallet h) { GET_INSTANCE(pimpl, h); From 6805e9abedc1ef81567563b1722a3baf96a00807 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 1 Feb 2020 23:49:59 +0100 Subject: [PATCH 25/28] extended plain wallet api for interruptin sync thread-2 --- src/wallet/plain_wallet_api.cpp | 1 + src/wallet/plain_wallet_api.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index b5241548..8f8846c1 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -141,6 +141,7 @@ namespace plain_wallet GET_INSTANCE(pimpl, h); return pimpl->cancel_sync_thread(); } + std::string sync(hwallet h) { GET_INSTANCE(pimpl, h); diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 0b9bb92a..ae58ba0c 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -21,6 +21,7 @@ namespace plain_wallet std::string start_sync_thread(hwallet h); std::string get_sync_status(hwallet h); + std::string cancel_sync_thread(hwallet h); std::string sync(hwallet h); std::string invoke(hwallet h, const std::string& params); } \ No newline at end of file From ff0bf643572de9b126ff5c671721390c0cdc07d7 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 3 Feb 2020 02:11:20 +0100 Subject: [PATCH 26/28] added synchronization to plain_wallet --- src/wallet/plain_wallet_api.cpp | 2 +- src/wallet/plain_wallet_api_impl.cpp | 33 +++++++++++++++++----------- src/wallet/plain_wallet_api_impl.h | 1 + 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 8f8846c1..701408ea 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -21,7 +21,7 @@ std::atomic glogs_initialized(false); auto it = ginstances.find(instance_handle);\ if (it == ginstances.end())\ {\ - LOG_ERROR("Internall error: attempt to delete wallet with wrong instance id: " << instance_handle);\ + LOG_ERROR("Internall error: attempt to get instance wallet with wrong id: " << instance_handle);\ return GENERAL_INTERNAL_ERRROR_INSTANCE;\ }\ var_name = it->second;\ diff --git a/src/wallet/plain_wallet_api_impl.cpp b/src/wallet/plain_wallet_api_impl.cpp index 15614968..249dca78 100644 --- a/src/wallet/plain_wallet_api_impl.cpp +++ b/src/wallet/plain_wallet_api_impl.cpp @@ -29,7 +29,13 @@ namespace plain_wallet error_response err_result = AUTO_VAL_INIT(err_result); try { + CRITICAL_REGION_LOCAL(m_wallet_lock); m_wallet->load(epee::string_encoding::utf8_to_wstring(path), password); + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + m_wallet->get_recent_transfers_history(ok_response.result.recent_history.history, 0, 20, ok_response.result.recent_history.total_history_items); + m_wallet->get_unconfirmed_transfers(ok_response.result.recent_history.history); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); } catch (const tools::error::wallet_load_notice_wallet_restored& e) { @@ -43,11 +49,6 @@ namespace plain_wallet err_result.error.code = API_RETURN_CODE_FAIL; return epee::serialization::store_t_to_json(err_result); } - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - m_wallet->get_recent_transfers_history(ok_response.result.recent_history.history, 0, 20, ok_response.result.recent_history.total_history_items); - m_wallet->get_unconfirmed_transfers(ok_response.result.recent_history.history); - tools::get_wallet_info(*m_wallet, ok_response.result.wi); - return epee::serialization::store_t_to_json(ok_response); } std::string plain_wallet_api_impl::restore(const std::string& seed, const std::string& path, const std::string& password) @@ -55,7 +56,12 @@ namespace plain_wallet error_response err_result = AUTO_VAL_INIT(err_result); try { + CRITICAL_REGION_LOCAL(m_wallet_lock); m_wallet->restore(epee::string_encoding::utf8_to_wstring(path), password, seed); + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); + } catch (const tools::error::wallet_load_notice_wallet_restored& e) { @@ -69,9 +75,6 @@ namespace plain_wallet err_result.error.code = API_RETURN_CODE_FAIL; return epee::serialization::store_t_to_json(err_result); } - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - tools::get_wallet_info(*m_wallet, ok_response.result.wi); - return epee::serialization::store_t_to_json(ok_response); } std::string plain_wallet_api_impl::generate(const std::string& path, const std::string& password) @@ -79,7 +82,11 @@ namespace plain_wallet error_response err_result = AUTO_VAL_INIT(err_result); try { + CRITICAL_REGION_LOCAL(m_wallet_lock); m_wallet->generate(epee::string_encoding::utf8_to_wstring(path), password); + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); + tools::get_wallet_info(*m_wallet, ok_response.result.wi); + return epee::serialization::store_t_to_json(ok_response); } catch (const tools::error::wallet_load_notice_wallet_restored& e) { @@ -93,9 +100,6 @@ namespace plain_wallet err_result.error.code = API_RETURN_CODE_FAIL; return epee::serialization::store_t_to_json(err_result); } - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - tools::get_wallet_info(*m_wallet, ok_response.result.wi); - return epee::serialization::store_t_to_json(ok_response); } std::string plain_wallet_api_impl::start_sync_thread() @@ -105,6 +109,7 @@ namespace plain_wallet try { + CRITICAL_REGION_LOCAL(m_wallet_lock); m_wallet->refresh(m_stop); } catch (const std::exception& e) @@ -143,7 +148,10 @@ namespace plain_wallet basic_status_response bsr = AUTO_VAL_INIT(bsr); try { + CRITICAL_REGION_LOCAL(m_wallet_lock); m_wallet->refresh(m_stop); + bsr.status = API_RETURN_CODE_OK; + return epee::serialization::store_t_to_json(bsr); } catch (const std::exception& e) { @@ -151,11 +159,10 @@ namespace plain_wallet bsr.status = API_RETURN_CODE_FAIL; return epee::serialization::store_t_to_json(bsr); } - bsr.status = API_RETURN_CODE_OK; - return epee::serialization::store_t_to_json(bsr); } std::string plain_wallet_api_impl::invoke(const std::string& params) { + CRITICAL_REGION_LOCAL(m_wallet_lock); epee::net_utils::http::http_request_info query_info = AUTO_VAL_INIT(query_info); epee::net_utils::http::http_response_info response_info = AUTO_VAL_INIT(response_info); epee::net_utils::connection_context_base stub_conn_context = AUTO_VAL_INIT(stub_conn_context); diff --git a/src/wallet/plain_wallet_api_impl.h b/src/wallet/plain_wallet_api_impl.h index 2aede346..310c37a5 100644 --- a/src/wallet/plain_wallet_api_impl.h +++ b/src/wallet/plain_wallet_api_impl.h @@ -30,6 +30,7 @@ namespace plain_wallet private: bool get_wallet_info(view::wallet_info& wi); std::thread m_sync_thread; + epee::critical_section m_wallet_lock; std::atomic m_stop; std::atomic m_sync_finished; std::shared_ptr m_wallet; From 7129c80832c8c087e2eef7e39f8d79e444a95879 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 3 Feb 2020 16:58:02 +0100 Subject: [PATCH 27/28] extended rpc api for plain wallet needs --- src/wallet/wallet_public_structs_defs.h | 61 +++++++++++++++++++++++++ src/wallet/wallet_rpc_server.cpp | 25 ++++++++++ src/wallet/wallet_rpc_server.h | 2 + 3 files changed, 88 insertions(+) diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index d2b3862a..764ee1b4 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -5,6 +5,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #pragma once +#include #include "currency_protocol/currency_protocol_defs.h" #include "currency_core/currency_basic.h" #include "crypto/hash.h" @@ -236,6 +237,66 @@ namespace wallet_public }; }; + + struct wallet_provision_info + { + uint64_t transfers_count; + uint64_t transfer_entries_count; + uint64_t balance; + uint64_t unlocked_balance; + + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(transfers_count) + KV_SERIALIZE(transfer_entries_count) + KV_SERIALIZE(balance) + KV_SERIALIZE(unlocked_balance) + END_KV_SERIALIZE_MAP() + }; + + struct COMMAND_RPC_GET_RECENT_TXS_AND_INFO + { + struct request + { + + /* + if offset is 0, then GET_RECENT_TXS_AND_INFO return + unconfirmed transactions as the first first items of "transfers", + this unconfirmed transactions is not counted regarding "count" parameter + */ + uint64_t offset; + uint64_t count; + + /* + need_to_get_info - should backend re-calculate balance(could be relatively heavy, + and not needed when getting long tx history with multiple calls + of GET_RECENT_TXS_AND_INFO with offsets) + */ + bool update_provision_info; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(offset) + KV_SERIALIZE(count) + KV_SERIALIZE(update_provision_info) + END_KV_SERIALIZE_MAP() + }; + + struct response + { + wallet_provision_info pi; + std::vector transfers; + uint64_t total_transfers; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(pi) + KV_SERIALIZE(transfers) + KV_SERIALIZE(total_transfers) + END_KV_SERIALIZE_MAP() + }; + }; + + + struct trnsfer_destination { diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index a90de9dd..1cf0dbc2 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -209,6 +209,31 @@ namespace tools return false; } } + bool wallet_rpc_server::on_get_recent_txs_and_info(const wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request& req, wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx) + { + try + { + if (req.update_provision_info) + { + res.pi.balance = m_wallet.balance(res.pi.unlocked_balance); + res.pi.transfer_entries_count = m_wallet.get_transfer_entries_count(); + res.pi.transfers_count = m_wallet.get_recent_transfers_total_count(); + } + + if (req.offset == 0) + m_wallet.get_unconfirmed_transfers(res.transfers); + + m_wallet.get_recent_transfers_history(res.transfers, req.offset, req.count, res.total_transfers); + + return true; + } + catch (std::exception& e) + { + er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR; + er.message = e.what(); + return false; + } + } //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_transfer(const wallet_public::COMMAND_RPC_TRANSFER::request& req, wallet_public::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx) { diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index a3f1e19a..d0a1ef12 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -40,6 +40,7 @@ namespace tools MAP_JON_RPC_WE("getbalance", on_getbalance, wallet_public::COMMAND_RPC_GET_BALANCE) MAP_JON_RPC_WE("getaddress", on_getaddress, wallet_public::COMMAND_RPC_GET_ADDRESS) MAP_JON_RPC_WE("get_wallet_info", on_getwallet_info, wallet_public::COMMAND_RPC_GET_WALLET_INFO) + MAP_JON_RPC_WE("get_recent_txs_and_info", on_get_recent_txs_and_info, wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO) MAP_JON_RPC_WE("transfer", on_transfer, wallet_public::COMMAND_RPC_TRANSFER) MAP_JON_RPC_WE("store", on_store, wallet_public::COMMAND_RPC_STORE) MAP_JON_RPC_WE("get_payments", on_get_payments, wallet_public::COMMAND_RPC_GET_PAYMENTS) @@ -68,6 +69,7 @@ namespace tools bool on_getbalance(const wallet_public::COMMAND_RPC_GET_BALANCE::request& req, wallet_public::COMMAND_RPC_GET_BALANCE::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_getaddress(const wallet_public::COMMAND_RPC_GET_ADDRESS::request& req, wallet_public::COMMAND_RPC_GET_ADDRESS::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_getwallet_info(const wallet_public::COMMAND_RPC_GET_WALLET_INFO::request& req, wallet_public::COMMAND_RPC_GET_WALLET_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx); + bool on_get_recent_txs_and_info(const wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request& req, wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_transfer(const wallet_public::COMMAND_RPC_TRANSFER::request& req, wallet_public::COMMAND_RPC_TRANSFER::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_store(const wallet_public::COMMAND_RPC_STORE::request& req, wallet_public::COMMAND_RPC_STORE::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_get_payments(const wallet_public::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_public::COMMAND_RPC_GET_PAYMENTS::response& res, epee::json_rpc::error& er, connection_context& cntx); From 1bcd7e8bb6459cb368177cefebe066c9e3bd741a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 3 Feb 2020 17:16:25 +0100 Subject: [PATCH 28/28] clean cmake edits --- CMakeLists.txt | 2 +- contrib/CMakeLists.txt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5b2348a..dae368fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(Boost_LIBRARIES "libboost.a") set(Boost_VERSION "ofxiOSBoost 1.60.0") else() - find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem locale thread timer date_time chrono regex serialization atomic program_options ) #locale + find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) endif() diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 853e70d4..b9ebc127 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -7,7 +7,7 @@ add_subdirectory(ethereum) if(CMAKE_SYSTEM_NAME STREQUAL "iOS") - message("excluded db support for IOS build") + message("excluded upnp support for IOS build") return() endif() add_subdirectory(miniupnp/miniupnpc) @@ -17,7 +17,8 @@ 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") -#set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat minigzip zlib PROPERTY FOLDER "unused") +set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat minigzip zlib example PROPERTY FOLDER "unused") + if(MSVC) set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused") endif()