From 476c3a43e46f9ddbf18a089c1b32d00642308737 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Wed, 3 Jan 2024 13:24:07 +0100 Subject: Make the process run a bit differently, let's delay the task to the Isolate.run as std::thread was causing some funky crashes that I'm in no mood to fix atm --- libbridge/src/main/cpp/wallet2_api_c.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index ce9c210..6faa922 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -955,30 +955,17 @@ uint64_t MONERO_Wallet_daemonBlockChainHeight_cached(void* wallet_ptr) { return daemonBlockChainHeight_cached; } -uint64_t daemonBlockChainHeight_cahceSleepTime = 1; -bool daemonBlockChainHeight_cahceIsEnabled = false; +bool daemonBlockChainHeight_cacheIsEnabled = false; -void MONERO_Wallet_daemonBlockChainHeight_runThread(void* wallet_ptr) { +void MONERO_Wallet_daemonBlockChainHeight_runThread(void* wallet_ptr, int seconds) { while (true) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); daemonBlockChainHeight_cached = wallet->daemonBlockChainHeight(); - sleep(daemonBlockChainHeight_cahceSleepTime); - std::cout << "MONERO: TICK: MONERO_Wallet_daemonBlockChainHeight_runThread: " << daemonBlockChainHeight_cached << std::endl; + sleep(seconds); + std::cout << "MONERO: TICK: MONERO_Wallet_daemonBlockChainHeight_runThread(" << seconds << "): " << daemonBlockChainHeight_cached << std::endl; } } -bool MONERO_Wallet_daemonBlockChainHeight_enableRefresh(void* wallet_ptr, int seconds) { - if (seconds < 1) { - seconds = 1; - } - daemonBlockChainHeight_cahceSleepTime = seconds; - if (daemonBlockChainHeight_cahceIsEnabled == true) { - return true; - } - daemonBlockChainHeight_cahceIsEnabled = true; - std::thread t1(MONERO_Wallet_daemonBlockChainHeight_runThread, wallet_ptr); - return true; -} uint64_t MONERO_Wallet_daemonBlockChainTargetHeight(void* wallet_ptr) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->daemonBlockChainTargetHeight(); -- cgit v1.2.3 From 53d14fc615abd664781af98f8b9992cde4268ad3 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Wed, 3 Jan 2024 14:11:19 +0100 Subject: prepare for sweep --- libbridge/src/main/cpp/wallet2_api_c.cpp | 6 +++++- libbridge/src/main/cpp/wallet2_api_c.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 6faa922..97b6fa8 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1109,8 +1109,12 @@ void* MONERO_Wallet_createTransaction(void* wallet_ptr, const char* dst_addr, co int pendingTransactionPriority, uint32_t subaddr_account) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + Monero::optional optAmount; + if (amount != 0) { + optAmount = amount; + } return wallet->createTransaction(std::string(dst_addr), std::string(payment_id), - amount, mixin_count, + optAmount, mixin_count, Monero::PendingTransaction::Priority_Low, subaddr_account /*, subaddr_indices */); } diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index e38c51b..6e9c971 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -573,7 +573,7 @@ uint64_t MONERO_Wallet_estimateBlockChainHeight(void* wallet_ptr); // virtual uint64_t daemonBlockChainHeight() const = 0; uint64_t MONERO_Wallet_daemonBlockChainHeight(void* wallet_ptr); uint64_t MONERO_Wallet_daemonBlockChainHeight_cached(void* wallet_ptr); -bool MONERO_Wallet_daemonBlockChainHeight_enableRefresh(void* wallet_ptr, int seconds); +void MONERO_Wallet_daemonBlockChainHeight_runThread(void* wallet_ptr, int seconds); // virtual uint64_t daemonBlockChainTargetHeight() const = 0; uint64_t MONERO_Wallet_daemonBlockChainTargetHeight(void* wallet_ptr); // virtual bool synchronized() const = 0; -- cgit v1.2.3 From 12bc3aaaa9aafb7db0b08ad1343f830070aa18d3 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Thu, 4 Jan 2024 22:17:42 +0100 Subject: drop cache, it is causing more trouble than it's worth implement anonero's fork functions in bridge. Calling it RC39 to not break versioning. --- .github/workflows/android.yml | 151 +------------------------------ .github/workflows/linux.yml | 111 ----------------------- libbridge/src/main/cpp/helpers.cpp | 14 +++ libbridge/src/main/cpp/helpers.hpp | 3 +- libbridge/src/main/cpp/wallet2_api.h | 82 ++++++++++++++++- libbridge/src/main/cpp/wallet2_api_c.cpp | 107 +++++++++++++++++++++- libbridge/src/main/cpp/wallet2_api_c.h | 53 ++++++++++- 7 files changed, 253 insertions(+), 268 deletions(-) (limited to 'libbridge/src') diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index cbfe5c9..c2aae62 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -92,94 +92,8 @@ jobs: steps: - name: Checkout repository code uses: actions/checkout@v3 - - name: Download cached build artifacts - run: | - ${{ github.workspace }}/download_artifact.sh libsodium "${SODIUM_VERSION}-${{ matrix.host_triplet }}-${SODIUM_HASH}" ${{ github.workspace }}/prefix/lib/libsodium.a - ${{ github.workspace }}/download_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libcrypto.a - ${{ github.workspace }}/download_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libssl.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_chrono.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_date_time.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_filesystem.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_program_options.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_regex.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_serialization.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_system.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_thread.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_wserialization.a - ${{ github.workspace }}/download_artifact.sh libunbound "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/prefix/lib/libunbound.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet_api.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_core/libcryptonote_core.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_basic.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/mnemonics/libmnemonics.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/common/libcommon.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/libcncrypto.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct_basic.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blockchain_db/libblockchain_db.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/db_drivers/liblmdb/liblmdb.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/easylogging++/libeasylogging.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/contrib/epee/src/libepee.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blocks/libblocks.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/checkpoints/libcheckpoints.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device/libdevice.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device_trezor/libdevice_trezor.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/multisig/libmultisig.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/libversion.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/net/libnet.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/hardforks/libhardforks.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/randomx/librandomx.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/rpc/librpc_base.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/wallet/libwallet-crypto.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_format_utils_basic.a - - name: Create skip flag based on cache - run: | - if [[ -f "${{ github.workspace }}/prefix/lib/libsodium.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libcrypto.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libssl.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_chrono.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_date_time.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_filesystem.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_program_options.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_regex.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_serialization.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_system.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_thread.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_wserialization.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libunbound.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/lib/libwallet_api.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/lib/libwallet.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_core/libcryptonote_core.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_basic.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/mnemonics/libmnemonics.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/common/libcommon.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/crypto/libcncrypto.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/ringct/libringct.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/ringct/libringct_basic.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/blockchain_db/libblockchain_db.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/db_drivers/liblmdb/liblmdb.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/easylogging++/libeasylogging.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/contrib/epee/src/libepee.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/blocks/libblocks.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/checkpoints/libcheckpoints.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/device/libdevice.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/device_trezor/libdevice_trezor.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/multisig/libmultisig.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/libversion.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/net/libnet.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/hardforks/libhardforks.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/randomx/librandomx.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/rpc/librpc_base.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_format_utils_basic.a" ]]; \ - then \ - echo "Cache exist, creating /tmp/skip_deps"; \ - touch /tmp/skip_deps; \ - else \ - echo "Cache missing, this will be a looooong build."; \ - fi - name: Download monero run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && rm -rf monero && git clone ${MONERO_GIT_SOURCE} --depth=1 --branch ${MONERO_TAG} monero \ && cd monero \ @@ -194,7 +108,6 @@ jobs: && rm -f /usr/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz - name: Download Boost run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -L -o boost_${BOOST_VERSION}.tar.bz2 https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \ && echo "${BOOST_HASH} boost_${BOOST_VERSION}.tar.bz2" | sha256sum -c \ @@ -202,7 +115,6 @@ jobs: && rm -f boost_${BOOST_VERSION}.tar.bz2 - name: Download iconv run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz \ && echo "${ICONV_HASH} libiconv-${ICONV_VERSION}.tar.gz" | sha256sum -c \ @@ -210,7 +122,6 @@ jobs: && rm -f libiconv-${ICONV_VERSION}.tar.gz - name: Download zlib run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz \ && echo "${ZLIB_HASH} zlib-${ZLIB_VERSION}.tar.gz" | sha256sum -c \ @@ -219,7 +130,6 @@ jobs: && mv zlib-${ZLIB_VERSION} zlib - name: Download OpenSSL run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \ && echo "${OPENSSL_HASH} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c \ @@ -227,42 +137,36 @@ jobs: && rm openssl-${OPENSSL_VERSION}.tar.gz - name: Download ZMQ run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/zeromq/libzmq.git -b ${ZMQ_VERSION} --depth=1 \ && cd libzmq \ && test `git rev-parse HEAD` = ${ZMQ_HASH} || exit 1 - name: Download libsodium run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/jedisct1/libsodium.git -b ${SODIUM_VERSION} --depth=1 \ && cd libsodium \ && test `git rev-parse HEAD` = ${SODIUM_HASH} || exit 1 - name: Download libexpat run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/libexpat/libexpat.git -b ${LIBEXPAT_VERSION} --depth=1 \ && cd libexpat/expat \ && test `git rev-parse HEAD` = ${LIBEXPAT_HASH} || exit 1 \ - name: Download libunbound run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/NLnetLabs/unbound.git -b ${LIBUNBOUND_VERSION} --depth=1 \ && cd unbound \ && test `git rev-parse HEAD` = ${LIBUNBOUND_HASH} || exit 1 - name: Download polyseed run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/tevador/polyseed.git \ && cd polyseed \ && git reset --hard ${POLYSEED_HASH} - name: Download utf8proc run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/JuliaStrings/utf8proc -b v2.8.0 --depth=1 \ && cd utf8proc \ @@ -281,7 +185,6 @@ jobs: # TODO(mrcyjanek): x86_64-linux-gnu <- get this dynamically. - name: Build iconv (for boost) run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libiconv-${ICONV_VERSION} \ && CC=clang CXX=clang++ ./configure --build=x86_64-linux-gnu --host=${{ matrix.host_triplet }} --prefix=${PREFIX} --disable-rpath \ @@ -289,20 +192,17 @@ jobs: && make install - name: Build boost (2/2) run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd boost_${BOOST_VERSION} \ && ./b2 --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --with-locale --build-dir=android --stagedir=android toolset=clang threading=multi threadapi=pthread target-os=android -sICONV_PATH=${PREFIX} install -j${NPROC} &>/tmp/boost_log.txt || cat /tmp/boost_log.txt - name: Build zlib run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd zlib \ && CC=clang CXX=clang++ ./configure --static \ && make -j${NPROC} - name: Build OpenSSL run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd openssl-${OPENSSL_VERSION} \ && export PATH=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH \ @@ -311,7 +211,6 @@ jobs: && make install_sw &>/tmp/openssl_log_2.txt || cat /tmp/openssl_log_2.txt - name: Build ZMQ run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libzmq \ && ./autogen.sh \ @@ -320,7 +219,6 @@ jobs: && make install - name: Build Sodium run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libsodium \ && ./autogen.sh \ @@ -329,7 +227,6 @@ jobs: && make install - name: Build libexpat run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libexpat/expat \ && ./buildconf.sh \ @@ -338,7 +235,6 @@ jobs: && make install - name: Build libunbound run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd unbound \ && CC=clang CXX=clang++ ./configure --prefix=${PREFIX} --host=${{ matrix.host_triplet }} --enable-static --disable-shared --disable-flto --with-ssl=${PREFIX} --with-libexpat=${PREFIX} \ @@ -346,7 +242,6 @@ jobs: && make install - name: Build polyseed run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd polyseed \ && CC=clang CXX=clang++ cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} . \ @@ -354,7 +249,6 @@ jobs: && make install - name: Build utf8proc run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd utf8proc \ && mkdir build \ @@ -365,7 +259,6 @@ jobs: && make install - name: Build monero (1/2) configure run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd monero \ && export CMAKE_INCLUDE_PATH="${PREFIX}/include" \ @@ -380,7 +273,6 @@ jobs: && env CC=clang CXX=clang++ cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH="${{ matrix.monero_arch }}" -D STATIC=ON -D BUILD_64="${{ matrix.monero_build64 }}" -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D BUILD_TAG="${{ matrix.monero_buildtag }}" -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI="${{ matrix.full_arch }}" ../.. ; fi - name: Build monero (2/2) build run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd monero \ && cd build/release \ @@ -392,7 +284,6 @@ jobs: && make wallet_api -j${NPROC} - name: Copy prefix from $PREFIX to local run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cp -a /opt/android/prefix ${{ github.workspace }}/prefix - name: Build libbridge (1/2) configure @@ -430,44 +321,4 @@ jobs: files: |- ${{ github.workspace }}/libbridge/build/${{ matrix.host_triplet }}_libwallet2_api_c.so.xz ${{ github.workspace }}/libbridge/build/${{ matrix.host_triplet }}_libwallet2_api_c.so.sha256 - ${{ github.workspace }}/libbridge/build/${{ matrix.host_triplet }}_libwallet2_api_c.so.xz.sha256 - - name: Create cache entries - run: | - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh libsodium "${SODIUM_VERSION}-${{ matrix.host_triplet }}-${SODIUM_HASH}" ${{ github.workspace }}/prefix/lib/libsodium.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libcrypto.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libssl.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_chrono.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_date_time.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_filesystem.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_program_options.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_regex.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_serialization.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_system.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_thread.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_wserialization.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh libunbound "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/prefix/lib/libunbound.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet_api.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_core/libcryptonote_core.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_basic.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/mnemonics/libmnemonics.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/common/libcommon.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/libcncrypto.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct_basic.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blockchain_db/libblockchain_db.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/db_drivers/liblmdb/liblmdb.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/easylogging++/libeasylogging.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/contrib/epee/src/libepee.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blocks/libblocks.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/checkpoints/libcheckpoints.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device/libdevice.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device_trezor/libdevice_trezor.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/multisig/libmultisig.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/libversion.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/net/libnet.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/hardforks/libhardforks.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/randomx/librandomx.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/rpc/librpc_base.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/wallet/libwallet-crypto.a - PAT_SECRET_PACKAGE=${{ secrets.PAT_SECRET_PACKAGE }} ${{ github.workspace }}/save_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_format_utils_basic.a \ No newline at end of file + ${{ github.workspace }}/libbridge/build/${{ matrix.host_triplet }}_libwallet2_api_c.so.xz.sha256 \ No newline at end of file diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3f7ec47..0455f8f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -65,94 +65,8 @@ jobs: run: apt update && apt install -y pkg-config m4 libtool automake autoconf bison checkinstall - name: Checkout repository code uses: actions/checkout@v3 - - name: Download cached build artifacts - run: | - ${{ github.workspace }}/download_artifact.sh libsodium "${SODIUM_VERSION}-${{ matrix.host_triplet }}-${SODIUM_HASH}" ${{ github.workspace }}/prefix/lib/libsodium.a - ${{ github.workspace }}/download_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libcrypto.a - ${{ github.workspace }}/download_artifact.sh openssl "${OPENSSL_VERSION}-${{ matrix.host_triplet }}-${OPENSSL_HASH}" ${{ github.workspace }}/prefix/lib/libssl.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_chrono.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_date_time.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_filesystem.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_program_options.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_regex.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_serialization.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_system.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_thread.a - ${{ github.workspace }}/download_artifact.sh boost "${BOOST_VERSION_DOT}-${{ matrix.host_triplet }}-${BOOST_HASH}" ${{ github.workspace }}/prefix/lib/libboost_wserialization.a - ${{ github.workspace }}/download_artifact.sh libunbound "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/prefix/lib/libunbound.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet_api.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/lib/libwallet.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_core/libcryptonote_core.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_basic.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/mnemonics/libmnemonics.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/common/libcommon.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/libcncrypto.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/ringct/libringct_basic.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blockchain_db/libblockchain_db.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/db_drivers/liblmdb/liblmdb.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/easylogging++/libeasylogging.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/contrib/epee/src/libepee.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/blocks/libblocks.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/checkpoints/libcheckpoints.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device/libdevice.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/device_trezor/libdevice_trezor.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/multisig/libmultisig.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/libversion.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/net/libnet.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/hardforks/libhardforks.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/external/randomx/librandomx.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/rpc/librpc_base.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/crypto/wallet/libwallet-crypto.a - ${{ github.workspace }}/download_artifact.sh monero "${MONERO_TAG}-${{ matrix.host_triplet }}-${MONERO_GIT_SOURCE_SIMPLE}" ${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_format_utils_basic.a - - name: Create skip flag based on cache - run: | - if [[ -f "${{ github.workspace }}/prefix/lib/libsodium.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libcrypto.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libssl.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_chrono.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_date_time.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_filesystem.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_program_options.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_regex.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_serialization.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_system.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_thread.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libboost_wserialization.a" ]] \ - && [[ -f "${{ github.workspace }}/prefix/lib/libunbound.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/lib/libwallet_api.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/lib/libwallet.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_core/libcryptonote_core.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_basic.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/mnemonics/libmnemonics.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/common/libcommon.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/crypto/libcncrypto.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/ringct/libringct.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/ringct/libringct_basic.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/blockchain_db/libblockchain_db.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/db_drivers/liblmdb/liblmdb.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/easylogging++/libeasylogging.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/contrib/epee/src/libepee.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/blocks/libblocks.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/checkpoints/libcheckpoints.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/device/libdevice.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/device_trezor/libdevice_trezor.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/multisig/libmultisig.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/libversion.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/net/libnet.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/hardforks/libhardforks.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/external/randomx/librandomx.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/rpc/librpc_base.a" ]] \ - && [[ -f "${{ github.workspace }}/monero/build/release/src/cryptonote_basic/libcryptonote_format_utils_basic.a" ]]; \ - then \ - echo "Cache exist, creating /tmp/skip_deps"; \ - touch /tmp/skip_deps; \ - else \ - echo "Cache missing, this will be a looooong build."; \ - fi - name: Download monero run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && rm -rf monero && git clone ${MONERO_GIT_SOURCE} --depth=1 --branch ${MONERO_TAG} monero \ && cd monero \ @@ -167,7 +81,6 @@ jobs: && rm -f /usr/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz - name: Download Boost run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -L -o boost_${BOOST_VERSION}.tar.bz2 https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2 \ && echo "${BOOST_HASH} boost_${BOOST_VERSION}.tar.bz2" | sha256sum -c \ @@ -175,7 +88,6 @@ jobs: && rm -f boost_${BOOST_VERSION}.tar.bz2 - name: Download iconv run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ICONV_VERSION}.tar.gz \ && echo "${ICONV_HASH} libiconv-${ICONV_VERSION}.tar.gz" | sha256sum -c \ @@ -183,7 +95,6 @@ jobs: && rm -f libiconv-${ICONV_VERSION}.tar.gz - name: Download zlib run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz \ && echo "${ZLIB_HASH} zlib-${ZLIB_VERSION}.tar.gz" | sha256sum -c \ @@ -192,7 +103,6 @@ jobs: && mv zlib-${ZLIB_VERSION} zlib - name: Download OpenSSL run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && curl -O https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz \ && echo "${OPENSSL_HASH} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c \ @@ -200,49 +110,42 @@ jobs: && rm openssl-${OPENSSL_VERSION}.tar.gz - name: Download ZMQ run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/zeromq/libzmq.git -b ${ZMQ_VERSION} --depth=1 \ && cd libzmq \ && test `git rev-parse HEAD` = ${ZMQ_HASH} || exit 1 - name: Download libsodium run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/jedisct1/libsodium.git -b ${SODIUM_VERSION} --depth=1 \ && cd libsodium \ && test `git rev-parse HEAD` = ${SODIUM_HASH} || exit 1 - name: Download libexpat run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/libexpat/libexpat.git -b ${LIBEXPAT_VERSION} --depth=1 \ && cd libexpat/expat \ && test `git rev-parse HEAD` = ${LIBEXPAT_HASH} || exit 1 \ - name: Download libunbound run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/NLnetLabs/unbound.git -b ${LIBUNBOUND_VERSION} --depth=1 \ && cd unbound \ && test `git rev-parse HEAD` = ${LIBUNBOUND_HASH} || exit 1 - name: Download polyseed run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/tevador/polyseed.git \ && cd polyseed \ && git reset --hard ${POLYSEED_HASH} - name: Download utf8proc run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && git clone https://github.com/JuliaStrings/utf8proc -b v2.8.0 --depth=1 \ && cd utf8proc \ && git reset --hard ${UTF8PROC_HASH} - name: Build boost (1/2) run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd boost_${BOOST_VERSION} \ && ./bootstrap.sh --prefix=${PREFIX} @@ -250,7 +153,6 @@ jobs: # TODO(mrcyjanek): x86_64-linux-gnu <- get this dynamically. - name: Build iconv (for boost) run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libiconv-${ICONV_VERSION} \ && ./configure --build=x86_64-linux-gnu --host=${{ matrix.host_triplet }} --prefix=${PREFIX} --disable-rpath \ @@ -258,21 +160,18 @@ jobs: && make install - name: Build boost (2/2) run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd boost_${BOOST_VERSION} \ && echo -n -e '\n#undef PTHREAD_STACK_MIN\n#define PTHREAD_STACK_MIN 16384\n' | cat - ./boost/thread/pthread/thread_data.hpp > temp && mv temp ./boost/thread/pthread/thread_data.hpp \ && ./b2 cxxflags=-fPIC cflags=-fPIC --build-type=minimal link=static runtime-link=static --with-chrono --with-date_time --with-filesystem --with-program_options --with-regex --with-serialization --with-system --with-thread --with-locale --build-dir=linux --stagedir=linux toolset=gcc threading=multi threadapi=pthread -sICONV_PATH=${PREFIX} install -j${NPROC} &>/tmp/boost_log.txt || cat /tmp/boost_log.txt - name: Build zlib run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd zlib \ && ./configure --static \ && make -j${NPROC} - name: Build OpenSSL run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd openssl-${OPENSSL_VERSION} \ && ./Configure -static no-shared no-tests --with-zlib-include=${{ github.workspace }}/zlib/include --with-zlib-lib=${{ github.workspace }}/zlib/lib --prefix=${PREFIX} --openssldir=${PREFIX} -fpic \ @@ -280,7 +179,6 @@ jobs: && make install_sw &>/tmp/openssl_log_2.txt || cat /tmp/openssl_log_2.txt - name: Build ZMQ run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libzmq \ && ./autogen.sh \ @@ -290,7 +188,6 @@ jobs: && make install - name: Build Sodium run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libsodium \ && ./autogen.sh \ @@ -299,7 +196,6 @@ jobs: && make install - name: Build libexpat run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd libexpat/expat \ && ./buildconf.sh \ @@ -308,11 +204,9 @@ jobs: && make install - name: Fix paths run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cp /opt/linux/prefix/lib64/* /opt/linux/prefix/lib -r - name: Build libunbound run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd unbound \ && ./configure -with-pic --prefix=${PREFIX} --enable-static --disable-shared --disable-flto --with-libexpat=${PREFIX} --with-ssl=${PREFIX} \ @@ -320,7 +214,6 @@ jobs: && make install - name: Build polyseed run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd polyseed \ && cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} . \ @@ -328,7 +221,6 @@ jobs: && make install - name: Build utf8proc run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd utf8proc \ && mkdir build \ @@ -339,7 +231,6 @@ jobs: && make install - name: Build monero (1/2) configure run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd monero \ && export CMAKE_INCLUDE_PATH="${PREFIX}/include" \ @@ -350,7 +241,6 @@ jobs: && env cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH="${{ matrix.monero_arch }}" -D STATIC=ON -D BUILD_64="${{ matrix.monero_build64 }}" -D CMAKE_BUILD_TYPE=release -D ANDROID=false -D BUILD_TAG="${{ matrix.monero_buildtag }}" -D CMAKE_SYSTEM_NAME="Linux" ../.. - name: Build monero (2/2) build run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cd monero \ && cd build/release \ @@ -361,7 +251,6 @@ jobs: && make wallet_api -j${NPROC} - name: Copy prefix from $PREFIX to local run: | - [[ -f "/tmp/skip_deps" ]] && exit 0; \ cd ${{ github.workspace }} \ && cp -a /opt/linux/prefix/lib64/* /opt/linux/prefix/lib \ && cp -a /opt/linux/prefix ${{ github.workspace }}/prefix diff --git a/libbridge/src/main/cpp/helpers.cpp b/libbridge/src/main/cpp/helpers.cpp index 064ce36..fac131a 100644 --- a/libbridge/src/main/cpp/helpers.cpp +++ b/libbridge/src/main/cpp/helpers.cpp @@ -143,3 +143,17 @@ const char* vectorToString(const std::set& intSet, const std::string s memcpy(buffer, str.c_str(), size + 1); return buffer; } + +std::set splitString(const std::string& str, const std::string& delim) { + std::set tokens; + size_t pos = 0; + std::string token; + std::string content = str; // Copy of str so we can safely erase content + while ((pos = content.find(delim)) != std::string::npos) { + token = content.substr(0, pos); + tokens.insert(token); + content.erase(0, pos + delim.length()); + } + tokens.insert(content); // Inserting the last token + return tokens; +} \ No newline at end of file diff --git a/libbridge/src/main/cpp/helpers.hpp b/libbridge/src/main/cpp/helpers.hpp index 5d9b4a4..45fa624 100644 --- a/libbridge/src/main/cpp/helpers.hpp +++ b/libbridge/src/main/cpp/helpers.hpp @@ -7,4 +7,5 @@ const char* vectorToString(const std::vector& vec, const std::strin const char* vectorToString(const std::vector& vec, const std::string separator); const char* vectorToString(const std::vector& vec, const std::string separator); const char* vectorToString(const std::vector>& vec, const std::string separator); -const char* vectorToString(const std::set& intSet, const std::string separator); \ No newline at end of file +const char* vectorToString(const std::set& intSet, const std::string separator); +std::set splitString(const std::string& str, const std::string& delim); \ No newline at end of file diff --git a/libbridge/src/main/cpp/wallet2_api.h b/libbridge/src/main/cpp/wallet2_api.h index 646e585..5612c66 100644 --- a/libbridge/src/main/cpp/wallet2_api.h +++ b/libbridge/src/main/cpp/wallet2_api.h @@ -38,6 +38,7 @@ #include #include #include +#include // Public interface for libwallet library namespace Monero { @@ -287,6 +288,7 @@ struct CoinsInfo virtual bool unlocked() const = 0; virtual std::string pubKey() const = 0; virtual bool coinbase() const = 0; + virtual std::string description() const = 0; }; struct Coins @@ -296,9 +298,12 @@ struct Coins virtual CoinsInfo * coin(int index) const = 0; virtual std::vector getAll() const = 0; virtual void refresh() = 0; + virtual void setFrozen(std::string public_key) = 0; virtual void setFrozen(int index) = 0; + virtual void thaw(std::string public_key) = 0; virtual void thaw(int index) = 0; virtual bool isTransferUnlocked(uint64_t unlockTime, uint64_t blockHeight) = 0; + virtual void setDescription(const std::string &public_key, const std::string &description) = 0; }; struct SubaddressRow { @@ -485,6 +490,12 @@ struct Wallet ConnectionStatus_WrongVersion }; + enum BackgroundSyncType { + BackgroundSync_Off = 0, + BackgroundSync_ReusePassword = 1, + BackgroundSync_CustomPassword = 2 + }; + virtual ~Wallet() = 0; virtual std::string seed(const std::string& seed_offset = "") const = 0; virtual std::string getSeedLanguage() const = 0; @@ -660,6 +671,7 @@ struct Wallet result += unlockedBalance(i); return result; } + virtual uint64_t viewOnlyBalance(uint32_t accountIndex, const std::vector &key_images = {}) const = 0; /** * @brief watchOnly - checks if wallet is watch only @@ -740,6 +752,10 @@ struct Wallet static void warning(const std::string &category, const std::string &str); static void error(const std::string &category, const std::string &str); + virtual bool getPolyseed(std::string &seed, std::string &passphrase) const = 0; + static bool createPolyseed(std::string &seed_words, std::string &err, const std::string &language = "English"); + static std::vector> getPolyseedLanguages(); + /** * @brief StartRefresh - Start/resume refresh thread (refresh every 10 seconds) */ @@ -883,7 +899,8 @@ struct Wallet optional> amount, uint32_t mixin_count, PendingTransaction::Priority = PendingTransaction::Priority_Low, uint32_t subaddr_account = 0, - std::set subaddr_indices = {}) = 0; + std::set subaddr_indices = {}, + const std::set &preferred_inputs = {}) = 0; /*! * \brief createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored @@ -902,7 +919,8 @@ struct Wallet optional amount, uint32_t mixin_count, PendingTransaction::Priority = PendingTransaction::Priority_Low, uint32_t subaddr_account = 0, - std::set subaddr_indices = {}) = 0; + std::set subaddr_indices = {}, + const std::set &preferred_inputs = {}) = 0; /*! * \brief createSweepUnmixableTransaction creates transaction with unmixable outputs. @@ -940,6 +958,8 @@ struct Wallet virtual uint64_t estimateTransactionFee(const std::vector> &destinations, PendingTransaction::Priority priority) const = 0; + virtual bool hasUnknownKeyImages() const = 0; + /*! * \brief exportKeyImages - exports key images to file * \param filename @@ -976,6 +996,43 @@ struct Wallet */ virtual bool scanTransactions(const std::vector &txids) = 0; + /*! + * \brief setupBackgroundSync - setup background sync mode with just a view key + * \param background_sync_type - the mode the wallet background syncs in + * \param wallet_password + * \param background_cache_password - custom password to encrypt background cache, only needed for custom password background sync type + * \return - true on success + */ + virtual bool setupBackgroundSync(const BackgroundSyncType background_sync_type, const std::string &wallet_password, const optional &background_cache_password) = 0; + + /*! + * \brief getBackgroundSyncType - get mode the wallet background syncs in + * \return - the type, or off if type is unknown + */ + virtual BackgroundSyncType getBackgroundSyncType() const = 0; + + /** + * @brief startBackgroundSync - sync the chain in the background with just view key + */ + virtual bool startBackgroundSync() = 0; + + /** + * @brief stopBackgroundSync - bring back spend key and process background synced txs + * \param wallet_password + */ + virtual bool stopBackgroundSync(const std::string &wallet_password) = 0; + + /** + * @brief isBackgroundSyncing - returns true if the wallet is background syncing + */ + virtual bool isBackgroundSyncing() const = 0; + + /** + * @brief isBackgroundWallet - returns true if the wallet is a background wallet + */ + virtual bool isBackgroundWallet() const = 0; + + virtual TransactionHistory * history() = 0; virtual AddressBook * addressBook() = 0; virtual Coins * coins() = 0; @@ -1297,6 +1354,27 @@ struct WalletManager uint64_t kdf_rounds = 1, WalletListener * listener = nullptr) = 0; + /*! + * \brief creates a wallet from a polyseed mnemonic phrase + * \param path Name of the wallet file to be created + * \param password Password of wallet file + * \param nettype Network type + * \param mnemonic Polyseed mnemonic + * \param passphrase Optional seed offset passphrase + * \param newWallet Whether it is a new wallet + * \param restoreHeight Override the embedded restore height + * \param kdf_rounds Number of rounds for key derivation function + * @return + */ + virtual Wallet * createWalletFromPolyseed(const std::string &path, + const std::string &password, + NetworkType nettype, + const std::string &mnemonic, + const std::string &passphrase = "", + bool newWallet = true, + uint64_t restore_height = 0, + uint64_t kdf_rounds = 1) = 0; + /*! * \brief Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed, wallet object not deleted * \param wallet previously opened / created wallet instance diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 97b6fa8..388c0b0 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -475,6 +475,15 @@ bool MONERO_CoinsInfo_coinbase(void* coinsInfo_ptr) { Monero::CoinsInfo *coinsInfo = reinterpret_cast(coinsInfo_ptr); return coinsInfo->internalOutputIndex(); } +// virtual std::string description() const = 0; +const char* MONERO_CoinsInfo_description(void* coinsInfo_ptr) { + Monero::CoinsInfo *coinsInfo = reinterpret_cast(coinsInfo_ptr); + std::string str = coinsInfo->description(); + const std::string::size_type size = str.size(); + char *buffer = new char[size + 1]; //we need extra char for NUL + memcpy(buffer, str.c_str(), size + 1); + return buffer; +} // coins @@ -496,6 +505,11 @@ void MONERO_Coins_refresh(void* coins_ptr) { Monero::Coins *coins = reinterpret_cast(coins_ptr); return coins->refresh(); } +// virtual void setFrozen(std::string public_key) = 0; +void MONERO_Coins_setFrozenByPublicKey(void* coins_ptr, const char* public_key) { + Monero::Coins *coins = reinterpret_cast(coins_ptr); + return coins->setFrozen(std::string(public_key)); +} // virtual void setFrozen(int index) = 0; void MONERO_Coins_setFrozen(void* coins_ptr, int index) { Monero::Coins *coins = reinterpret_cast(coins_ptr); @@ -506,11 +520,21 @@ void MONERO_Coins_thaw(void* coins_ptr, int index) { Monero::Coins *coins = reinterpret_cast(coins_ptr); return coins->thaw(index); } +// virtual void thaw(std::string public_key) = 0; +void MONERO_Coins_thawByPublicKey(void* coins_ptr, const char* public_key) { + Monero::Coins *coins = reinterpret_cast(coins_ptr); + return coins->thaw(std::string(public_key)); +} // virtual bool isTransferUnlocked(uint64_t unlockTime, uint64_t blockHeight) = 0; bool MONERO_Coins_isTransferUnlocked(void* coins_ptr, uint64_t unlockTime, uint64_t blockHeight) { Monero::Coins *coins = reinterpret_cast(coins_ptr); return coins->isTransferUnlocked(unlockTime, blockHeight); } +// virtual void setDescription(const std::string &public_key, const std::string &description) = 0; +void MONERO_Coins_setDescription(void* coins_ptr, const char* public_key, const char* description) { + Monero::Coins *coins = reinterpret_cast(coins_ptr); + coins->setDescription(std::string(public_key), std::string(description)); +} // SubaddressRow @@ -923,6 +947,11 @@ uint64_t MONERO_Wallet_unlockedBalance(void* wallet_ptr, uint32_t accountIndex) return wallet->unlockedBalance(accountIndex); } +uint64_t MONERO_Wallet_viewOnlyBalance(void* wallet_ptr, uint32_t accountIndex) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->viewOnlyBalance(accountIndex); +} + // TODO bool MONERO_Wallet_watchOnly(void* wallet_ptr) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); @@ -1035,6 +1064,29 @@ void MONERO_Wallet_init3(void* wallet_ptr, const char* argv0, const char* defaul Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->init(argv0, default_log_base_name, log_path, console); } +const char* MONERO_Wallet_getPolyseed(void* wallet_ptr, const char* passphrase) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + std::string seed = ""; + std::string _passphrase = std::string(passphrase); + wallet->getPolyseed(seed, _passphrase); + std::string str = seed; + const std::string::size_type size = str.size(); + char *buffer = new char[size + 1]; //we need extra char for NUL + memcpy(buffer, str.c_str(), size + 1); + return buffer; +} +// static bool createPolyseed(std::string &seed_words, std::string &err, const std::string &language = "English"); +const char* MONERO_Wallet_createPolyseed() { + std::string seed_words = ""; + std::string err; + Monero::Wallet::createPolyseed(seed_words, err); + std::string str = seed_words; + const std::string::size_type size = str.size(); + char *buffer = new char[size + 1]; //we need extra char for NUL + memcpy(buffer, str.c_str(), size + 1); + return buffer; +} + void MONERO_Wallet_startRefresh(void* wallet_ptr) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->startRefresh(); @@ -1107,16 +1159,19 @@ const char* MONERO_Wallet_getMultisigInfo(void* wallet_ptr) { void* MONERO_Wallet_createTransaction(void* wallet_ptr, const char* dst_addr, const char* payment_id, uint64_t amount, uint32_t mixin_count, int pendingTransactionPriority, - uint32_t subaddr_account) { + uint32_t subaddr_account, + const char* preferredInputs, const char* separator) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); Monero::optional optAmount; if (amount != 0) { optAmount = amount; } + std::set subaddr_indices = {}; + std::set preferred_inputs = splitString(std::string(preferredInputs), std::string(separator)); return wallet->createTransaction(std::string(dst_addr), std::string(payment_id), optAmount, mixin_count, Monero::PendingTransaction::Priority_Low, - subaddr_account /*, subaddr_indices */); + subaddr_account, subaddr_indices); } void* MONERO_Wallet_loadUnsignedTx(void* wallet_ptr, const char* fileName) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); @@ -1126,6 +1181,10 @@ bool MONERO_Wallet_submitTransaction(void* wallet_ptr, const char* fileName) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->submitTransaction(std::string(fileName)); } +bool MONERO_Wallet_hasUnknownKeyImages(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->hasUnknownKeyImages(); +} bool MONERO_Wallet_exportKeyImages(void* wallet_ptr, const char* filename, bool all) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->exportKeyImages(std::string(filename), all); @@ -1142,6 +1201,36 @@ bool MONERO_Wallet_importOutputs(void* wallet_ptr, const char* filename) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->importOutputs(std::string(filename)); } +// virtual bool setupBackgroundSync(const BackgroundSyncType background_sync_type, const std::string &wallet_password, const optional &background_cache_password) = 0; +bool MONERO_Wallet_setupBackgroundSync(void* wallet_ptr, int background_sync_type, const char* wallet_password, const char* background_cache_password) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->setupBackgroundSync(Monero::Wallet::BackgroundSyncType::BackgroundSync_CustomPassword, std::string(wallet_password), std::string(background_cache_password)); +} +// virtual BackgroundSyncType getBackgroundSyncType() const = 0; +int MONERO_Wallet_getBackgroundSyncType(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->getBackgroundSyncType(); +} +// virtual bool startBackgroundSync() = 0; +bool MONERO_Wallet_startBackgroundSync(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->startBackgroundSync(); +} +// virtual bool stopBackgroundSync(const std::string &wallet_password) = 0; +bool MONERO_Wallet_stopBackgroundSync(void* wallet_ptr, const char* wallet_password) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->stopBackgroundSync(std::string(wallet_password)); +} +// virtual bool isBackgroundSyncing() const = 0; +bool MONERO_Wallet_isBackgroundSyncing(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->hasUnknownKeyImages(); +} +// virtual bool isBackgroundWallet() const = 0; +bool MONERO_Wallet_isBackgroundWallet(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return wallet->isBackgroundWallet(); +} void* MONERO_Wallet_history(void* wallet_ptr) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return wallet->history(); @@ -1325,6 +1414,20 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password return reinterpret_cast(wallet); } +void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char* password, + int nettype, const char* mnemonic, const char* passphrase, + bool newWallet, uint64_t restore_height, uint64_t kdf_rounds) { + return Monero::WalletManagerFactory::getWalletManager()->createWalletFromPolyseed(std::string(path), + std::string(password), + static_cast(nettype), + std::string(mnemonic), + std::string(passphrase), + newWallet, + restore_height, + kdf_rounds); +} + + bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); return Monero::WalletManagerFactory::getWalletManager()->closeWallet( diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index 6e9c971..53b75f2 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -293,6 +293,8 @@ bool MONERO_CoinsInfo_unlocked(void* coinsInfo_ptr); const char* MONERO_CoinsInfo_pubKey(void* coinsInfo_ptr); // virtual bool coinbase() const = 0; bool MONERO_CoinsInfo_coinbase(void* coinsInfo_ptr); +// virtual std::string description() const = 0; +const char* MONERO_CoinsInfo_description(void* coinsInfo_ptr); // }; // struct Coins // { @@ -304,12 +306,18 @@ void* MONERO_Coins_coin(void* coins_ptr, int index); // virtual std::vector getAll() const = 0; // virtual void refresh() = 0; void MONERO_Coins_refresh(void* coins_ptr); +// virtual void setFrozen(std::string public_key) = 0; +void MONERO_Coins_setFrozenByPublicKey(void* coins_ptr, const char* public_key); // virtual void setFrozen(int index) = 0; void MONERO_Coins_setFrozen(void* coins_ptr, int index); // virtual void thaw(int index) = 0; void MONERO_Coins_thaw(void* coins_ptr, int index); +// virtual void thaw(std::string public_key) = 0; +void MONERO_Coins_thawByPublicKey(void* coins_ptr, const char* public_key); // virtual bool isTransferUnlocked(uint64_t unlockTime, uint64_t blockHeight) = 0; bool MONERO_Coins_isTransferUnlocked(void* coins_ptr, uint64_t unlockTime, uint64_t blockHeight); +// virtual void setDescription(const std::string &public_key, const std::string &description) = 0; +void MONERO_Coins_setDescription(void* coins_ptr, const char* public_key, const char* description); // }; // struct SubaddressRow { // public: @@ -467,6 +475,14 @@ const int WalletConnectionStatus_Connected = 1; // ConnectionStatus_WrongVersion const int WalletConnectionStatus_WrongVersion = 2; // }; +// enum BackgroundSyncType { +// BackgroundSync_Off = 0, +const int WalletBackgroundSync_Off = 0; +// BackgroundSync_ReusePassword = 1, +const int WalletBackgroundSync_ReusePassword = 1; +// BackgroundSync_CustomPassword = 2 +const int BackgroundSync_CustomPassword = 2; +// }; // virtual ~Wallet() = 0; // virtual std::string seed(const std::string& seed_offset = "") const = 0; const char* MONERO_Wallet_seed(void* wallet_ptr, const char* seed_offset); @@ -561,6 +577,8 @@ uint64_t MONERO_Wallet_unlockedBalance(void* wallet_ptr, uint32_t accountIndex); // return result; // } // virtual bool watchOnly() const = 0; +// virtual uint64_t viewOnlyBalance(uint32_t accountIndex, const std::vector &key_images = {}) const = 0; +uint64_t MONERO_Wallet_viewOnlyBalance(void* wallet_ptr, uint32_t accountIndex); bool MONERO_Wallet_watchOnly(void* wallet_ptr); // virtual bool isDeterministic() const = 0; bool MONERO_Wallet_isDeterministic(void* wallet_ptr); @@ -617,6 +635,10 @@ void MONERO_Wallet_init3(void* wallet_ptr, const char* argv0, const char* defaul // static void warning(const std::string &category, const std::string &str); // static void error(const std::string &category, const std::string &str); // virtual void startRefresh() = 0; +// virtual bool getPolyseed(std::string &seed, std::string &passphrase) const = 0; +const char* MONERO_Wallet_getPolyseed(void* wallet_ptr, const char* passphrase); +// static bool createPolyseed(std::string &seed_words, std::string &err, const std::string &language = "English"); +const char* MONERO_Wallet_createPolyseed(); void MONERO_Wallet_startRefresh(void* wallet_ptr); // virtual void pauseRefresh() = 0; void MONERO_Wallet_pauseRefresh(void* wallet_ptr); @@ -662,11 +684,13 @@ const char* MONERO_Wallet_getMultisigInfo(void* wallet_ptr); // optional amount, uint32_t mixin_count, // PendingTransaction::Priority = PendingTransaction::Priority_Low, // uint32_t subaddr_account = 0, -// std::set subaddr_indices = {}) = 0; +// std::set subaddr_indices = {}, +// const std::set &preferred_inputs = {) = 0; void* MONERO_Wallet_createTransaction(void* wallet_ptr, const char* dst_addr, const char* payment_id, uint64_t amount, uint32_t mixin_count, int pendingTransactionPriority, - uint32_t subaddr_account); // std::nullopt + uint32_t subaddr_account, + const char* preferredInputs, const char* separator); // virtual PendingTransaction * createSweepUnmixableTransaction() = 0; // virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) = 0; void* MONERO_Wallet_loadUnsignedTx(void* wallet_ptr, const char* unsigned_filename); @@ -675,6 +699,8 @@ bool MONERO_Wallet_submitTransaction(void* wallet_ptr, const char* fileName); // virtual void disposeTransaction(PendingTransaction * t) = 0; // virtual uint64_t estimateTransactionFee(const std::vector> &destinations, // PendingTransaction::Priority priority) const = 0; +// virtual bool hasUnknownKeyImages() const = 0; +bool MONERO_Wallet_hasUnknownKeyImages(void* wallet_ptr); // virtual bool exportKeyImages(const std::string &filename, bool all = false) = 0; bool MONERO_Wallet_exportKeyImages(void* wallet_ptr, const char* filename, bool all); // virtual bool importKeyImages(const std::string &filename) = 0; @@ -684,6 +710,18 @@ bool MONERO_Wallet_exportOutputs(void* wallet_ptr, const char* filename, bool al // virtual bool importOutputs(const std::string &filename) = 0; bool MONERO_Wallet_importOutputs(void* wallet_ptr, const char* filename); // virtual bool scanTransactions(const std::vector &txids) = 0; +// virtual bool setupBackgroundSync(const BackgroundSyncType background_sync_type, const std::string &wallet_password, const optional &background_cache_password) = 0; +bool MONERO_Wallet_setupBackgroundSync(void* wallet_ptr, int background_sync_type, const char* wallet_password, const char* background_cache_password); +// virtual BackgroundSyncType getBackgroundSyncType() const = 0; +int MONERO_Wallet_getBackgroundSyncType(void* wallet_ptr); +// virtual bool startBackgroundSync() = 0; +bool MONERO_Wallet_startBackgroundSync(void* wallet_ptr); +// virtual bool stopBackgroundSync(const std::string &wallet_password) = 0; +bool MONERO_Wallet_stopBackgroundSync(void* wallet_ptr, const char* wallet_password); +// virtual bool isBackgroundSyncing() const = 0; +bool MONERO_Wallet_isBackgroundSyncing(void* wallet_ptr); +// virtual bool isBackgroundWallet() const = 0; +bool MONERO_Wallet_isBackgroundWallet(void* wallet_ptr); // virtual TransactionHistory * history() = 0; void* MONERO_Wallet_history(void* wallet_ptr); // virtual AddressBook * addressBook() = 0; @@ -836,6 +874,17 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password // const std::string &subaddressLookahead = "", // uint64_t kdf_rounds = 1, // WalletListener * listener = nullptr) = 0; +// virtual Wallet * createWalletFromPolyseed(const std::string &path, +// const std::string &password, +// NetworkType nettype, +// const std::string &mnemonic, +// const std::string &passphrase = "", +// bool newWallet = true, +// uint64_t restore_height = 0, +// uint64_t kdf_rounds = 1) = 0; +void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char* password, + int nettype, const char* mnemonic, const char* passphrase, + bool newWallet, uint64_t restore_height, uint64_t kdf_rounds); // virtual bool closeWallet(Wallet *wallet, bool store = true) = 0; bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store); // virtual bool walletExists(const std::string &path) = 0; -- cgit v1.2.3 From a2ef1040df905f00482597b50eaec62f4f7b99b1 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 5 Jan 2024 14:59:45 +0100 Subject: coins update --- .github/workflows/linux.yml | 6 ++++-- libbridge/src/main/cpp/wallet2_api_c.cpp | 10 ++++++++++ libbridge/src/main/cpp/wallet2_api_c.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'libbridge/src') diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0455f8f..0630b8b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,7 +1,9 @@ name: Linux Release run-name: Building monero_c for linux -on: push - +on: + push: + tags: + - '*' # cat envs.txt | sed 's/ //g' | sed 's/: /=/g' | grep -v '#' > .env # export $(cat .env | xargs) env: diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 388c0b0..3e56263 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -499,6 +499,16 @@ void* MONERO_Coins_coin(void* coins_ptr, int index) { Monero::Coins *coins = reinterpret_cast(coins_ptr); return coins->coin(index); } + +int MONERO_Coins_getAll_size(void* coins_ptr) { + Monero::Coins *coins = reinterpret_cast(coins_ptr); + return coins->getAll().size(); +} +void* MONERO_Coins_getAll_byIndex(void* coins_ptr, int index) { + Monero::Coins *coins = reinterpret_cast(coins_ptr); + return coins->getAll()[index]; +} + // virtual std::vector getAll() const = 0; // virtual void refresh() = 0; void MONERO_Coins_refresh(void* coins_ptr) { diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index 53b75f2..27aa2e3 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -304,6 +304,8 @@ int MONERO_Coins_count(void* coins_ptr); // virtual CoinsInfo * coin(int index) const = 0; void* MONERO_Coins_coin(void* coins_ptr, int index); // virtual std::vector getAll() const = 0; +int MONERO_Coins_getAll_size(void* coins_ptr); +void* MONERO_Coins_getAll_byIndex(void* coins_ptr, int index); // virtual void refresh() = 0; void MONERO_Coins_refresh(void* coins_ptr); // virtual void setFrozen(std::string public_key) = 0; -- cgit v1.2.3 From 54611055816001884a91c1760722de8c0af8b294 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 5 Jan 2024 17:32:49 +0100 Subject: fix splitString, add logging --- libbridge/src/main/cpp/helpers.cpp | 1 + libbridge/src/main/cpp/wallet2_api_c.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/helpers.cpp b/libbridge/src/main/cpp/helpers.cpp index fac131a..04befc6 100644 --- a/libbridge/src/main/cpp/helpers.cpp +++ b/libbridge/src/main/cpp/helpers.cpp @@ -146,6 +146,7 @@ const char* vectorToString(const std::set& intSet, const std::string s std::set splitString(const std::string& str, const std::string& delim) { std::set tokens; + if (str.empty()) return tokens; size_t pos = 0; std::string token; std::string content = str; // Copy of str so we can safely erase content diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 3e56263..31f3bd4 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1178,10 +1178,15 @@ void* MONERO_Wallet_createTransaction(void* wallet_ptr, const char* dst_addr, co } std::set subaddr_indices = {}; std::set preferred_inputs = splitString(std::string(preferredInputs), std::string(separator)); + wallet->info("MONERO_C", "TEST"); + wallet->info("MONERO_C", preferredInputs); + wallet->info("MONERO_C", std::to_string(preferred_inputs.size())); + auto oneInput = *(preferred_inputs.begin()); + wallet->info("MONERO_C", oneInput); return wallet->createTransaction(std::string(dst_addr), std::string(payment_id), optAmount, mixin_count, Monero::PendingTransaction::Priority_Low, - subaddr_account, subaddr_indices); + subaddr_account, subaddr_indices, preferred_inputs); } void* MONERO_Wallet_loadUnsignedTx(void* wallet_ptr, const char* fileName) { Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); -- cgit v1.2.3 From 74d93461682559a36eecb4b7b0e5728cd7f5389f Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Sun, 7 Jan 2024 14:38:45 +0100 Subject: view-only support --- README.md | 10 +++++----- libbridge/src/main/cpp/wallet2_api_c.cpp | 22 ++++++++++++++++++++++ libbridge/src/main/cpp/wallet2_api_c.h | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) (limited to 'libbridge/src') diff --git a/README.md b/README.md index 8c3a1a1..29254da 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,10 @@ $ docker run --rm -it \ -v $PWD/libbridge:/opt/wspace/libbridge_up \ --entrypoint /bin/bash \ monero_c:dev -[docker] $ export 'PATH=/usr/cmake-3.14.6-Linux-x86_64/bin:/opt/android/toolchain/aarch64-linux-android/bin:/opt/android/toolchain/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -[docker] $ cd /opt/wspace/libbridge_up -[docker] $ rm -rf build && mkdir build && cd build -[docker] $ env CC=clang CXX=clang++ cmake -DANDROID_ABI=-arm64-v8a .. -[docker] $ make +[docker] $ export 'PATH=/usr/cmake-3.14.6-Linux-x86_64/bin:/opt/android/toolchain/aarch64-linux-android/bin:/opt/android/toolchain/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' \ + && cd /opt/wspace/libbridge_up \ + && rm -rf build && mkdir build && cd build \ + && env CC=clang CXX=clang++ cmake -DANDROID_ABI=-arm64-v8a .. \ + && make # Resulting file will be available in the current directory. ``` diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 31f3bd4..95931fc 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1428,6 +1428,28 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password std::string(seedOffset)); return reinterpret_cast(wallet); } +// virtual Wallet * createWalletFromKeys(const std::string &path, +// const std::string &password, +// const std::string &language, +// NetworkType nettype, +// uint64_t restoreHeight, +// const std::string &addressString, +// const std::string &viewKeyString, +// const std::string &spendKeyString = "", +// uint64_t kdf_rounds = 1) = 0; +void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds) { + Monero::Wallet *wallet = + Monero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( + std::string(path), + std::string(password), + std::string(language), + static_cast(nettype), + restoreHeight, + std::string(addressString), + std::string(viewKeyString), + std::string(spendKeyString)); + return reinterpret_cast(wallet); +} void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char* password, int nettype, const char* mnemonic, const char* passphrase, diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index 27aa2e3..0f993c3 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -840,6 +840,7 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password // const std::string &viewKeyString, // const std::string &spendKeyString = "", // uint64_t kdf_rounds = 1) = 0; +void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds); // Wallet * createWalletFromKeys(const std::string &path, // const std::string &password, // const std::string &language, -- cgit v1.2.3 From 5fd5036ea39b4e5ea4b828d0804cf1a039df9a1a Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Thu, 11 Jan 2024 15:15:57 +0100 Subject: add `MONERO_DEBUG_isPointerNull` --- libbridge/src/main/cpp/wallet2_api_c.cpp | 5 +++++ libbridge/src/main/cpp/wallet2_api_c.h | 1 + 2 files changed, 6 insertions(+) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 95931fc..82024c5 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1597,6 +1597,11 @@ const char* MONERO_DEBUG_test5_std() { return text2; } +bool MONERO_DEBUG_isPointerNull(void* wallet_ptr) { + Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); + return (wallet != NULL); +} + #ifdef __cplusplus } #endif diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index 0f993c3..d838608 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -966,6 +966,7 @@ uint64_t MONERO_DEBUG_test3(uint64_t x); void* MONERO_DEBUG_test4(uint64_t x); const char* MONERO_DEBUG_test5(); const char* MONERO_DEBUG_test5_std(); +bool MONERO_DEBUG_isPointerNull(void* wallet_ptr); #ifdef __cplusplus } -- cgit v1.2.3 From f8bc659801c3d00cc9adb2d4310f8d402ca60263 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 19 Jan 2024 10:25:27 +0100 Subject: fix walletmanager wrap --- libbridge/src/main/cpp/wallet2_api_c.cpp | 116 ++++++++++++++++++------------- libbridge/src/main/cpp/wallet2_api_c.h | 42 +++++------ 2 files changed, 89 insertions(+), 69 deletions(-) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index 82024c5..bcc2d97 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1395,9 +1395,14 @@ uint64_t MONERO_Wallet_getBytesSent(void* wallet_ptr) { return wallet->getBytesSent(); } -void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType) { - Monero::Wallet *wallet = - Monero::WalletManagerFactory::getWalletManager()->createWallet( +void* MONERO_WalletManagerFactory_getWalletManager() { + Monero::WalletManager *wm = Monero::WalletManagerFactory::getWalletManager(); + return reinterpret_cast(wm); +} + +void* MONERO_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + Monero::Wallet *wallet = wm->createWallet( std::string(path), std::string(password), std::string(language), @@ -1405,20 +1410,20 @@ void* MONERO_WalletManager_createWallet(const char* path, const char* password, return reinterpret_cast(wallet); } -void* MONERO_WalletManager_openWallet(const char* path, const char* password, int networkType) { - Monero::Wallet *wallet = - Monero::WalletManagerFactory::getWalletManager()->openWallet( +void* MONERO_WalletManager_openWallet(void* wm_ptr, const char* path, const char* password, int networkType) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + Monero::Wallet *wallet = wm->openWallet( std::string(path), std::string(password), static_cast(networkType)); return reinterpret_cast(wallet); } -void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password, const char* mnemonic, int networkType, uint64_t restoreHeight, uint64_t kdfRounds, const char* seedOffset) { +void* MONERO_WalletManager_recoveryWallet(void* wm_ptr, const char* path, const char* password, const char* mnemonic, int networkType, uint64_t restoreHeight, uint64_t kdfRounds, const char* seedOffset) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); // (const std::string &path, const std::string &password, const std::string &mnemonic, // NetworkType nettype = MAINNET, uint64_t restoreHeight = 0, uint64_t kdf_rounds = 1, // const std::string &seed_offset = {}) - Monero::Wallet *wallet = - Monero::WalletManagerFactory::getWalletManager()->recoveryWallet( + Monero::Wallet *wallet = wm->recoveryWallet( std::string(path), std::string(password), std::string(mnemonic), @@ -1437,9 +1442,9 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password // const std::string &viewKeyString, // const std::string &spendKeyString = "", // uint64_t kdf_rounds = 1) = 0; -void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds) { - Monero::Wallet *wallet = - Monero::WalletManagerFactory::getWalletManager()->createWalletFromKeys( +void* MONERO_WalletManager_createWalletFromKeys(void* wm_ptr, const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + Monero::Wallet *wallet = wm->createWalletFromKeys( std::string(path), std::string(password), std::string(language), @@ -1451,10 +1456,11 @@ void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* pa return reinterpret_cast(wallet); } -void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char* password, +void* MONERO_WalletManager_createWalletFromPolyseed(void* wm_ptr, const char* path, const char* password, int nettype, const char* mnemonic, const char* passphrase, bool newWallet, uint64_t restore_height, uint64_t kdf_rounds) { - return Monero::WalletManagerFactory::getWalletManager()->createWalletFromPolyseed(std::string(path), + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->createWalletFromPolyseed(std::string(path), std::string(password), static_cast(nettype), std::string(mnemonic), @@ -1465,84 +1471,98 @@ void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char } -bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store) { +bool MONERO_WalletManager_closeWallet(void* wm_ptr, void* wallet_ptr, bool store) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); Monero::Wallet *wallet = reinterpret_cast(wallet_ptr); - return Monero::WalletManagerFactory::getWalletManager()->closeWallet( - wallet, - store); + return wm->closeWallet(wallet, store); } -bool MONERO_WalletManager_walletExists(const char* path) { - return Monero::WalletManagerFactory::getWalletManager()->walletExists(std::string(path)); +bool MONERO_WalletManager_walletExists(void* wm_ptr, const char* path) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->walletExists(std::string(path)); } // virtual bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const = 0; -bool MONERO_WalletManager_verifyWalletPassword(const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds) { - return Monero::WalletManagerFactory::getWalletManager()->verifyWalletPassword(std::string(keys_file_name), std::string(password), no_spend_key, kdf_rounds); +bool MONERO_WalletManager_verifyWalletPassword(void* wm_ptr, const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->verifyWalletPassword(std::string(keys_file_name), std::string(password), no_spend_key, kdf_rounds); } // virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0; // bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds) { // return Monero::WalletManagerFactory::getWalletManager()->queryWalletDevice(device_type, std::string(keys_file_name), std::string(password), kdf_rounds); //} // virtual std::vector findWallets(const std::string &path) = 0; -const char* MONERO_WalletManager_findWallets(const char* path, const char* separator) { - return vectorToString(Monero::WalletManagerFactory::getWalletManager()->findWallets(std::string(path)), std::string(separator)); +const char* MONERO_WalletManager_findWallets(void* wm_ptr, const char* path, const char* separator) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return vectorToString(wm->findWallets(std::string(path)), std::string(separator)); } -const char* MONERO_WalletManager_errorString() { - std::string str = Monero::WalletManagerFactory::getWalletManager()->errorString(); +const char* MONERO_WalletManager_errorString(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + std::string str = wm->errorString(); const std::string::size_type size = str.size(); char *buffer = new char[size + 1]; //we need extra char for NUL memcpy(buffer, str.c_str(), size + 1); return buffer; } -void MONERO_WalletManager_setDaemonAddress(const char* address) { - return Monero::WalletManagerFactory::getWalletManager()->setDaemonAddress(std::string(address)); +void MONERO_WalletManager_setDaemonAddress(void* wm_ptr, const char* address) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->setDaemonAddress(std::string(address)); } -bool MONERO_WalletManager_setProxy(const char* address) { - return Monero::WalletManagerFactory::getWalletManager()->setProxy(std::string(address)); +bool MONERO_WalletManager_setProxy(void* wm_ptr, const char* address) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->setProxy(std::string(address)); } // virtual bool connected(uint32_t *version = NULL) = 0; // virtual uint64_t blockchainHeight() = 0; -uint64_t MONERO_WalletManager_blockchainHeight() { - return Monero::WalletManagerFactory::getWalletManager()->blockchainHeight(); +uint64_t MONERO_WalletManager_blockchainHeight(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->blockchainHeight(); } // virtual uint64_t blockchainTargetHeight() = 0; -uint64_t MONERO_WalletManager_blockchainTargetHeight() { - return Monero::WalletManagerFactory::getWalletManager()->blockchainTargetHeight(); +uint64_t MONERO_WalletManager_blockchainTargetHeight(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->blockchainTargetHeight(); } // virtual uint64_t networkDifficulty() = 0; -uint64_t MONERO_WalletManager_networkDifficulty() { - return Monero::WalletManagerFactory::getWalletManager()->networkDifficulty(); +uint64_t MONERO_WalletManager_networkDifficulty(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->networkDifficulty(); } // virtual double miningHashRate() = 0; -double MONERO_WalletManager_miningHashRate() { - return Monero::WalletManagerFactory::getWalletManager()->miningHashRate(); +double MONERO_WalletManager_miningHashRate(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->miningHashRate(); } // virtual uint64_t blockTarget() = 0; -uint64_t MONERO_WalletManager_blockTarget() { - return Monero::WalletManagerFactory::getWalletManager()->blockTarget(); +uint64_t MONERO_WalletManager_blockTarget(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->blockTarget(); } // virtual bool isMining() = 0; -bool MONERO_WalletManager_isMining() { - return Monero::WalletManagerFactory::getWalletManager()->isMining(); +bool MONERO_WalletManager_isMining(void* wm_ptr) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->isMining(); } // virtual bool startMining(const std::string &address, uint32_t threads = 1, bool background_mining = false, bool ignore_battery = true) = 0; -bool MONERO_WalletManager_startMining(const char* address, uint32_t threads, bool backgroundMining, bool ignoreBattery) { - return Monero::WalletManagerFactory::getWalletManager()->startMining(std::string(address), threads, backgroundMining, ignoreBattery); +bool MONERO_WalletManager_startMining(void* wm_ptr, const char* address, uint32_t threads, bool backgroundMining, bool ignoreBattery) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->startMining(std::string(address), threads, backgroundMining, ignoreBattery); } // virtual bool stopMining() = 0; -bool MONERO_WalletManager_stopMining(const char* address) { - return Monero::WalletManagerFactory::getWalletManager()->stopMining(); +bool MONERO_WalletManager_stopMining(void* wm_ptr, const char* address) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + return wm->stopMining(); } // virtual std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const = 0; -const char* MONERO_WalletManager_resolveOpenAlias(const char* address, bool dnssec_valid) { - std::string str = Monero::WalletManagerFactory::getWalletManager()->resolveOpenAlias(std::string(address), dnssec_valid); +const char* MONERO_WalletManager_resolveOpenAlias(void* wm_ptr, const char* address, bool dnssec_valid) { + Monero::WalletManager *wm = reinterpret_cast(wm_ptr); + std::string str = wm->resolveOpenAlias(std::string(address), dnssec_valid); const std::string::size_type size = str.size(); char *buffer = new char[size + 1]; //we need extra char for NUL memcpy(buffer, str.c_str(), size + 1); diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index d838608..748321e 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -806,13 +806,13 @@ uint64_t MONERO_Wallet_getBytesSent(void* wallet_ptr); // struct WalletManager // { // virtual Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype, uint64_t kdf_rounds = 1) = 0; -void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType); +void* MONERO_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType); // Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet = false) // deprecated // { // return createWallet(path, password, language, testnet ? TESTNET : MAINNET); // } // virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds = 1, WalletListener * listener = nullptr) = 0; -void* MONERO_WalletManager_openWallet(const char* path, const char* password, int networkType); +void* MONERO_WalletManager_openWallet(void* wm_ptr, const char* path, const char* password, int networkType); // Wallet * openWallet(const std::string &path, const std::string &password, bool testnet = false) // deprecated // { // return openWallet(path, password, testnet ? TESTNET : MAINNET); @@ -820,7 +820,7 @@ void* MONERO_WalletManager_openWallet(const char* path, const char* password, in // virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, // NetworkType nettype = MAINNET, uint64_t restoreHeight = 0, uint64_t kdf_rounds = 1, // const std::string &seed_offset = {}) = 0; -void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password, const char* mnemonic, int networkType, uint64_t restoreHeight, uint64_t kdfRounds, const char* seedOffset); +void* MONERO_WalletManager_recoveryWallet(void* wm_ptr, const char* path, const char* password, const char* mnemonic, int networkType, uint64_t restoreHeight, uint64_t kdfRounds, const char* seedOffset); // Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic, // bool testnet = false, uint64_t restoreHeight = 0) // deprecated // { @@ -840,7 +840,7 @@ void* MONERO_WalletManager_recoveryWallet(const char* path, const char* password // const std::string &viewKeyString, // const std::string &spendKeyString = "", // uint64_t kdf_rounds = 1) = 0; -void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds); +void* MONERO_WalletManager_createWalletFromKeys(void* wm_ptr, const char* path, const char* password, const char* language, int nettype, uint64_t restoreHeight, const char* addressString, const char* viewKeyString, const char* spendKeyString, uint64_t kdf_rounds); // Wallet * createWalletFromKeys(const std::string &path, // const std::string &password, // const std::string &language, @@ -885,49 +885,49 @@ void* MONERO_WalletManager_createWalletFromKeys(const char* path, const char* pa // bool newWallet = true, // uint64_t restore_height = 0, // uint64_t kdf_rounds = 1) = 0; -void* MONERO_WalletManager_createWalletFromPolyseed(const char* path, const char* password, +void* MONERO_WalletManager_createWalletFromPolyseed(void* wm_ptr, const char* path, const char* password, int nettype, const char* mnemonic, const char* passphrase, bool newWallet, uint64_t restore_height, uint64_t kdf_rounds); // virtual bool closeWallet(Wallet *wallet, bool store = true) = 0; -bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store); +bool MONERO_WalletManager_closeWallet(void* wm_ptr, void* wallet_ptr, bool store); // virtual bool walletExists(const std::string &path) = 0; -bool MONERO_WalletManager_walletExists(const char* path); +bool MONERO_WalletManager_walletExists(void* wm_ptr, const char* path); // virtual bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const = 0; -bool MONERO_WalletManager_verifyWalletPassword(const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds); +bool MONERO_WalletManager_verifyWalletPassword(void* wm_ptr, const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds); // virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0; // bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds); // virtual std::vector findWallets(const std::string &path) = 0; -const char* MONERO_WalletManager_findWallets(const char* path, const char* separator); +const char* MONERO_WalletManager_findWallets(void* wm_ptr, const char* path, const char* separator); // virtual std::string errorString() const = 0; -const char* MONERO_WalletManager_errorString(); +const char* MONERO_WalletManager_errorString(void* wm_ptr); // virtual void setDaemonAddress(const std::string &address) = 0; -void MONERO_WalletManager_setDaemonAddress(const char* address); +void MONERO_WalletManager_setDaemonAddress(void* wm_ptr, const char* address); // virtual bool connected(uint32_t *version = NULL) = 0; // virtual uint64_t blockchainHeight() = 0; -uint64_t MONERO_WalletManager_blockchainHeight(); +uint64_t MONERO_WalletManager_blockchainHeight(void* wm_ptr); // virtual uint64_t blockchainTargetHeight() = 0; -uint64_t MONERO_WalletManager_blockchainTargetHeight(); +uint64_t MONERO_WalletManager_blockchainTargetHeight(void* wm_ptr); // virtual uint64_t networkDifficulty() = 0; -uint64_t MONERO_WalletManager_networkDifficulty(); +uint64_t MONERO_WalletManager_networkDifficulty(void* wm_ptr); // virtual double miningHashRate() = 0; -double MONERO_WalletManager_miningHashRate(); +double MONERO_WalletManager_miningHashRate(void* wm_ptr); // virtual uint64_t blockTarget() = 0; -uint64_t MONERO_WalletManager_blockTarget(); +uint64_t MONERO_WalletManager_blockTarget(void* wm_ptr); // virtual bool isMining() = 0; -bool MONERO_WalletManager_isMining(); +bool MONERO_WalletManager_isMining(void* wm_ptr); // virtual bool startMining(const std::string &address, uint32_t threads = 1, bool background_mining = false, bool ignore_battery = true) = 0; -bool MONERO_WalletManager_startMining(const char* address, uint32_t threads, bool backgroundMining, bool ignoreBattery); +bool MONERO_WalletManager_startMining(void* wm_ptr, const char* address, uint32_t threads, bool backgroundMining, bool ignoreBattery); // virtual bool stopMining() = 0; -bool MONERO_WalletManager_stopMining(const char* address); +bool MONERO_WalletManager_stopMining(void* wm_ptr, const char* address); // virtual std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const = 0; -const char* MONERO_WalletManager_resolveOpenAlias(const char* address, bool dnssec_valid); +const char* MONERO_WalletManager_resolveOpenAlias(void* wm_ptr, const char* address, bool dnssec_valid); // static std::tuple checkUpdates( // const std::string &software, // std::string subdir, // const char *buildtag = nullptr, // const char *current_version = nullptr); // virtual bool setProxy(const std::string &address) = 0; -bool MONERO_WalletManager_setProxy(const char* address); +bool MONERO_WalletManager_setProxy(void* wm_ptr, const char* address); // }; int LogLevel_Silent = -1; -- cgit v1.2.3 From 8d2f007d9eb88bea5363957c7c2ee48dd15ff4f4 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 19 Jan 2024 16:12:34 +0100 Subject: getWalletManager --- libbridge/src/main/cpp/wallet2_api_c.cpp | 9 +++++---- libbridge/src/main/cpp/wallet2_api_c.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'libbridge/src') diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp index bcc2d97..5659bb4 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.cpp +++ b/libbridge/src/main/cpp/wallet2_api_c.cpp @@ -1395,10 +1395,6 @@ uint64_t MONERO_Wallet_getBytesSent(void* wallet_ptr) { return wallet->getBytesSent(); } -void* MONERO_WalletManagerFactory_getWalletManager() { - Monero::WalletManager *wm = Monero::WalletManagerFactory::getWalletManager(); - return reinterpret_cast(wm); -} void* MONERO_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType) { Monero::WalletManager *wm = reinterpret_cast(wm_ptr); @@ -1571,6 +1567,11 @@ const char* MONERO_WalletManager_resolveOpenAlias(void* wm_ptr, const char* addr // WalletManagerFactory +void* MONERO_WalletManagerFactory_getWalletManager() { + Monero::WalletManager *wm = Monero::WalletManagerFactory::getWalletManager(); + return reinterpret_cast(wm); +} + void MONERO_WalletManagerFactory_setLogLevel(int level) { Monero::WalletManagerFactory::setLogLevel(level); } diff --git a/libbridge/src/main/cpp/wallet2_api_c.h b/libbridge/src/main/cpp/wallet2_api_c.h index 748321e..300d3ca 100644 --- a/libbridge/src/main/cpp/wallet2_api_c.h +++ b/libbridge/src/main/cpp/wallet2_api_c.h @@ -952,6 +952,7 @@ int LogLevel_Max = 4; // LogLevel_Max = LogLevel_4 // }; // static WalletManager * getWalletManager(); +void* MONERO_WalletManagerFactory_getWalletManager(); // static void setLogLevel(int level); void MONERO_WalletManagerFactory_setLogLevel(int level); // static void setLogCategories(const std::string &categories); -- cgit v1.2.3