-This project may be compiled as part of another application or built as a shared or static library.
+#include "wallet/wownero_wallet_full.h"
+#include "utils/wownero_utils.h"
-For example, [monero-java](https://github.com/woodser/monero-java) compiles this project to a shared library to support Java JNI bindings, while [monero-ts](https://github.com/woodser/monero-ts) compiles this project to WebAssembly binaries.
+using namespace std;
+wownero_wallet* wallet_restored = nullptr;
-### Linux
+int main() {
+ // create a wallet from a seed phrase into /tmp/test.keys
+ wownero_wallet_config wallet_config;
+ wallet_config.m_seed = "afar industrial unafraid input ulcers innocent aggravate pulp insult sawmill ankle smash niece hydrogen mouth issued unusual pride fully identity fever hatchet knife knowledge issued";
+ wallet_config.m_path = "/tmp/test";
+ wallet_config.m_password = "";
+ wallet_config.m_network_type = wownero_network_type::MAINNET;
+ // configure your own remote node here
+ wallet_config.m_server = wownero_rpc_connection("http://10.1.0.10:34568", "", "");
+ wallet_config.m_restore_height = 610000;
+ wallet_config.m_seed_offset = "";
+ wallet_restored = wownero_wallet_full::create_wallet(wallet_config);
+ wallet_restored->save();
-1. Clone the project repository if applicable: `git clone --recurse-submodules https://github.com/woodser/monero-cpp.git`
-2. Update submodules: `cd monero-cpp && ./bin/update_submodules.sh`
-3. `sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz nettle-dev libevent-dev`
-4. Follow instructions to install [unbound](https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/installation.html) for Linux to your home directory (e.g. `~/unbound-1.19.0`).
+ // synchronize the wallet and receive progress notifications
+ struct : wownero_wallet_listener {
+ void on_sync_progress(uint64_t height, uint64_t start_height, uint64_t end_height, double percent_done, const string& message) {
+ // feed a progress bar?
+ printf("%f", percent_done);
+ wallet_restored->save();
+ }
+ } my_sync_listener;
- For example, install expat:
- ```
- cd ~
- wget https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.bz2
- tar -xf expat-2.4.8.tar.bz2
- sudo rm expat-2.4.8.tar.bz2
- cd expat-2.4.8
- ./configure --enable-static --disable-shared
- make
- sudo make install
- cd ../
- ```
+ wallet_restored->sync(my_sync_listener);
- For example, install unbound:
- ```
- cd ~
- wget https://www.nlnetlabs.nl/downloads/unbound/unbound-1.19.0.tar.gz
- tar xzf unbound-1.19.0.tar.gz
- sudo apt update
- sudo apt install -y build-essential
- sudo apt install -y libssl-dev
- sudo apt install -y libexpat1-dev
- sudo apt-get install -y bison
- sudo apt-get install -y flex
- cd unbound-1.19.0
- ./configure --with-libexpat=/usr --with-ssl=/usr
- make
- sudo make install
- cd ../
- ```
-5. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with: `make release-static -j8`
-6. Link to this library's source files in your application, or build monero-cpp to a shared library in ./build: `./bin/build_libmonero_cpp.sh`
+ // start syncing the wallet continuously in the background
+ wallet_restored->start_syncing();
-### macOS
-
-1. Clone the project repository if applicable: `git clone --recurse-submodules https://github.com/woodser/monero-cpp.git`
-2. Update submodules: `cd monero-cpp && ./bin/update_submodules.sh`
-3. Follow instructions to install [unbound](https://unbound.docs.nlnetlabs.nl/en/latest/getting-started/installation.html) for macOS to your home directory (e.g. `~/unbound-1.19.0`).
-
- For example:
- ```
- cd ~
- wget https://nlnetlabs.nl/downloads/unbound/unbound-1.19.0.tar.gz
- tar xzf unbound-1.19.0.tar.gz
- cd ~/unbound-1.19.0
- ./configure --with-ssl=/opt/homebrew/Cellar/openssl@3/3.2.1/ --with-libexpat=/opt/homebrew/Cellar/expat/2.5.0
- make
- sudo make install
- ```
-4. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with: `make release-static -j8`
-5. Link to this library's source files in your application, or build monero-cpp to a shared library in ./build: `./bin/build_libmonero_cpp.sh`
-
-### Windows
-
-1. Download and install [MSYS2](https://www.msys2.org/).
-2. Press the Windows button and launch `MSYS2 MINGW64` for 64 bit systems or `MSYS2 MINGW32` for 32 bit.
-3. Update packages: `pacman -Syu` and confirm at prompts.
-4. Relaunch MSYS2 (if necessary) and install dependencies:
-
- For 64 bit:
-
- ```
- pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound mingw-w64-x86_64-protobuf git mingw-w64-x86_64-libusb gettext base-devel
- ```
-
- For 32 bit:
-
- ```
- pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound mingw-w64-i686-protobuf git mingw-w64-i686-libusb gettext base-devel
- ```
-5. Clone repo if installing standalone (skip if building as part of another repo like monero-java or monero-ts): `git clone --recursive https://github.com/woodser/monero-cpp.git`
-6. Update submodules: `cd monero-cpp && ./bin/update_submodules.sh`
-7. Build monero-project, located as a submodule at ./external/monero-project. Install [dependencies](https://github.com/monero-project/monero#dependencies) as needed for your system, then build with:
-
- For 64 bit: `make release-static-win64`
-
- For 32 bit: `make release-static-win32`
-8. Link to this library's source files in your application, or build monero-cpp to a shared library (libmonero-cpp.dll) in ./build: `./bin/build_libmonero_cpp.sh`
-
-## Running sample code and tests
-
-1. In CMakeLists.txt, set the flags to build:
-
- set(BUILD_LIBRARY ON)
- set(BUILD_SAMPLE ON)
- set(BUILD_SCRATCHPAD ON)
- set(BUILD_TESTS ON)
-2. `./bin/build_libmonero_cpp.sh`
-3. Run the app, for example: `./build/sample_code`
-
-## Related projects
-
-* [monero-java](https://github.com/woodser/monero-java)
-* [monero-ts](https://github.com/woodser/monero-ts)
-
-## License
-
-This project is licensed under MIT.
-
-## Donations
-
-If this library brings you value, please consider donating.
-
-
- 
- 46FR1GKVqFNQnDiFkH7AuzbUBrGQwz2VdaXTDD4jcjRE8YkkoTYTmZ2Vohsz9gLSqkj5EM6ai9Q7sBoX4FPPYJdGKQQXPVz
-
+ return 0;
+}
+```
diff --git a/bin/build_libmonero_cpp.sh b/bin/build_libmonero_cpp.sh
deleted file mode 100755
index 8056d10..0000000
--- a/bin/build_libmonero_cpp.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-# build monero-project dependencies
-cd ./external/monero-project/ || exit 1
-git submodule update --init --force || exit 1
-HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
-if [[ "$OSTYPE" == "msys" ]]; then
- bit=$(getconf LONG_BIT)
- if [ "$bit" == "64" ]; then
- make release-static-win64 -j$HOST_NCORES || exit 1
- else
- make release-static-win32 -j$HOST_NCORES || exit 1
- fi
-elif [[ "$OSTYPE" == "cygwin" ]]; then
- echo "monero-project supports building on Windows only with MSYS"
- exit 1
-else
- # OS is not windows
- make release-static -j$HOST_NCORES || exit 1
-fi
-cd ../../
-
-# build libmonero-cpp shared library
-mkdir -p build &&
-cd build &&
-cmake .. &&
-cmake --build . &&
-make .
\ No newline at end of file
diff --git a/bin/update_submodules.sh b/bin/update_submodules.sh
deleted file mode 100755
index 9108ee1..0000000
--- a/bin/update_submodules.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-# initialize submodules recursively
-git submodule update --init --force --recursive
-
-# update monero-project
-cd ./external/monero-project
-git checkout master
-git pull --ff-only origin master
-cd ../../
\ No newline at end of file
diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
new file mode 100644
index 0000000..ad2567f
--- /dev/null
+++ b/cmake/Config.cmake.in
@@ -0,0 +1,8 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/wownero_cppTargets.cmake")
+
+find_package(Wownero REQUIRED)
+
+check_required_components(wownero_cpp)
+check_required_components(Wownero)
\ No newline at end of file
diff --git a/cmake/FindCcache.cmake b/cmake/FindCcache.cmake
new file mode 100644
index 0000000..29e2d24
--- /dev/null
+++ b/cmake/FindCcache.cmake
@@ -0,0 +1,56 @@
+# Copyright (c) 2014-2020, The Monero Project
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other
+# materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be
+# used to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# - Try to find readline include dirs and libraries
+#
+# Automatically finds ccache build accelerator, if it's found in PATH.
+#
+# Usage of this module as follows:
+#
+# project(monero)
+# include(FindCcache) # Include AFTER the project() macro to be able to reach the CMAKE_CXX_COMPILER variable
+#
+# Properties modified by this module:
+#
+# GLOBAL PROPERTY RULE_LAUNCH_COMPILE set to ccache, when ccache found
+# GLOBAL PROPERTY RULE_LAUNCH_LINK set to ccache, when ccache found
+
+find_program(CCACHE_FOUND ccache)
+if (CCACHE_FOUND)
+ set(TEMP_CPP_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test-program.cpp")
+ file(WRITE "${TEMP_CPP_FILE}" "int main() { return 0; }")
+ execute_process(COMMAND "${CCACHE_FOUND}" "${CMAKE_CXX_COMPILER}" "${TEMP_CPP_FILE}" RESULT_VARIABLE RET)
+ if (${RET} EQUAL 0)
+ message("found usable ccache: ${CCACHE_FOUND}")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_FOUND}")
+ else()
+ message("found ccache ${CCACHE_FOUND}, but is UNUSABLE! Return code: ${RET}")
+ endif()
+else()
+ message("ccache NOT found!")
+endif()
diff --git a/cmake/FindHIDAPI.cmake b/cmake/FindHIDAPI.cmake
deleted file mode 100644
index 9b45dcc..0000000
--- a/cmake/FindHIDAPI.cmake
+++ /dev/null
@@ -1,60 +0,0 @@
-# - try to find HIDAPI library
-# from http://www.signal11.us/oss/hidapi/
-#
-# Cache Variables: (probably not for direct use in your scripts)
-# HIDAPI_INCLUDE_DIR
-# HIDAPI_LIBRARY
-#
-# Non-cache variables you might use in your CMakeLists.txt:
-# HIDAPI_FOUND
-# HIDAPI_INCLUDE_DIRS
-# HIDAPI_LIBRARIES
-#
-# Requires these CMake modules:
-# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
-#
-# Original Author:
-# 2009-2010 Ryan Pavlik
-# http://academic.cleardefinition.com
-# Iowa State University HCI Graduate Program/VRAC
-#
-# Copyright Iowa State University 2009-2010.
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-find_library(HIDAPI_LIBRARY
- NAMES hidapi hidapi-libusb)
-
-find_path(HIDAPI_INCLUDE_DIR
- NAMES hidapi.h
- PATH_SUFFIXES
- hidapi)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(HIDAPI
- DEFAULT_MSG
- HIDAPI_LIBRARY
- HIDAPI_INCLUDE_DIR)
-
-if(HIDAPI_FOUND)
- set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}")
- if((STATIC AND UNIX AND NOT APPLE) OR (DEPENDS AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
- find_library(LIBUSB-1.0_LIBRARY usb-1.0)
- find_library(LIBUDEV_LIBRARY udev)
- if(LIBUSB-1.0_LIBRARY)
- set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUSB-1.0_LIBRARY}")
- if(LIBUDEV_LIBRARY)
- set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARIES};${LIBUDEV_LIBRARY}")
- else()
- message(WARNING "libudev library not found, binaries may fail to link.")
- endif()
- else()
- message(WARNING "libusb-1.0 library not found, binaries may fail to link.")
- endif()
- endif()
-
- set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}")
-endif()
-
-mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY)
diff --git a/donate.png b/donate.png
deleted file mode 100644
index 8d65e01..0000000
Binary files a/donate.png and /dev/null differ
diff --git a/external/libsodium/include/sodium/crypto_verify_16.h b/external/libsodium/include/sodium/crypto_verify_16.h
deleted file mode 100644
index 5e9eeab..0000000
--- a/external/libsodium/include/sodium/crypto_verify_16.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef crypto_verify_16_H
-#define crypto_verify_16_H
-
-#include
-#include "export.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define crypto_verify_16_BYTES 16U
-SODIUM_EXPORT
-size_t crypto_verify_16_bytes(void);
-
-SODIUM_EXPORT
-int crypto_verify_16(const unsigned char *x, const unsigned char *y)
- __attribute__ ((warn_unused_result));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/external/libsodium/include/sodium/crypto_verify_32.h b/external/libsodium/include/sodium/crypto_verify_32.h
deleted file mode 100644
index 281b5a1..0000000
--- a/external/libsodium/include/sodium/crypto_verify_32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef crypto_verify_32_H
-#define crypto_verify_32_H
-
-#include
-#include "export.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define crypto_verify_32_BYTES 32U
-SODIUM_EXPORT
-size_t crypto_verify_32_bytes(void);
-
-SODIUM_EXPORT
-int crypto_verify_32(const unsigned char *x, const unsigned char *y)
- __attribute__ ((warn_unused_result));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/external/libsodium/include/sodium/crypto_verify_64.h b/external/libsodium/include/sodium/crypto_verify_64.h
deleted file mode 100644
index 0dc7c30..0000000
--- a/external/libsodium/include/sodium/crypto_verify_64.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef crypto_verify_64_H
-#define crypto_verify_64_H
-
-#include
-#include "export.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define crypto_verify_64_BYTES 64U
-SODIUM_EXPORT
-size_t crypto_verify_64_bytes(void);
-
-SODIUM_EXPORT
-int crypto_verify_64(const unsigned char *x, const unsigned char *y)
- __attribute__ ((warn_unused_result));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/external/libsodium/include/sodium/export.h b/external/libsodium/include/sodium/export.h
deleted file mode 100644
index a0074fc..0000000
--- a/external/libsodium/include/sodium/export.h
+++ /dev/null
@@ -1,57 +0,0 @@
-
-#ifndef sodium_export_H
-#define sodium_export_H
-
-#include
-#include
-#include
-
-#if !defined(__clang__) && !defined(__GNUC__)
-# ifdef __attribute__
-# undef __attribute__
-# endif
-# define __attribute__(a)
-#endif
-
-#ifdef SODIUM_STATIC
-# define SODIUM_EXPORT
-# define SODIUM_EXPORT_WEAK
-#else
-# if defined(_MSC_VER)
-# ifdef SODIUM_DLL_EXPORT
-# define SODIUM_EXPORT __declspec(dllexport)
-# else
-# define SODIUM_EXPORT __declspec(dllimport)
-# endif
-# else
-# if defined(__SUNPRO_C)
-# ifndef __GNU_C__
-# define SODIUM_EXPORT __attribute__ (visibility(__global))
-# else
-# define SODIUM_EXPORT __attribute__ __global
-# endif
-# elif defined(_MSG_VER)
-# define SODIUM_EXPORT extern __declspec(dllexport)
-# else
-# define SODIUM_EXPORT __attribute__ ((visibility ("default")))
-# endif
-# endif
-# if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS)
-# define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak))
-# else
-# define SODIUM_EXPORT_WEAK SODIUM_EXPORT
-# endif
-#endif
-
-#ifndef CRYPTO_ALIGN
-# if defined(__INTEL_COMPILER) || defined(_MSC_VER)
-# define CRYPTO_ALIGN(x) __declspec(align(x))
-# else
-# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x)))
-# endif
-#endif
-
-#define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B))
-#define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX)
-
-#endif
diff --git a/external/libsodium/src/crypto_verify/verify.c b/external/libsodium/src/crypto_verify/verify.c
deleted file mode 100644
index ffebf22..0000000
--- a/external/libsodium/src/crypto_verify/verify.c
+++ /dev/null
@@ -1,98 +0,0 @@
-
-#include
-#include
-
-#include "crypto_verify_16.h"
-#include "crypto_verify_32.h"
-#include "crypto_verify_64.h"
-
-size_t
-crypto_verify_16_bytes(void)
-{
- return crypto_verify_16_BYTES;
-}
-
-size_t
-crypto_verify_32_bytes(void)
-{
- return crypto_verify_32_BYTES;
-}
-
-size_t
-crypto_verify_64_bytes(void)
-{
- return crypto_verify_64_BYTES;
-}
-
-#if defined(HAVE_EMMINTRIN_H) && defined(__SSE2__)
-
-# ifdef __GNUC__
-# pragma GCC target("sse2")
-# endif
-# include
-
-static inline int
-crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
- const int n)
-{
- const __m128i zero = _mm_setzero_si128();
- volatile __m128i v1, v2, z;
- volatile int m;
- int i;
-
- const volatile __m128i *volatile x =
- (const volatile __m128i *volatile) (const void *) x_;
- const volatile __m128i *volatile y =
- (const volatile __m128i *volatile) (const void *) y_;
- v1 = _mm_loadu_si128((const __m128i *) &x[0]);
- v2 = _mm_loadu_si128((const __m128i *) &y[0]);
- z = _mm_xor_si128(v1, v2);
- for (i = 1; i < n / 16; i++) {
- v1 = _mm_loadu_si128((const __m128i *) &x[i]);
- v2 = _mm_loadu_si128((const __m128i *) &y[i]);
- z = _mm_or_si128(z, _mm_xor_si128(v1, v2));
- }
- m = _mm_movemask_epi8(_mm_cmpeq_epi32(z, zero));
- v1 = zero; v2 = zero; z = zero;
-
- return (int) (((uint32_t) m + 1U) >> 16) - 1;
-}
-
-#else
-
-static inline int
-crypto_verify_n(const unsigned char *x_, const unsigned char *y_,
- const int n)
-{
- const volatile unsigned char *volatile x =
- (const volatile unsigned char *volatile) x_;
- const volatile unsigned char *volatile y =
- (const volatile unsigned char *volatile) y_;
- volatile uint_fast16_t d = 0U;
- int i;
-
- for (i = 0; i < n; i++) {
- d |= x[i] ^ y[i];
- }
- return (1 & ((d - 1) >> 8)) - 1;
-}
-
-#endif
-
-int
-crypto_verify_16(const unsigned char *x, const unsigned char *y)
-{
- return crypto_verify_n(x, y, crypto_verify_16_BYTES);
-}
-
-int
-crypto_verify_32(const unsigned char *x, const unsigned char *y)
-{
- return crypto_verify_n(x, y, crypto_verify_32_BYTES);
-}
-
-int
-crypto_verify_64(const unsigned char *x, const unsigned char *y)
-{
- return crypto_verify_n(x, y, crypto_verify_64_BYTES);
-}
diff --git a/external/monero-project b/external/monero-project
deleted file mode 160000
index 81d4db0..0000000
--- a/external/monero-project
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 81d4db08eb75ce5392c65ca6571e7b08e41b7c95
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..aed159d
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,62 @@
+add_subdirectory(daemon)
+add_subdirectory(utils)
+add_subdirectory(wallet)
+
+file(GLOB SOURCES
+ "daemon/*.cpp"
+ "utils/*.cpp"
+ "wallet/*.cpp"
+)
+
+add_library(wownero_cpp ${SOURCES})
+include(GNUInstallDirs)
+
+target_link_libraries(wownero_cpp PUBLIC
+ wownero::epee
+ wownero::wallet_api
+ wownero::easylogging
+ Threads::Threads
+ ${CMAKE_DL_LIBS}
+ )
+
+target_include_directories(wownero_cpp
+ PUBLIC $
+ PUBLIC $
+ )
+
+install(TARGETS wownero_cpp EXPORT wownero_cppTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wownero_cpp/)
+
+# CMake targets file
+install(EXPORT wownero_cppTargets
+ FILE wownero_cppTargets.cmake
+ NAMESPACE wownero_cpp::
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wownero_cpp")
+
+# generate CMake config file
+configure_package_config_file("${CMAKE_SOURCE_DIR}/cmake/Config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/wownero_cppConfig.cmake"
+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wownero_cpp")
+
+# install CMake config file
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/wownero_cppConfig.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/wownero_cpp")
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/wownero_cppConfigVersion.cmake"
+ VERSION "${CMAKE_PROJECT_VERSION}"
+ COMPATIBILITY AnyNewerVersion)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/wownero_cppConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/wownero_cppConfigVersion.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/wownero_cpp)
+
+message(STATUS "==== wownero-cpp")
+message(STATUS "CMake ${CMAKE_VERSION}")
+message(STATUS "[+] VERSION: ${CMAKE_PROJECT_VERSION}")
+message(STATUS "[+] STATIC: ${STATIC}")
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
new file mode 100644
index 0000000..42bbc3b
--- /dev/null
+++ b/src/daemon/CMakeLists.txt
@@ -0,0 +1,2 @@
+file(GLOB HEADERS "*.h")
+install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wownero_cpp/daemon)
\ No newline at end of file
diff --git a/src/daemon/monero_daemon.cpp b/src/daemon/wownero_daemon.cpp
similarity index 98%
rename from src/daemon/monero_daemon.cpp
rename to src/daemon/wownero_daemon.cpp
index 38feaaa..0a9f59e 100644
--- a/src/daemon/monero_daemon.cpp
+++ b/src/daemon/wownero_daemon.cpp
@@ -50,11 +50,11 @@
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
*/
-#include "monero_daemon.h"
+#include "wownero_daemon.h"
/**
* Public library intereface.
*/
-namespace monero {
+namespace wownero {
}
diff --git a/src/daemon/monero_daemon.h b/src/daemon/wownero_daemon.h
similarity index 98%
rename from src/daemon/monero_daemon.h
rename to src/daemon/wownero_daemon.h
index 7dbcb4a..28d358f 100644
--- a/src/daemon/monero_daemon.h
+++ b/src/daemon/wownero_daemon.h
@@ -52,11 +52,11 @@
#pragma once
-#include "monero_daemon_model.h"
+#include "wownero_daemon_model.h"
/**
* Public library interface.
*/
-namespace monero {
+namespace wownero {
}
diff --git a/src/daemon/monero_daemon_model.cpp b/src/daemon/wownero_daemon_model.cpp
similarity index 64%
rename from src/daemon/monero_daemon_model.cpp
rename to src/daemon/wownero_daemon_model.cpp
index 7c78f89..fce5c74 100644
--- a/src/daemon/monero_daemon_model.cpp
+++ b/src/daemon/wownero_daemon_model.cpp
@@ -50,22 +50,22 @@
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
*/
-#include "monero_daemon_model.h"
+#include "wownero_daemon_model.h"
#include "utils/gen_utils.h"
-#include "utils/monero_utils.h"
+#include "utils/wownero_utils.h"
#include "include_base_utils.h"
#include "common/util.h"
/**
* Public library interface.
*/
-namespace monero {
+namespace wownero {
// ----------------------- UNDECLARED PRIVATE HELPERS -----------------------
- void merge_tx(std::vector>& txs, const std::shared_ptr& tx) {
- for (const std::shared_ptr& aTx : txs) {
+ void merge_tx(std::vector>& txs, const std::shared_ptr& tx) {
+ for (const std::shared_ptr& aTx : txs) {
if (aTx->m_hash.get() == tx->m_hash.get()) {
aTx->merge(aTx, tx);
return;
@@ -76,7 +76,7 @@ namespace monero {
// ------------------------- INITIALIZE CONSTANTS ---------------------------
- const std::string monero_tx::DEFAULT_PAYMENT_ID = std::string("0000000000000000");
+ const std::string wownero_tx::DEFAULT_PAYMENT_ID = std::string("0000000000000000");
// ------------------------- SERIALIZABLE STRUCT ----------------------------
@@ -85,22 +85,22 @@ namespace monero {
doc.SetObject();
rapidjson::Value val = to_rapidjson_val(doc.GetAllocator());
val.Swap(doc);
- return monero_utils::serialize(doc);
+ return wownero_utils::serialize(doc);
}
// ----------------------------- MONERO VERSION -----------------------------
- rapidjson::Value monero_version::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_version::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
- if (m_number != boost::none) monero_utils::add_json_member("number", m_number.get(), allocator, root, value_num);
+ if (m_number != boost::none) wownero_utils::add_json_member("number", m_number.get(), allocator, root, value_num);
// set bool values
- if (m_is_release != boost::none) monero_utils::add_json_member("isRelease", m_is_release.get(), allocator, root);
+ if (m_is_release != boost::none) wownero_utils::add_json_member("isRelease", m_is_release.get(), allocator, root);
// return root
return root;
@@ -108,23 +108,23 @@ namespace monero {
// --------------------------- MONERO RPC VERSION ---------------------------
- rapidjson::Value monero_rpc_connection::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_rpc_connection::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
- if (m_uri != boost::none) monero_utils::add_json_member("uri", m_uri.get(), allocator, root, value_str);
- if (m_username != boost::none) monero_utils::add_json_member("username", m_username.get(), allocator, root, value_str);
- if (m_password != boost::none) monero_utils::add_json_member("password", m_password.get(), allocator, root, value_str);
+ if (m_uri != boost::none) wownero_utils::add_json_member("uri", m_uri.get(), allocator, root, value_str);
+ if (m_username != boost::none) wownero_utils::add_json_member("username", m_username.get(), allocator, root, value_str);
+ if (m_password != boost::none) wownero_utils::add_json_member("password", m_password.get(), allocator, root, value_str);
// return root
return root;
}
- monero_rpc_connection monero_rpc_connection::from_property_tree(const boost::property_tree::ptree& node) {
- monero_rpc_connection connection;
+ wownero_rpc_connection wownero_rpc_connection::from_property_tree(const boost::property_tree::ptree& node) {
+ wownero_rpc_connection connection;
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
std::string key = it->first;
if (key == std::string("uri")) connection.m_uri = it->second.data();
@@ -136,42 +136,42 @@ namespace monero {
// ------------------------- MONERO BLOCK HEADER ----------------------------
- rapidjson::Value monero_block_header::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_block_header::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
- if (m_height != boost::none) monero_utils::add_json_member("height", m_height.get(), allocator, root, value_num);
- if (m_timestamp != boost::none) monero_utils::add_json_member("timestamp", m_timestamp.get(), allocator, root, value_num);
- if (m_size != boost::none) monero_utils::add_json_member("size", m_size.get(), allocator, root, value_num);
- if (m_weight != boost::none) monero_utils::add_json_member("weight", m_weight.get(), allocator, root, value_num);
- if (m_long_term_weight != boost::none) monero_utils::add_json_member("longTermWeight", m_long_term_weight.get(), allocator, root, value_num);
- if (m_depth != boost::none) monero_utils::add_json_member("depth", m_depth.get(), allocator, root, value_num);
- if (m_difficulty != boost::none) monero_utils::add_json_member("difficulty", m_difficulty.get(), allocator, root, value_num);
- if (m_cumulative_difficulty != boost::none) monero_utils::add_json_member("cumulativeDifficulty", m_cumulative_difficulty.get(), allocator, root, value_num);
- if (m_major_version != boost::none) monero_utils::add_json_member("majorVersion", m_major_version.get(), allocator, root, value_num);
- if (m_minor_version != boost::none) monero_utils::add_json_member("minorVersion", m_minor_version.get(), allocator, root, value_num);
- if (m_nonce != boost::none) monero_utils::add_json_member("nonce", m_nonce.get(), allocator, root, value_num);
- if (m_miner_tx_hash != boost::none) monero_utils::add_json_member("minerTxHash", m_miner_tx_hash.get(), allocator, root, value_num);
- if (m_num_txs != boost::none) monero_utils::add_json_member("numTxs", m_num_txs.get(), allocator, root, value_num);
- if (m_reward != boost::none) monero_utils::add_json_member("reward", m_reward.get(), allocator, root, value_num);
+ if (m_height != boost::none) wownero_utils::add_json_member("height", m_height.get(), allocator, root, value_num);
+ if (m_timestamp != boost::none) wownero_utils::add_json_member("timestamp", m_timestamp.get(), allocator, root, value_num);
+ if (m_size != boost::none) wownero_utils::add_json_member("size", m_size.get(), allocator, root, value_num);
+ if (m_weight != boost::none) wownero_utils::add_json_member("weight", m_weight.get(), allocator, root, value_num);
+ if (m_long_term_weight != boost::none) wownero_utils::add_json_member("longTermWeight", m_long_term_weight.get(), allocator, root, value_num);
+ if (m_depth != boost::none) wownero_utils::add_json_member("depth", m_depth.get(), allocator, root, value_num);
+ if (m_difficulty != boost::none) wownero_utils::add_json_member("difficulty", m_difficulty.get(), allocator, root, value_num);
+ if (m_cumulative_difficulty != boost::none) wownero_utils::add_json_member("cumulativeDifficulty", m_cumulative_difficulty.get(), allocator, root, value_num);
+ if (m_major_version != boost::none) wownero_utils::add_json_member("majorVersion", m_major_version.get(), allocator, root, value_num);
+ if (m_minor_version != boost::none) wownero_utils::add_json_member("minorVersion", m_minor_version.get(), allocator, root, value_num);
+ if (m_nonce != boost::none) wownero_utils::add_json_member("nonce", m_nonce.get(), allocator, root, value_num);
+ if (m_miner_tx_hash != boost::none) wownero_utils::add_json_member("minerTxHash", m_miner_tx_hash.get(), allocator, root, value_num);
+ if (m_num_txs != boost::none) wownero_utils::add_json_member("numTxs", m_num_txs.get(), allocator, root, value_num);
+ if (m_reward != boost::none) wownero_utils::add_json_member("reward", m_reward.get(), allocator, root, value_num);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
- if (m_hash != boost::none) monero_utils::add_json_member("hash", m_hash.get(), allocator, root, value_str);
- if (m_prev_hash != boost::none) monero_utils::add_json_member("prevHash", m_prev_hash.get(), allocator, root, value_str);
- if (m_pow_hash != boost::none) monero_utils::add_json_member("powHash", m_pow_hash.get(), allocator, root, value_str);
+ if (m_hash != boost::none) wownero_utils::add_json_member("hash", m_hash.get(), allocator, root, value_str);
+ if (m_prev_hash != boost::none) wownero_utils::add_json_member("prevHash", m_prev_hash.get(), allocator, root, value_str);
+ if (m_pow_hash != boost::none) wownero_utils::add_json_member("powHash", m_pow_hash.get(), allocator, root, value_str);
// set bool values
- if (m_orphan_status != boost::none) monero_utils::add_json_member("orphanStatus", m_orphan_status.get(), allocator, root);
+ if (m_orphan_status != boost::none) wownero_utils::add_json_member("orphanStatus", m_orphan_status.get(), allocator, root);
// return root
return root;
}
- std::shared_ptr monero_block_header::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
+ std::shared_ptr wownero_block_header::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
if (this != src.get()) throw std::runtime_error("this block header != src");
tgt->m_hash = src->m_hash;
tgt->m_height = src->m_height;
@@ -195,7 +195,7 @@ namespace monero {
return tgt;
}
- void monero_block_header::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ void wownero_block_header::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
if (this != self.get()) throw std::runtime_error("this != self");
if (self == other) return;
m_hash = gen_utils::reconcile(m_hash, other->m_hash, "block header m_hash");
@@ -220,18 +220,18 @@ namespace monero {
// ----------------------------- MONERO BLOCK -------------------------------
- rapidjson::Value monero_block::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_block::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
- rapidjson::Value root = monero_block_header::to_rapidjson_val(allocator);
+ rapidjson::Value root = wownero_block_header::to_rapidjson_val(allocator);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
- if (m_hex != boost::none) monero_utils::add_json_member("hex", m_hex.get(), allocator, root, value_str);
+ if (m_hex != boost::none) wownero_utils::add_json_member("hex", m_hex.get(), allocator, root, value_str);
// set sub-arrays
- if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_rapidjson_val(allocator, m_txs), allocator);
- if (!m_tx_hashes.empty()) root.AddMember("txHashes", monero_utils::to_rapidjson_val(allocator, m_tx_hashes), allocator);
+ if (!m_txs.empty()) root.AddMember("txs", wownero_utils::to_rapidjson_val(allocator, m_txs), allocator);
+ if (!m_tx_hashes.empty()) root.AddMember("txHashes", wownero_utils::to_rapidjson_val(allocator, m_tx_hashes), allocator);
// set sub-objects
if (m_miner_tx != boost::none) root.AddMember("minerTx", m_miner_tx.get()->to_rapidjson_val(allocator), allocator);
@@ -240,25 +240,25 @@ namespace monero {
return root;
}
- std::shared_ptr monero_block::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
+ std::shared_ptr wownero_block::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
if (this != src.get()) throw std::runtime_error("this block != src");
- monero_block_header::copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt));
+ wownero_block_header::copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt));
tgt->m_hex = src->m_hex;
if (src->m_miner_tx) {
- tgt->m_miner_tx = src->m_miner_tx.get()->copy(src->m_miner_tx.get(), std::make_shared());
+ tgt->m_miner_tx = src->m_miner_tx.get()->copy(src->m_miner_tx.get(), std::make_shared());
tgt->m_miner_tx.get()->m_block = tgt;
}
if (!src->m_txs.empty()) {
- bool use_wallet_types = std::dynamic_pointer_cast(src->m_txs[0]) != 0;
- tgt->m_txs = std::vector>();
+ bool use_wallet_types = std::dynamic_pointer_cast(src->m_txs[0]) != 0;
+ tgt->m_txs = std::vector>();
for (const auto& tx : src->m_txs) {
if (use_wallet_types) {
- std::shared_ptr tx_wallet = std::static_pointer_cast(tx);
- std::shared_ptr tx_copy = tx_wallet->copy(tx_wallet, std::make_shared());
+ std::shared_ptr tx_wallet = std::static_pointer_cast(tx);
+ std::shared_ptr tx_copy = tx_wallet->copy(tx_wallet, std::make_shared());
tx_copy->m_block = tgt;
tgt->m_txs.push_back(tx_copy);
} else {
- std::shared_ptr tx_copy = tx->copy(tx, std::make_shared());
+ std::shared_ptr tx_copy = tx->copy(tx, std::make_shared());
tx_copy->m_block = tgt;
tgt->m_txs.push_back(tx_copy);
}
@@ -268,16 +268,16 @@ namespace monero {
return tgt;
}
- void monero_block::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
- merge(std::static_pointer_cast(self), std::static_pointer_cast(other));
+ void wownero_block::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ merge(std::static_pointer_cast(self), std::static_pointer_cast(other));
}
- void monero_block::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ void wownero_block::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
if (this != self.get()) throw std::runtime_error("this != self");
if (self == other) return;
// merge header fields
- monero_block_header::merge(self, other);
+ wownero_block_header::merge(self, other);
// merge reconcilable block extensions
m_hex = gen_utils::reconcile(m_hex, other->m_hex, "block m_hex");
@@ -292,7 +292,7 @@ namespace monero {
// merge non-miner txs
if (!other->m_txs.empty()) {
- for (const std::shared_ptr otherTx : other->m_txs) { // NOTE: not using reference so std::shared_ptr is not deleted when block is dereferenced
+ for (const std::shared_ptr otherTx : other->m_txs) { // NOTE: not using reference so std::shared_ptr is not deleted when block is dereferenced
otherTx->m_block = self;
merge_tx(self->m_txs, otherTx);
}
@@ -301,63 +301,63 @@ namespace monero {
// ------------------------------- MONERO TX --------------------------------
- rapidjson::Value monero_tx::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_tx::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
- if (m_version != boost::none) monero_utils::add_json_member("version", m_version.get(), allocator, root, value_num);
- if (m_fee != boost::none) monero_utils::add_json_member("fee", m_fee.get(), allocator, root, value_num);
- if (m_ring_size != boost::none) monero_utils::add_json_member("ringSize", m_ring_size.get(), allocator, root, value_num);
- if (m_num_confirmations != boost::none) monero_utils::add_json_member("numConfirmations", m_num_confirmations.get(), allocator, root, value_num);
- if (m_unlock_time != boost::none) monero_utils::add_json_member("unlockTime", m_unlock_time.get(), allocator, root, value_num);
- if (m_last_relayed_timestamp != boost::none) monero_utils::add_json_member("lastRelayedTimestamp", m_last_relayed_timestamp.get(), allocator, root, value_num);
- if (m_received_timestamp != boost::none) monero_utils::add_json_member("receivedTimestamp", m_received_timestamp.get(), allocator, root, value_num);
- if (m_size != boost::none) monero_utils::add_json_member("size", m_size.get(), allocator, root, value_num);
- if (m_weight != boost::none) monero_utils::add_json_member("weight", m_weight.get(), allocator, root, value_num);
- if (m_last_failed_height != boost::none) monero_utils::add_json_member("lastFailedHeight", m_last_failed_height.get(), allocator, root, value_num);
- if (m_max_used_block_height != boost::none) monero_utils::add_json_member("maxUsedBlockHeight", m_max_used_block_height.get(), allocator, root, value_num);
+ if (m_version != boost::none) wownero_utils::add_json_member("version", m_version.get(), allocator, root, value_num);
+ if (m_fee != boost::none) wownero_utils::add_json_member("fee", m_fee.get(), allocator, root, value_num);
+ if (m_ring_size != boost::none) wownero_utils::add_json_member("ringSize", m_ring_size.get(), allocator, root, value_num);
+ if (m_num_confirmations != boost::none) wownero_utils::add_json_member("numConfirmations", m_num_confirmations.get(), allocator, root, value_num);
+ if (m_unlock_time != boost::none) wownero_utils::add_json_member("unlockTime", m_unlock_time.get(), allocator, root, value_num);
+ if (m_last_relayed_timestamp != boost::none) wownero_utils::add_json_member("lastRelayedTimestamp", m_last_relayed_timestamp.get(), allocator, root, value_num);
+ if (m_received_timestamp != boost::none) wownero_utils::add_json_member("receivedTimestamp", m_received_timestamp.get(), allocator, root, value_num);
+ if (m_size != boost::none) wownero_utils::add_json_member("size", m_size.get(), allocator, root, value_num);
+ if (m_weight != boost::none) wownero_utils::add_json_member("weight", m_weight.get(), allocator, root, value_num);
+ if (m_last_failed_height != boost::none) wownero_utils::add_json_member("lastFailedHeight", m_last_failed_height.get(), allocator, root, value_num);
+ if (m_max_used_block_height != boost::none) wownero_utils::add_json_member("maxUsedBlockHeight", m_max_used_block_height.get(), allocator, root, value_num);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
- if (m_hash != boost::none) monero_utils::add_json_member("hash", m_hash.get(), allocator, root, value_str);
- if (m_payment_id != boost::none) monero_utils::add_json_member("paymentId", m_payment_id.get(), allocator, root, value_str);
- if (m_key != boost::none) monero_utils::add_json_member("key", m_key.get(), allocator, root, value_str);
- if (m_full_hex != boost::none) monero_utils::add_json_member("fullHex", m_full_hex.get(), allocator, root, value_str);
- if (m_pruned_hex != boost::none) monero_utils::add_json_member("prunedHex", m_pruned_hex.get(), allocator, root, value_str);
- if (m_prunable_hex != boost::none) monero_utils::add_json_member("prunableHex", m_prunable_hex.get(), allocator, root, value_str);
- if (m_prunable_hash != boost::none) monero_utils::add_json_member("prunableHash", m_prunable_hash.get(), allocator, root, value_str);
- if (m_metadata != boost::none) monero_utils::add_json_member("metadata", m_metadata.get(), allocator, root, value_str);
- if (m_common_tx_sets != boost::none) monero_utils::add_json_member("commonTxSets", m_common_tx_sets.get(), allocator, root, value_str);
- if (m_rct_signatures != boost::none) monero_utils::add_json_member("rctSignatures", m_rct_signatures.get(), allocator, root, value_str);
- if (m_rct_sig_prunable != boost::none) monero_utils::add_json_member("rctSigPrunable", m_rct_sig_prunable.get(), allocator, root, value_str);
- if (m_last_failed_hash != boost::none) monero_utils::add_json_member("lastFailedHash", m_last_failed_hash.get(), allocator, root, value_str);
- if (m_max_used_block_hash != boost::none) monero_utils::add_json_member("maxUsedBlockHash", m_max_used_block_hash.get(), allocator, root, value_str);
+ if (m_hash != boost::none) wownero_utils::add_json_member("hash", m_hash.get(), allocator, root, value_str);
+ if (m_payment_id != boost::none) wownero_utils::add_json_member("paymentId", m_payment_id.get(), allocator, root, value_str);
+ if (m_key != boost::none) wownero_utils::add_json_member("key", m_key.get(), allocator, root, value_str);
+ if (m_full_hex != boost::none) wownero_utils::add_json_member("fullHex", m_full_hex.get(), allocator, root, value_str);
+ if (m_pruned_hex != boost::none) wownero_utils::add_json_member("prunedHex", m_pruned_hex.get(), allocator, root, value_str);
+ if (m_prunable_hex != boost::none) wownero_utils::add_json_member("prunableHex", m_prunable_hex.get(), allocator, root, value_str);
+ if (m_prunable_hash != boost::none) wownero_utils::add_json_member("prunableHash", m_prunable_hash.get(), allocator, root, value_str);
+ if (m_metadata != boost::none) wownero_utils::add_json_member("metadata", m_metadata.get(), allocator, root, value_str);
+ if (m_common_tx_sets != boost::none) wownero_utils::add_json_member("commonTxSets", m_common_tx_sets.get(), allocator, root, value_str);
+ if (m_rct_signatures != boost::none) wownero_utils::add_json_member("rctSignatures", m_rct_signatures.get(), allocator, root, value_str);
+ if (m_rct_sig_prunable != boost::none) wownero_utils::add_json_member("rctSigPrunable", m_rct_sig_prunable.get(), allocator, root, value_str);
+ if (m_last_failed_hash != boost::none) wownero_utils::add_json_member("lastFailedHash", m_last_failed_hash.get(), allocator, root, value_str);
+ if (m_max_used_block_hash != boost::none) wownero_utils::add_json_member("maxUsedBlockHash", m_max_used_block_hash.get(), allocator, root, value_str);
// set bool values
- if (m_is_miner_tx != boost::none) monero_utils::add_json_member("isMinerTx", m_is_miner_tx.get(), allocator, root);
- if (m_relay != boost::none) monero_utils::add_json_member("relay", m_relay.get(), allocator, root);
- if (m_is_relayed != boost::none) monero_utils::add_json_member("isRelayed", m_is_relayed.get(), allocator, root);
- if (m_is_confirmed != boost::none) monero_utils::add_json_member("isConfirmed", m_is_confirmed.get(), allocator, root);
- if (m_in_tx_pool != boost::none) monero_utils::add_json_member("inTxPool", m_in_tx_pool.get(), allocator, root);
- if (m_is_double_spend_seen != boost::none) monero_utils::add_json_member("isDoubleSpendSeen", m_is_double_spend_seen.get(), allocator, root);
- if (m_is_kept_by_block != boost::none) monero_utils::add_json_member("isKeptByBlock", m_is_kept_by_block.get(), allocator, root);
- if (m_is_failed != boost::none) monero_utils::add_json_member("isFailed", m_is_failed.get(), allocator, root);
+ if (m_is_miner_tx != boost::none) wownero_utils::add_json_member("isMinerTx", m_is_miner_tx.get(), allocator, root);
+ if (m_relay != boost::none) wownero_utils::add_json_member("relay", m_relay.get(), allocator, root);
+ if (m_is_relayed != boost::none) wownero_utils::add_json_member("isRelayed", m_is_relayed.get(), allocator, root);
+ if (m_is_confirmed != boost::none) wownero_utils::add_json_member("isConfirmed", m_is_confirmed.get(), allocator, root);
+ if (m_in_tx_pool != boost::none) wownero_utils::add_json_member("inTxPool", m_in_tx_pool.get(), allocator, root);
+ if (m_is_double_spend_seen != boost::none) wownero_utils::add_json_member("isDoubleSpendSeen", m_is_double_spend_seen.get(), allocator, root);
+ if (m_is_kept_by_block != boost::none) wownero_utils::add_json_member("isKeptByBlock", m_is_kept_by_block.get(), allocator, root);
+ if (m_is_failed != boost::none) wownero_utils::add_json_member("isFailed", m_is_failed.get(), allocator, root);
// set sub-arrays
- if (!m_inputs.empty()) root.AddMember("inputs", monero_utils::to_rapidjson_val(allocator, m_inputs), allocator);
- if (!m_outputs.empty()) root.AddMember("outputs", monero_utils::to_rapidjson_val(allocator, m_outputs), allocator);
- if (!m_output_indices.empty()) root.AddMember("outputIndices", monero_utils::to_rapidjson_val(allocator, m_output_indices), allocator);
- if (!m_extra.empty()) root.AddMember("extra", monero_utils::to_rapidjson_val(allocator, m_extra), allocator);
- if (!m_signatures.empty()) root.AddMember("signatures", monero_utils::to_rapidjson_val(allocator, m_signatures), allocator);
+ if (!m_inputs.empty()) root.AddMember("inputs", wownero_utils::to_rapidjson_val(allocator, m_inputs), allocator);
+ if (!m_outputs.empty()) root.AddMember("outputs", wownero_utils::to_rapidjson_val(allocator, m_outputs), allocator);
+ if (!m_output_indices.empty()) root.AddMember("outputIndices", wownero_utils::to_rapidjson_val(allocator, m_output_indices), allocator);
+ if (!m_extra.empty()) root.AddMember("extra", wownero_utils::to_rapidjson_val(allocator, m_extra), allocator);
+ if (!m_signatures.empty()) root.AddMember("signatures", wownero_utils::to_rapidjson_val(allocator, m_signatures), allocator);
// return root
return root;
}
- void monero_tx::from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr tx) {
+ void wownero_tx::from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr tx) {
// initialize tx from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
@@ -402,8 +402,8 @@ namespace monero {
}
}
- std::shared_ptr monero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
- MTRACE("monero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt)");
+ std::shared_ptr wownero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
+ MTRACE("wownero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt)");
tgt->m_hash = src->m_hash;
tgt->m_version = src->m_version;
tgt->m_is_miner_tx = src->m_is_miner_tx;
@@ -427,17 +427,17 @@ namespace monero {
tgt->m_size = src->m_size;
tgt->m_weight = src->m_weight;
if (!src->m_inputs.empty()) {
- tgt->m_inputs = std::vector>();
- for (const std::shared_ptr& input : src->m_inputs) {
- std::shared_ptr input_copy = input->copy(input, std::make_shared());
+ tgt->m_inputs = std::vector>();
+ for (const std::shared_ptr& input : src->m_inputs) {
+ std::shared_ptr input_copy = input->copy(input, std::make_shared());
input_copy->m_tx = tgt;
tgt->m_inputs.push_back(input_copy);
}
}
if (!src->m_outputs.empty()) {
- tgt->m_outputs = std::vector>();
- for (const std::shared_ptr& output : src->m_outputs) {
- std::shared_ptr output_copy = output->copy(output, std::make_shared());
+ tgt->m_outputs = std::vector>();
+ for (const std::shared_ptr& output : src->m_outputs) {
+ std::shared_ptr output_copy = output->copy(output, std::make_shared());
output_copy->m_tx = tgt;
tgt->m_outputs.push_back(output_copy);
}
@@ -458,12 +458,12 @@ namespace monero {
return tgt;
}
- boost::optional monero_tx::get_height() const {
+ boost::optional wownero_tx::get_height() const {
if (m_block == boost::none) return boost::none;
return *((*m_block)->m_height);
}
- void monero_tx::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ void wownero_tx::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
if (this != self.get()) throw std::runtime_error("this != self");
if (self == other) return;
@@ -514,10 +514,10 @@ namespace monero {
// merge inputs
if (!other->m_inputs.empty()) {
- for (const std::shared_ptr& merger : other->m_inputs) {
+ for (const std::shared_ptr& merger : other->m_inputs) {
bool merged = false;
merger->m_tx = self;
- for (const std::shared_ptr& mergee : m_inputs) {
+ for (const std::shared_ptr& mergee : m_inputs) {
if ((*mergee->m_key_image)->m_hex == (*merger->m_key_image)->m_hex) {
mergee->merge(mergee, merger);
merged = true;
@@ -530,15 +530,15 @@ namespace monero {
// merge outputs
if (!other->m_outputs.empty()) {
- for (const std::shared_ptr& output : other->m_outputs) output->m_tx = self;
+ for (const std::shared_ptr& output : other->m_outputs) output->m_tx = self;
if (m_outputs.empty()) m_outputs = other->m_outputs;
else {
// merge outputs if key image or stealth public key present, otherwise append
- for (const std::shared_ptr& merger : other->m_outputs) {
+ for (const std::shared_ptr& merger : other->m_outputs) {
bool merged = false;
merger->m_tx = self;
- for (const std::shared_ptr& mergee : m_outputs) {
+ for (const std::shared_ptr& mergee : m_outputs) {
if ((merger->m_key_image != boost::none && (*mergee->m_key_image)->m_hex == (*merger->m_key_image)->m_hex) ||
(merger->m_stealth_public_key != boost::none && *mergee->m_stealth_public_key == *merger->m_stealth_public_key)) {
mergee->merge(mergee, merger);
@@ -565,21 +565,21 @@ namespace monero {
// --------------------------- MONERO KEY IMAGE -----------------------------
- rapidjson::Value monero_key_image::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_key_image::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
- if (m_hex != boost::none) monero_utils::add_json_member("hex", m_hex.get(), allocator, root, value_str);
- if (m_signature != boost::none) monero_utils::add_json_member("signature", m_signature.get(), allocator, root, value_str);
+ if (m_hex != boost::none) wownero_utils::add_json_member("hex", m_hex.get(), allocator, root, value_str);
+ if (m_signature != boost::none) wownero_utils::add_json_member("signature", m_signature.get(), allocator, root, value_str);
// return root
return root;
}
- void monero_key_image::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& key_image) {
+ void wownero_key_image::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& key_image) {
// initialize key image from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
@@ -589,7 +589,7 @@ namespace monero {
}
}
- std::vector> monero_key_image::deserialize_key_images(const std::string& key_images_json) {
+ std::vector> wownero_key_image::deserialize_key_images(const std::string& key_images_json) {
// deserialize json to property node
std::istringstream iss = key_images_json.empty() ? std::istringstream() : std::istringstream(key_images_json);
@@ -597,13 +597,13 @@ namespace monero {
boost::property_tree::read_json(iss, node);
// convert property tree to key images
- std::vector> key_images;
+ std::vector> key_images;
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
std::string key = it->first;
if (key == std::string("keyImages")) {
for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
- std::shared_ptr key_image = std::make_shared();
- monero_key_image::from_property_tree(it2->second, key_image);
+ std::shared_ptr key_image = std::make_shared();
+ wownero_key_image::from_property_tree(it2->second, key_image);
key_images.push_back(key_image);
}
}
@@ -612,15 +612,15 @@ namespace monero {
return key_images;
}
- std::shared_ptr monero_key_image::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
+ std::shared_ptr wownero_key_image::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
if (this != src.get()) throw std::runtime_error("this != src");
tgt->m_hex = src->m_hex;
tgt->m_signature = src->m_signature;
return tgt;
}
- void monero_key_image::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
- MTRACE("monero_key_image::merge(self, other)");
+ void wownero_key_image::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ MTRACE("wownero_key_image::merge(self, other)");
if (this != self.get()) throw std::runtime_error("this != self");
if (self == other) return;
m_hex = gen_utils::reconcile(m_hex, other->m_hex, "key image m_hex");
@@ -629,19 +629,19 @@ namespace monero {
// ------------------------------ MONERO OUTPUT -----------------------------
- rapidjson::Value monero_output::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
+ rapidjson::Value wownero_output::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
- if (m_amount != boost::none) monero_utils::add_json_member("amount", m_amount.get(), allocator, root, value_num);
- if (m_index != boost::none) monero_utils::add_json_member("index", m_index.get(), allocator, root, value_num);
- if (m_stealth_public_key != boost::none) monero_utils::add_json_member("stealthPublicKey", m_stealth_public_key.get(), allocator, root, value_num);
+ if (m_amount != boost::none) wownero_utils::add_json_member("amount", m_amount.get(), allocator, root, value_num);
+ if (m_index != boost::none) wownero_utils::add_json_member("index", m_index.get(), allocator, root, value_num);
+ if (m_stealth_public_key != boost::none) wownero_utils::add_json_member("stealthPublicKey", m_stealth_public_key.get(), allocator, root, value_num);
// set sub-arrays
- if (!m_ring_output_indices.empty()) root.AddMember("ringOutputIndices", monero_utils::to_rapidjson_val(allocator, m_ring_output_indices), allocator);
+ if (!m_ring_output_indices.empty()) root.AddMember("ringOutputIndices", wownero_utils::to_rapidjson_val(allocator, m_ring_output_indices), allocator);
// set sub-objects
if (m_key_image != boost::none) root.AddMember("keyImage", m_key_image.get()->to_rapidjson_val(allocator), allocator);
@@ -650,14 +650,14 @@ namespace monero {
return root;
}
- void monero_output::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& output) {
+ void wownero_output::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& output) {
// initialize output from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
std::string key = it->first;
if (key == std::string("keyImage")) {
- output->m_key_image = std::make_shared();
- monero_key_image::from_property_tree(it->second, output->m_key_image.get());
+ output->m_key_image = std::make_shared();
+ wownero_key_image::from_property_tree(it->second, output->m_key_image.get());
}
else if (key == std::string("amount")) output->m_amount = it->second.get_value();
else if (key == std::string("index")) output->m_index = it->second.get_value();
@@ -666,10 +666,10 @@ namespace monero {
}
}
- std::shared_ptr monero_output::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
+ std::shared_ptr wownero_output::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const {
if (this != src.get()) throw std::runtime_error("this != src");
tgt->m_tx = src->m_tx; // reference same parent tx by default
- if (src->m_key_image != boost::none) tgt->m_key_image = src->m_key_image.get()->copy(src->m_key_image.get(), std::make_shared());
+ if (src->m_key_image != boost::none) tgt->m_key_image = src->m_key_image.get()->copy(src->m_key_image.get(), std::make_shared());
tgt->m_amount = src->m_amount;
tgt->m_index = src->m_index;
if (!src->m_ring_output_indices.empty()) tgt->m_ring_output_indices = std::vector(src->m_ring_output_indices);
@@ -677,7 +677,7 @@ namespace monero {
return tgt;
}
- void monero_output::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
+ void wownero_output::merge(const std::shared_ptr& self, const std::shared_ptr& other) {
if (this != self.get()) throw std::runtime_error("this != self");
if (self == other) return;
diff --git a/src/daemon/monero_daemon_model.h b/src/daemon/wownero_daemon_model.h
similarity index 74%
rename from src/daemon/monero_daemon_model.h
rename to src/daemon/wownero_daemon_model.h
index 3e7a82a..36a379e 100644
--- a/src/daemon/monero_daemon_model.h
+++ b/src/daemon/wownero_daemon_model.h
@@ -61,7 +61,7 @@
/**
* Public interface for libmonero-cpp library.
*/
-namespace monero {
+namespace wownero {
/**
* Base struct which can be serialized.
@@ -87,7 +87,7 @@ namespace monero {
/**
* Enumerates Monero network types.
*/
- enum monero_network_type : uint8_t {
+ enum wownero_network_type : uint8_t {
MAINNET = 0,
TESTNET,
STAGENET
@@ -96,7 +96,7 @@ namespace monero {
/**
* Models a Monero version.
*/
- struct monero_version : public serializable_struct {
+ struct wownero_version : public serializable_struct {
boost::optional m_number;
boost::optional m_is_release;
@@ -106,26 +106,26 @@ namespace monero {
/**
* Models a connection to a daemon.
*/
- struct monero_rpc_connection : public serializable_struct {
+ struct wownero_rpc_connection : public serializable_struct {
boost::optional m_uri;
boost::optional m_username;
boost::optional m_password;
- monero_rpc_connection(const std::string& uri = "", const std::string& username = "", const std::string& password = "") : m_uri(uri), m_username(username), m_password(password) {}
+ wownero_rpc_connection(const std::string& uri = "", const std::string& username = "", const std::string& password = "") : m_uri(uri), m_username(username), m_password(password) {}
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
- static monero_rpc_connection from_property_tree(const boost::property_tree::ptree& node);
+ static wownero_rpc_connection from_property_tree(const boost::property_tree::ptree& node);
};
// forward declarations
- struct monero_tx;
- struct monero_output;
+ struct wownero_tx;
+ struct wownero_output;
/**
* Models a Monero block header which contains information about the block.
*
* TODO: a header that is transmitted may have fewer fields like cryptonote::block_header; separate?
*/
- struct monero_block_header : public serializable_struct {
+ struct wownero_block_header : public serializable_struct {
boost::optional m_hash;
boost::optional m_height;
boost::optional m_timestamp;
@@ -146,31 +146,31 @@ namespace monero {
boost::optional m_pow_hash;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
- std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
- virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other);
+ std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
+ virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other);
};
/**
* Models a Monero block in the blockchain.
*/
- struct monero_block : public monero_block_header {
+ struct wownero_block : public wownero_block_header {
boost::optional m_hex;
- boost::optional> m_miner_tx;
- std::vector> m_txs;
+ boost::optional> m_miner_tx;
+ std::vector> m_txs;
std::vector m_tx_hashes;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
- std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
- void merge(const std::shared_ptr& self, const std::shared_ptr& other);
- void merge(const std::shared_ptr& self, const std::shared_ptr& other);
+ std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
+ void merge(const std::shared_ptr& self, const std::shared_ptr& other);
+ void merge(const std::shared_ptr& self, const std::shared_ptr& other);
};
/**
* Models a Monero transaction on the blockchain.
*/
- struct monero_tx : public serializable_struct {
+ struct wownero_tx : public serializable_struct {
static const std::string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
- boost::optional> m_block;
+ boost::optional> m_block;
boost::optional m_hash;
boost::optional m_version;
boost::optional m_is_miner_tx;
@@ -193,8 +193,8 @@ namespace monero {
boost::optional m_prunable_hash;
boost::optional m_size;
boost::optional m_weight;
- std::vector> m_inputs;
- std::vector> m_outputs;
+ std::vector> m_inputs;
+ std::vector> m_outputs;
std::vector m_output_indices;
boost::optional m_metadata;
boost::optional m_common_tx_sets;
@@ -210,40 +210,40 @@ namespace monero {
std::vector m_signatures;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
- static void from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr tx);
- std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
- virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other);
+ static void from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr tx);
+ std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
+ virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other);
boost::optional get_height() const;
};
/**
* Models a Monero key image.
*/
- struct monero_key_image : public serializable_struct {
+ struct wownero_key_image : public serializable_struct {
boost::optional m_hex;
boost::optional m_signature;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
- static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& key_image);
- static std::vector> deserialize_key_images(const std::string& key_images_json); // TODO: remove this specialty util used once
- std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
- void merge(const std::shared_ptr& self, const std::shared_ptr& other);
+ static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& key_image);
+ static std::vector> deserialize_key_images(const std::string& key_images_json); // TODO: remove this specialty util used once
+ std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const;
+ void merge(const std::shared_ptr& self, const std::shared_ptr& other);
};
/**
* Models a Monero transaction output.
*/
- struct monero_output : public serializable_struct {
- std::shared_ptr m_tx;
- boost::optional> m_key_image;
+ struct wownero_output : public serializable_struct {
+ std::shared_ptr m_tx;
+ boost::optional> m_key_image;
boost::optional