From 8724403f517ebf12db59fe8befe414f28a85ca58 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 16 Dec 2020 20:34:56 -0500 Subject: [PATCH] fix ambiguous call to overloaded function with template specialization update to monero-project v0.17.1.6 update readme --- CMakeLists.txt | 28 ++++++++++++---------------- README.md | 17 +++++++---------- bin/update_submodules.sh | 4 ++-- external/monero-core | 2 +- src/utils/monero_utils.cpp | 18 ------------------ src/utils/monero_utils.h | 12 +++++++++--- 6 files changed, 31 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 271110f..34f0125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,15 +242,9 @@ set( ) if (BUILD_LIBRARY) - add_library(monero-cpp SHARED ${LIBRARY_SRC_FILES}) target_link_libraries(monero-cpp - - ${Boost_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${SODIUM_LIBRARY} - ${HIDAPI_LIBRARIES} wallet_merged wallet_crypto @@ -277,6 +271,10 @@ if (BUILD_LIBRARY) version randomx + ${Boost_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} ${EXTRA_LIBRARIES} ) endif() @@ -292,11 +290,6 @@ if (BUILD_SAMPLE) target_link_libraries(sample_code - ${Boost_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${SODIUM_LIBRARY} - ${HIDAPI_LIBRARIES} - wallet_merged wallet_crypto #wallet_api @@ -322,6 +315,10 @@ if (BUILD_SAMPLE) version randomx + ${Boost_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} ${EXTRA_LIBRARIES} ) endif() @@ -337,11 +334,6 @@ if (BUILD_SCRATCHPAD) target_link_libraries(scratchpad - ${Boost_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${SODIUM_LIBRARY} - ${HIDAPI_LIBRARIES} - wallet_merged wallet_crypto #wallet_api @@ -367,6 +359,10 @@ if (BUILD_SCRATCHPAD) version randomx + ${Boost_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${SODIUM_LIBRARY} + ${HIDAPI_LIBRARIES} ${EXTRA_LIBRARIES} ) endif() \ No newline at end of file diff --git a/README.md b/README.md index d3a4b98..59e1651 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Monero C++ Library -A C++ library for creating Monero applications using native bindings to [monero v0.17.1.6 'Oxygen Orion'](https://github.com/monero-project/monero/tree/v0.17.1.6). +A C++ library for creating Monero applications using native bindings to [monero v0.17.1.7 'Oxygen Orion'](https://github.com/monero-project/monero/tree/v0.17.1.7). * Supports fully client-side wallets by wrapping [wallet2.h](https://github.com/monero-project/monero/blob/master/src/wallet/wallet2.h). * Supports multisig, view-only, and offline wallets. @@ -161,16 +161,13 @@ This project may be compiled as part of another application or built as a shared For example, [monero-java](https://github.com/monero-ecosystem/monero-java) compiles this project to a shared library to support Java JNI bindings, while [monero-javascript](https://github.com/monero-ecosystem/monero-javascript) compiles this project to WebAssembly binaries. -1. Install dependencies using your system's package manager: - * Boost - * OpenSSL - * HIDAPI - * Sodium +1. Clone this project repository (unless included as a submodule in another project): `git clone --recurse-submodules https://github.com/monero-ecosystem/monero-cpp.git` 2. Build monero-project: - 1. Update submodules: `./bin/update_submodules.sh` - 2. `cd ./external/monero-core` - 3. Modify CMakeLists.txt: `option(BUILD_GUI_DEPS "Build GUI dependencies." ON)` - 4. Run twice to create libwallet_merged.a in addition to other .a libraries: `make release-static -j16` + 1. Install [dependencies](https://github.com/monero-project/monero#dependencies) using your system's package manager (boost, openssl, hidapi, sodium, etc) + 2. Update submodules: `./bin/update_submodules.sh` + 3. `cd ./external/monero-core` + 4. Modify CMakeLists.txt: `option(BUILD_GUI_DEPS "Build GUI dependencies." ON)` + 5. Run twice to create libwallet_merged.a in addition to other .a libraries: `make release-static -j16` 3. Link to this library's source files in your application or build as a shared library in ./build/: `./bin/build_libmonero_cpp.sh` ## Developer guide diff --git a/bin/update_submodules.sh b/bin/update_submodules.sh index 3889534..bf8087c 100755 --- a/bin/update_submodules.sh +++ b/bin/update_submodules.sh @@ -5,6 +5,6 @@ git submodule update --init --force --recursive # update monero-core cd ./external/monero-core -git checkout tags/v0.17.1.6 -git pull --ff-only origin tags/v0.17.1.6 +git checkout tags/v0.17.1.7 +git pull --ff-only origin tags/v0.17.1.7 cd ../../ \ No newline at end of file diff --git a/external/monero-core b/external/monero-core index 3942a1c..54a4071 160000 --- a/external/monero-core +++ b/external/monero-core @@ -1 +1 @@ -Subproject commit 3942a1cd043bb103ca05184057aea5c86e3137e5 +Subproject commit 54a4071473432f30b83638a98779941e0b164f39 diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index 70b0a1a..dfab554 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -136,24 +136,6 @@ std::string monero_utils::serialize(const rapidjson::Document& doc) { return buffer.GetString(); } -void monero_utils::addJsonMember(std::string key, uint8_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) { - rapidjson::Value field_key(key.c_str(), key.size(), allocator); - field.SetInt(val); - root.AddMember(field_key, field, allocator); -} - -void monero_utils::addJsonMember(std::string key, uint32_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) { - rapidjson::Value field_key(key.c_str(), key.size(), allocator); - field.SetUint64(val); - root.AddMember(field_key, field, allocator); -} - -void monero_utils::addJsonMember(std::string key, uint64_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) { - rapidjson::Value field_key(key.c_str(), key.size(), allocator); - field.SetUint64(val); - root.AddMember(field_key, field, allocator); -} - void monero_utils::addJsonMember(std::string key, std::string val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) { rapidjson::Value field_key(key.c_str(), key.size(), allocator); field.SetString(val.c_str(), val.size(), allocator); diff --git a/src/utils/monero_utils.h b/src/utils/monero_utils.h index d52f737..8308262 100644 --- a/src/utils/monero_utils.h +++ b/src/utils/monero_utils.h @@ -81,9 +81,15 @@ namespace monero_utils std::string serialize(const rapidjson::Document& doc); - void addJsonMember(std::string key, uint8_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field); - void addJsonMember(std::string key, uint32_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field); - void addJsonMember(std::string key, uint64_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field); + /** + * Add number, string, and boolean json members using template specialization. + */ + template + void addJsonMember(std::string key, T val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) { + rapidjson::Value field_key(key.c_str(), key.size(), allocator); + field.SetInt64((uint64_t) val); + root.AddMember(field_key, field, allocator); + } void addJsonMember(std::string key, std::string val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field); void addJsonMember(std::string key, bool val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root);