From fcc2924f31e6ecc1ad787ab6c704188c393318aa Mon Sep 17 00:00:00 2001 From: cyan Date: Sat, 4 Jan 2025 09:02:44 +0100 Subject: initial zano commit (#83) * initial zano commit * update checksum, fix zano patches on CI * fix monero builds * fix cmake command * fix: devcontainer on x64 ffigen: add zano zano: add missing free dart: implement zano * update boost filenames * unboost the cmakelists * fix zano boost issues * added patch into proper location * fix various build issues * [skip ci] update tor-connect * fix zano builds for ios * fix apply patches and don't fail-fast * uncomment build depends for monero * build_single.sh fix for macos native builds * disable qemu on arm64 builders from buildjet * fix boost, fix missing symbols (maybe) * fix ordering of crypto and ssl libraries * fix wownero mingw * fetch zano releases to release-bulk * build things 'the zano way' * proper cmake config * Zano.. yeah... * Update zano release to 2.0.1.367 * update zano patches * update zano builds * update zano build * fix zano build * move zlibstatic to the top (this shouldn't matter anyway) * fix patch location, update tor-connect * update ci runner * fix zano build on the CI * enable zano for other targets * nvm * don't use darwin in single release file * Increase max password length * build contrib/depends offline * zano support for macos * Update dependencies to work on multithread via rosetta2 * different way of adding .patch-applied * Improve performance of incremental builds * remove unnecessary patches * update coin-control patch * fix test * remove contrib/depends patches in wownero * chore: support fallback names in the download_deps util --------- Co-authored-by: Im-Beast --- zano_libwallet2_api_c/src/main/cpp/helpers.cpp | 1 + zano_libwallet2_api_c/src/main/cpp/helpers.hpp | 1 + .../src/main/cpp/wallet2_api_c.cpp | 322 +++++++++++++++++++++ zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.h | 67 +++++ zano_libwallet2_api_c/src/main/cpp/zano_checksum.h | 6 + 5 files changed, 397 insertions(+) create mode 120000 zano_libwallet2_api_c/src/main/cpp/helpers.cpp create mode 120000 zano_libwallet2_api_c/src/main/cpp/helpers.hpp create mode 100644 zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp create mode 100644 zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.h create mode 100644 zano_libwallet2_api_c/src/main/cpp/zano_checksum.h (limited to 'zano_libwallet2_api_c/src/main/cpp') diff --git a/zano_libwallet2_api_c/src/main/cpp/helpers.cpp b/zano_libwallet2_api_c/src/main/cpp/helpers.cpp new file mode 120000 index 0000000..524768b --- /dev/null +++ b/zano_libwallet2_api_c/src/main/cpp/helpers.cpp @@ -0,0 +1 @@ +../../../../monero_libwallet2_api_c/src/main/cpp/helpers.cpp \ No newline at end of file diff --git a/zano_libwallet2_api_c/src/main/cpp/helpers.hpp b/zano_libwallet2_api_c/src/main/cpp/helpers.hpp new file mode 120000 index 0000000..99d2733 --- /dev/null +++ b/zano_libwallet2_api_c/src/main/cpp/helpers.hpp @@ -0,0 +1 @@ +../../../../monero_libwallet2_api_c/src/main/cpp/helpers.hpp \ No newline at end of file diff --git a/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp new file mode 100644 index 0000000..11acc0a --- /dev/null +++ b/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp @@ -0,0 +1,322 @@ +#include +#include "wallet2_api_c.h" +#include +#include +#include +#include "zano_checksum.h" +#include "helpers.hpp" +#include "../../../../zano/src/wallet/plain_wallet_api.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +// namespace plain_wallet +// { +// typedef int64_t hwallet; +// std::string init(const std::string& address, const std::string& working_dir, int log_level); +const char* ZANO_PlainWallet_init(const char* address, const char* working_dir, int log_level) { + DEBUG_START() + std::string str = plain_wallet::init(std::string(address), std::string(working_dir), log_level); + 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; + DEBUG_END() +} +// std::string init(const std::string& ip, const std::string& port, const std::string& working_dir, int log_level); +const char* ZANO_PlainWallet_init2(const char* ip, const char* port, const char* working_dir, int log_level) { + DEBUG_START() + std::string str = plain_wallet::init(std::string(ip), std::string(port), std::string(working_dir), log_level); + 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; + DEBUG_END() +} +// std::string reset(); +const char* ZANO_PlainWallet_reset() { + DEBUG_START() + std::string str = plain_wallet::reset(); + 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; + DEBUG_END() +} +// std::string set_log_level(int log_level); +const char* ZANO_PlainWallet_setLogLevel(int log_level) { + DEBUG_START() + std::string str = plain_wallet::set_log_level(log_level); + 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; + DEBUG_END() +} +// std::string get_version(); +const char* ZANO_PlainWallet_getVersion() { + DEBUG_START() + std::string str = plain_wallet::get_version(); + 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; + DEBUG_END() +} +// std::string get_wallet_files(); +const char* ZANO_PlainWallet_getWalletFiles() { + DEBUG_START() + std::string str = plain_wallet::get_wallet_files(); + 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; + DEBUG_END() +} +// std::string get_export_private_info(const std::string& target_dir); +const char* ZANO_PlainWallet_getExportPrivateInfo(const char* target_dir) { + DEBUG_START() + std::string str = plain_wallet::get_export_private_info(std::string(target_dir)); + 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; + DEBUG_END() +} +// std::string delete_wallet(const std::string& file_name); +const char* ZANO_PlainWallet_deleteWallet(const char* file_name) { + DEBUG_START() + std::string str = plain_wallet::delete_wallet(std::string(file_name)); + 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; + DEBUG_END() +} +// std::string get_address_info(const std::string& addr); +const char* ZANO_PlainWallet_getAddressInfo(const char* addr) { + DEBUG_START() + std::string str = plain_wallet::get_address_info(std::string(addr)); + 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; + DEBUG_END() +} +// std::string get_appconfig(const std::string& encryption_key); +const char* ZANO_PlainWallet_getAppconfig(const char* encryption_key) { + DEBUG_START() + std::string str = plain_wallet::get_appconfig(std::string(encryption_key)); + 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; + DEBUG_END() +} +// std::string set_appconfig(const std::string& conf_str, const std::string& encryption_key); +const char* ZANO_PlainWallet_setAppconfig(const char* conf_str, const char* encryption_key) { + DEBUG_START() + std::string str = plain_wallet::set_appconfig(std::string(conf_str), std::string(encryption_key)); + 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; + DEBUG_END() +} +// std::string generate_random_key(uint64_t lenght); +const char* ZANO_PlainWallet_generateRandomKey(uint64_t lenght) { + DEBUG_START() + std::string str = plain_wallet::generate_random_key(lenght); + 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; + DEBUG_END() +} +// std::string get_logs_buffer(); +const char* ZANO_PlainWallet_getLogsBuffer() { + DEBUG_START() + std::string str = plain_wallet::get_logs_buffer(); + 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; + DEBUG_END() +} +// std::string truncate_log(); +const char* ZANO_PlainWallet_truncateLog() { + DEBUG_START() + std::string str = plain_wallet::truncate_log(); + 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; + DEBUG_END() +} +// std::string get_connectivity_status(); +const char* ZANO_PlainWallet_getConnectivityStatus() { + DEBUG_START() + std::string str = plain_wallet::get_connectivity_status(); + 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; + DEBUG_END() +} +// std::string open(const std::string& path, const std::string& password); +const char* ZANO_PlainWallet_open(const char* path, const char* password) { + DEBUG_START() + std::string str = plain_wallet::open(std::string(path), std::string(password)); + 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; + DEBUG_END() +} +// std::string restore(const std::string& seed, const std::string& path, const std::string& password, const std::string& seed_password); +const char* ZANO_PlainWallet_restore(const char* seed, const char* path, const char* password, const char* seed_password) { + DEBUG_START() + std::string str = plain_wallet::restore(std::string(seed), std::string(path), std::string(password), std::string(seed_password)); + 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; + DEBUG_END() +} +// std::string generate(const std::string& path, const std::string& password); +const char* ZANO_PlainWallet_generate(const char* path, const char* password) { + DEBUG_START() + std::string str = plain_wallet::generate(std::string(path), std::string(password)); + 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; + DEBUG_END() +} +// std::string get_opened_wallets(); +const char* ZANO_PlainWallet_getOpenWallets() { + DEBUG_START() + std::string str = plain_wallet::get_opened_wallets(); + 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; + DEBUG_END() +} + +// std::string get_wallet_status(hwallet h); +const char* ZANO_PlainWallet_getWalletStatus(int64_t h) { + DEBUG_START() + std::string str = plain_wallet::get_wallet_status(h); + 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; + DEBUG_END() +} +// std::string close_wallet(hwallet h); +const char* ZANO_PlainWallet_closeWallet(int64_t h) { + DEBUG_START() + std::string str = plain_wallet::close_wallet(h); + 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; + DEBUG_END() +} +// std::string invoke(hwallet h, const std::string& params); +const char* ZANO_PlainWallet_invoke(int64_t h, const char* params) { + DEBUG_START() + std::string str = plain_wallet::invoke(h, std::string(params)); + 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; + DEBUG_END() +} +// //async api +// std::string async_call(const std::string& method_name, uint64_t instance_id, const std::string& params); +const char* ZANO_PlainWallet_asyncCall(const char* method_name, uint64_t instance_id, const char* params) { + DEBUG_START() + std::string str = plain_wallet::async_call(std::string(method_name), instance_id, std::string(params)); + 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; + DEBUG_END() +} +// std::string try_pull_result(uint64_t); +const char* ZANO_PlainWallet_tryPullResult(uint64_t instance_id) { + DEBUG_START() + std::string str = plain_wallet::try_pull_result(instance_id); + 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; + DEBUG_END() +} +// std::string sync_call(const std::string& method_name, uint64_t instance_id, const std::string& params); +const char* ZANO_PlainWallet_syncCall(const char* method_name, uint64_t instance_id, const char* params) { + DEBUG_START() + std::string str = plain_wallet::sync_call(std::string(method_name), instance_id, std::string(params)); + 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; + DEBUG_END() +} +// //cake wallet api extension +// bool is_wallet_exist(const std::string& path); +bool ZANO_PlainWallet_isWalletExist(const char* path) { + DEBUG_START() + return plain_wallet::is_wallet_exist(std::string(path)); + DEBUG_END() +} +// std::string get_wallet_info(hwallet h); +const char* ZANO_PlainWallet_getWalletInfo(int64_t h) { + DEBUG_START() + std::string str = plain_wallet::get_wallet_info(h); + 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; + DEBUG_END() +} +// std::string reset_wallet_password(hwallet h, const std::string& password); +const char* ZANO_PlainWallet_resetWalletPassword(int64_t h, const char* password) { + DEBUG_START() + std::string str = plain_wallet::reset_wallet_password(h, std::string(password)); + 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; + DEBUG_END() +} +// uint64_t get_current_tx_fee(uint64_t priority); // 0 (default), 1 (unimportant), 2 (normal), 3 (elevated), 4 (priority) +uint64_t ZANO_PlainWallet_getCurrentTxFee(uint64_t priority) { + DEBUG_START() + return plain_wallet::get_current_tx_fee(priority); + DEBUG_END() +} +// } + +void ZANO_free(void* ptr) { + free(ptr); +} + +const char* ZANO_checksum_wallet2_api_c_h() { + return ZANO_wallet2_api_c_h_sha256; +} +const char* ZANO_checksum_wallet2_api_c_cpp() { + return ZANO_wallet2_api_c_cpp_sha256; +} +const char* ZANO_checksum_wallet2_api_c_exp() { + return ZANO_wallet2_api_c_exp_sha256; +} + +#ifdef __cplusplus +} +#endif diff --git a/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.h new file mode 100644 index 0000000..df6d3ef --- /dev/null +++ b/zano_libwallet2_api_c/src/main/cpp/wallet2_api_c.h @@ -0,0 +1,67 @@ +/* +#include + +#define LOG_TAG "[NDK]" +#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) +#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +*/ +#include +#include +#include +#include +#include "zano_checksum.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __MINGW32__ + #define ADDAPI __declspec(dllexport) +#else + #define ADDAPI __attribute__((__visibility__("default"))) +#endif + + +extern ADDAPI const char* ZANO_PlainWallet_init(const char* address, const char* working_dir, int log_level); +extern ADDAPI const char* ZANO_PlainWallet_init2(const char* ip, const char* port, const char* working_dir, int log_level); +extern ADDAPI const char* ZANO_PlainWallet_reset(); +extern ADDAPI const char* ZANO_PlainWallet_setLogLevel(int log_level); +extern ADDAPI const char* ZANO_PlainWallet_getVersion(); +extern ADDAPI const char* ZANO_PlainWallet_getWalletFiles(); +extern ADDAPI const char* ZANO_PlainWallet_getExportPrivateInfo(const char* target_dir); +extern ADDAPI const char* ZANO_PlainWallet_deleteWallet(const char* file_name); +extern ADDAPI const char* ZANO_PlainWallet_getAddressInfo(const char* addr); +extern ADDAPI const char* ZANO_PlainWallet_getAppconfig(const char* encryption_key); +extern ADDAPI const char* ZANO_PlainWallet_setAppconfig(const char* conf_str, const char* encryption_key); +extern ADDAPI const char* ZANO_PlainWallet_generateRandomKey(uint64_t lenght); +extern ADDAPI const char* ZANO_PlainWallet_getLogsBuffer(); +extern ADDAPI const char* ZANO_PlainWallet_truncateLog(); +extern ADDAPI const char* ZANO_PlainWallet_getConnectivityStatus(); +extern ADDAPI const char* ZANO_PlainWallet_open(const char* path, const char* password); +extern ADDAPI const char* ZANO_PlainWallet_restore(const char* seed, const char* path, const char* password, const char* seed_password); +extern ADDAPI const char* ZANO_PlainWallet_generate(const char* path, const char* password); +extern ADDAPI const char* ZANO_PlainWallet_getOpenWallets(); +extern ADDAPI const char* ZANO_PlainWallet_getWalletStatus(int64_t h); +extern ADDAPI const char* ZANO_PlainWallet_closeWallet(int64_t h); +extern ADDAPI const char* ZANO_PlainWallet_invoke(int64_t h, const char* params); + + +extern ADDAPI const char* ZANO_PlainWallet_asyncCall(const char* method_name, uint64_t instance_id, const char* params); +extern ADDAPI const char* ZANO_PlainWallet_tryPullResult(uint64_t instance_id); +extern ADDAPI const char* ZANO_PlainWallet_syncCall(const char* method_name, uint64_t instance_id, const char* params); +extern ADDAPI bool ZANO_PlainWallet_isWalletExist(const char* path); +extern ADDAPI const char* ZANO_PlainWallet_getWalletInfo(int64_t h); +extern ADDAPI const char* ZANO_PlainWallet_resetWalletPassword(int64_t h, const char* password); +extern ADDAPI uint64_t ZANO_PlainWallet_getCurrentTxFee(uint64_t priority); + +extern ADDAPI void ZANO_free(void* ptr); + +extern ADDAPI const char* ZANO_checksum_wallet2_api_c_h(); +extern ADDAPI const char* ZANO_checksum_wallet2_api_c_cpp(); +extern ADDAPI const char* ZANO_checksum_wallet2_api_c_exp(); + +#ifdef __cplusplus +} +#endif diff --git a/zano_libwallet2_api_c/src/main/cpp/zano_checksum.h b/zano_libwallet2_api_c/src/main/cpp/zano_checksum.h new file mode 100644 index 0000000..7f8d845 --- /dev/null +++ b/zano_libwallet2_api_c/src/main/cpp/zano_checksum.h @@ -0,0 +1,6 @@ +#ifndef MONEROC_CHECKSUMS +#define MONEROC_CHECKSUMS +const char * ZANO_wallet2_api_c_h_sha256 = "8acaa95513b85a984c08e05cc3f2ac7530bb8f32946eeeb45357bd846aef33dd"; +const char * ZANO_wallet2_api_c_cpp_sha256 = "4efacd3812d53dd268b6869cc0a9560e7320574d96e09136cf067f796edfeba6-2817090c8ac7639d6f697d00fc8bcba2b3681d90"; +const char * ZANO_wallet2_api_c_exp_sha256 = "66f3ff655bbfd11ad28c318ab707090b5a93276f436b06f7b1c0f329dba3c9c2"; +#endif -- cgit v1.2.3