diff options
| author | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2026-03-10 08:49:35 +0100 |
|---|---|---|
| committer | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2026-03-10 08:49:35 +0100 |
| commit | b6a26390556fe14c3fc9634b291baabeba7ed517 (patch) | |
| tree | c921fdd7913183b0fbe770172db529eaecb11c91 /monero_libwallet2_api_c | |
| parent | 2c11591e02b907e63d8fd4fcb0a6559625934a95 (diff) | |
monero updates
Diffstat (limited to 'monero_libwallet2_api_c')
| -rw-r--r-- | monero_libwallet2_api_c/CMakeLists.txt | 115 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/monero_libwallet2_api_c.exp | 40 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/monero_checksum.c | 5 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/monero_checksum.h | 22 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.cpp (renamed from monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp) | 72 | ||||
| -rw-r--r-- | monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.h (renamed from monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h) | 113 |
6 files changed, 214 insertions, 153 deletions
diff --git a/monero_libwallet2_api_c/CMakeLists.txt b/monero_libwallet2_api_c/CMakeLists.txt index f11c2bc..7952dcd 100644 --- a/monero_libwallet2_api_c/CMakeLists.txt +++ b/monero_libwallet2_api_c/CMakeLists.txt @@ -1,13 +1,11 @@ cmake_minimum_required(VERSION 3.5) -project(wallet2_api_c) -message(STATUS ABI_INFO = ${HOST_ABI}) +project(${MONERO_FLAVOR}_wallet2_api_c) +message(STATUS HOST_ABI = ${HOST_ABI}) set(MD_LIBRARY "") set(CMAKE_CXX_STANDARD 11) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-lto") if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32") set(CMAKE_SYSTEM_NAME Windows) @@ -21,92 +19,60 @@ elseif(${HOST_ABI} STREQUAL "i686-w64-mingw32") set(TARGET "i686-w64-mingw32") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lssp") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lssp") -elseif(${HOST_ABI} STREQUAL "host-apple-ios" OR - ${HOST_ABI} STREQUAL "aarch64-apple-ios") +elseif(${HOST_ABI} MATCHES "-apple-ios") set(CMAKE_SYSTEM_NAME iOS) -elseif(${HOST_ABI} STREQUAL "host-apple-darwin" OR - ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR - ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin") +elseif(${HOST_ABI} MATCHES "-apple-darwin") set(CMAKE_SYSTEM_NAME Darwin) endif() -if (${HOST_ABI} STREQUAL "host-apple-darwin" OR - ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR - ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin") +if (${HOST_ABI} MATCHES "-apple-darwin") EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE ) if (NOT ${ARCHITECTURE} STREQUAL arm64) set(CMAKE_OSX_ARCHITECTURES x86_64) endif() endif() -if(${HOST_ABI} STREQUAL "x86_64-linux-android" OR - ${HOST_ABI} STREQUAL "i686-linux-android" OR - ${HOST_ABI} STREQUAL "aarch64-linux-android" OR - ${HOST_ABI} STREQUAL "armv7a-linux-androideabi") +if(${HOST_ABI} MATCHES "-linux-android") add_link_options(-stdlib=libc++ -static-libstdc++) set(EXTRA_LIBS_ANDROID log) endif() -add_library( wallet2_api_c - SHARED + +add_library( ${MONERO_FLAVOR}_wallet2_api_c + ${OUTPUT_MODE} src/main/cpp/helpers.cpp - src/main/cpp/wallet2_api_c.cpp ) + src/main/cpp/${MONERO_FLAVOR}_wallet2_api_c.cpp + src/main/cpp/${MONERO_FLAVOR}_checksum.c) -if(${HOST_ABI} STREQUAL "x86_64-linux-android" OR - ${HOST_ABI} STREQUAL "i686-linux-android" OR - ${HOST_ABI} STREQUAL "aarch64-linux-android" OR - ${HOST_ABI} STREQUAL "armv7a-linux-androideabi") - set_target_properties(wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,-z,noexecstack") +if(${HOST_ABI} MATCHES "-linux-android") + set_target_properties(${MONERO_FLAVOR}_wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,-z,noexecstack") endif() -if(${HOST_ABI} STREQUAL "x86_64-linux-gnu" OR - ${HOST_ABI} STREQUAL "i686-linux-gnu" OR - ${HOST_ABI} STREQUAL "aarch64-linux-gnu" OR - ${HOST_ABI} STREQUAL "armv7a-linux-gnu") - set_target_properties(wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,-z,noexecstack") +if(${HOST_ABI} MATCHES "-linux-gnu") + set_target_properties(${MONERO_FLAVOR}_wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,-z,noexecstack") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - - set(MONERO_DIR ${CMAKE_SOURCE_DIR}/../${MONERO_FLAVOR}) set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../contrib/depends/${HOST_ABI}) -if (${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11") - set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" "-framework Cocoa" hidapi) -# set_target_properties(wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,-F/Library/Frameworks") -elseif(${HOST_ABI} STREQUAL "host-apple-darwin" OR - ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR - ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin") - set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" "-framework Cocoa" apple_nghttp2) -elseif(${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-ios-simulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-ios-simulator") - set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" iconv ) -endif() - if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR ${HOST_ABI} STREQUAL "i686-w64-mingw32") - target_link_options(wallet2_api_c PRIVATE -static-libgcc -static-libstdc++) -endif() - -if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "arm64-apple-iossimulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-iossimulator") - set_target_properties(wallet2_api_c PROPERTIES SUFFIX ".dylib") - - set_target_properties(wallet2_api_c PROPERTIES NO_SONAME 1) + target_link_options(${MONERO_FLAVOR}_wallet2_api_c PRIVATE -static-libgcc -static-libstdc++) endif() if (${MONERO_FLAVOR} STREQUAL "monero") - target_compile_definitions(wallet2_api_c PRIVATE FLAVOR_MONERO) + target_compile_definitions(${MONERO_FLAVOR}_wallet2_api_c PRIVATE FLAVOR_MONERO) set(BCUR_ENABLED bc-ur) elseif(${MONERO_FLAVOR} STREQUAL "wownero") - target_compile_definitions(wallet2_api_c PRIVATE FLAVOR_WOWNERO) + target_compile_definitions(${MONERO_FLAVOR}_wallet2_api_c PRIVATE FLAVOR_WOWNERO) elseif(${MONERO_FLAVOR} STREQUAL "zano") - target_compile_definitions(wallet2_api_c PRIVATE FLAVOR_ZANO) + target_compile_definitions(${MONERO_FLAVOR}_wallet2_api_c PRIVATE FLAVOR_ZANO) endif() -if(NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" AND NOT ${HOST_ABI} STREQUAL "host-apple-ios" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-ios" AND NOT ${HOST_ABI} STREQUAL "aarch64-apple-ios-simulator" AND NOT ${HOST_ABI} STREQUAL "x86_64-apple-ios-simulator") - set_target_properties(wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") +if(NOT HOST_ABI MATCHES "-apple-") + set_target_properties(${MONERO_FLAVOR}_wallet2_api_c PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL") endif() if (${MONERO_FLAVOR} STREQUAL "zano") @@ -116,26 +82,19 @@ if (${MONERO_FLAVOR} STREQUAL "zano") endif() add_subdirectory("${CMAKE_SOURCE_DIR}/../${MONERO_FLAVOR}" ${CMAKE_BINARY_DIR}/${MONERO_FLAVOR}_build EXCLUDE_FROM_ALL) -if(${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11" OR ${HOST_ABI} STREQUAL "x86_64-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-darwin" OR ${HOST_ABI} STREQUAL "x86_64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "aarch64-host-apple-darwin" OR ${HOST_ABI} STREQUAL "host-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-ios" OR ${HOST_ABI} STREQUAL "aarch64-apple-iossimulator" OR ${HOST_ABI} STREQUAL "x86_64-apple-ios-simulator") - if (${MONERO_FLAVOR} STREQUAL "monero") - set(EXPORTED_SYMBOLS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/monero_libwallet2_api_c.exp) - elseif(${MONERO_FLAVOR} STREQUAL "wownero") - set(EXPORTED_SYMBOLS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/wownero_libwallet2_api_c.exp) - elseif(${MONERO_FLAVOR} STREQUAL "zano") - set(EXPORTED_SYMBOLS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zano_libwallet2_api_c.exp) - endif() + +if(HOST_ABI MATCHES "-apple-") + set(EXPORTED_SYMBOLS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${MONERO_FLAVOR}_libwallet2_api_c.exp) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -exported_symbols_list ${EXPORTED_SYMBOLS_FILE}") set_target_properties(${TARGET} PROPERTIES LINK_DEPENDS ${EXPORTED_SYMBOLS_FILE}) endif() -if (${MONERO_FLAVOR} STREQUAL "monero") - set(WALLET_TARGETS wallet_api ${wallet_api_LIB_DEPENDS}) # wallet_api_LIB_DEPENDS -elseif(${MONERO_FLAVOR} STREQUAL "wownero") - set(WALLET_TARGETS wallet_api ${wallet_api_LIB_DEPENDS}) # wallet_api_LIB_DEPENDS +if (${MONERO_FLAVOR} STREQUAL "monero" OR ${MONERO_FLAVOR} STREQUAL "wownero") + set(WALLET_TARGETS wallet_api ${wallet_api_LIB_DEPENDS}) elseif(${MONERO_FLAVOR} STREQUAL "zano") set(THREADS_PREFER_PTHREAD_FLAG ON) - + set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(CMAKE_USE_PTHREADS_INIT 1) @@ -160,22 +119,10 @@ if(${MONERO_FLAVOR} STREQUAL "wownero") set(EXTRA_LIBS_WOWNEROSEED wownero-seed) endif() -#get_cmake_property(_variableNames VARIABLES) -#list (SORT _variableNames) -#foreach (_variableName ${_variableNames}) -# message(STATUS "${_variableName}=${${_variableName}}") -#endforeach() -#message(SEND_ERROR "${Boost_LIBRARIES}") -#message(SEND_ERROR "${WALLET_TARGETS} -# ${EXTRA_LIBS_WOWNEROSEED} -# ${EXTRA_LIBS_ANDROID}") - - -if (${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR - ${HOST_ABI} STREQUAL "i686-w64-mingw32") - target_link_options(wallet2_api_c PRIVATE "-Wl,--section-alignment,16384") +if (${HOST_ABI} MATCHES "-w64-mingw32") + target_link_options(${MONERO_FLAVOR}_wallet2_api_c PRIVATE "-Wl,--section-alignment,16384") elseif(${HOST_ABI} MATCHES "-linux-") - target_link_options(wallet2_api_c PRIVATE "-Wl,-z,max-page-size=16384") + target_link_options(${MONERO_FLAVOR}_wallet2_api_c PRIVATE "-Wl,-z,max-page-size=16384") endif() if(${HOST_ABI} MATCHES "-apple-") @@ -193,7 +140,7 @@ if(${HOST_ABI} MATCHES "-apple-") ) endif() -target_link_libraries( wallet2_api_c +target_link_libraries( ${MONERO_FLAVOR}_wallet2_api_c ${WALLET_TARGETS} ${EXTRA_LIBS_WOWNEROSEED} diff --git a/monero_libwallet2_api_c/monero_libwallet2_api_c.exp b/monero_libwallet2_api_c/monero_libwallet2_api_c.exp index 1aa2f26..0c59e1a 100644 --- a/monero_libwallet2_api_c/monero_libwallet2_api_c.exp +++ b/monero_libwallet2_api_c/monero_libwallet2_api_c.exp @@ -308,3 +308,43 @@ _MONERO_free _MONERO_checksum_wallet2_api_c_h _MONERO_checksum_wallet2_api_c_cpp _MONERO_checksum_wallet2_api_c_exp +_MONERO_NetworkType_MAINNET +_MONERO_NetworkType_TESTNET +_MONERO_NetworkType_STAGENET +_MONERO_PendingTransactionStatus_Ok +_MONERO_PendingTransactionStatus_Error +_MONERO_PendingTransactionStatus_Critical +_MONERO_Priority_Default +_MONERO_Priority_Low +_MONERO_Priority_Medium +_MONERO_Priority_High +_MONERO_Priority_Last +_MONERO_WalletDevice_Software +_MONERO_WalletDevice_Ledger +_MONERO_WalletDevice_Trezor +_MONERO_WalletStatus_Ok +_MONERO_WalletStatus_Error +_MONERO_WalletStatus_Critical +_MONERO_WalletConnectionStatus_Disconnected +_MONERO_WalletConnectionStatus_Connected +_MONERO_WalletConnectionStatus_WrongVersion +_MONERO_WalletBackgroundSync_Off +_MONERO_WalletBackgroundSync_ReusePassword +_MONERO_WalletBackgroundSync_CustomPassword +_MONERO_LogLevel_Silent +_MONERO_LogLevel_0 +_MONERO_LogLevel_1 +_MONERO_LogLevel_2 +_MONERO_LogLevel_3 +_MONERO_LogLevel_4 +_MONERO_LogLevel_Min +_MONERO_LogLevel_Max +_MONERO_UnsignedTransactionStatus_Ok +_MONERO_UnsignedTransactionStatus_Error +_MONERO_UnsignedTransactionStatus_Critical +_MONERO_TransactionInfoDirection_In +_MONERO_TransactionInfoDirection_Out +_MONERO_AddressBookErrorCodeStatus_Ok +_MONERO_AddressBookErrorCodeGeneral_Error +_MONERO_AddressBookErrorCodeInvalid_Address +_MONERO_AddressBookErrorCodeInvalidPaymentId diff --git a/monero_libwallet2_api_c/src/main/cpp/monero_checksum.c b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.c new file mode 100644 index 0000000..36a251b --- /dev/null +++ b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.c @@ -0,0 +1,5 @@ +#include "monero_checksum.h" + +const char * MONERO_wallet2_api_c_h_sha256 = "e7117f437964c7bd7dc90ced932432b4571113bd1e981238c689e297ec02a9e5"; +const char * MONERO_wallet2_api_c_cpp_sha256 = "8329ea5c29578a48cf8a15ebe4de693bc412b7b6fdc053290f8c4719ffad54d0-dbcc7d212c094bd1a45f7291dbb99a4b4627a96d"; +const char * MONERO_wallet2_api_c_exp_sha256 = "135c0e3c7088e43cfbbff00fc814addb8929a1116324a618c7276bd789b78563"; diff --git a/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h index 55acabb..2636eb1 100644 --- a/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h +++ b/monero_libwallet2_api_c/src/main/cpp/monero_checksum.h @@ -1,6 +1,22 @@ #ifndef MONEROC_CHECKSUMS #define MONEROC_CHECKSUMS -const char * MONERO_wallet2_api_c_h_sha256 = "3515e4c9e537ca3efa664f0b364a3aeb106ff64337f542a262ce104c00b31235"; -const char * MONERO_wallet2_api_c_cpp_sha256 = "ca44a8d4a201ba6dc0a25c857e95d07bc8d514039b38cd5b3826100e8943cbcc-dbcc7d212c094bd1a45f7291dbb99a4b4627a96d"; -const char * MONERO_wallet2_api_c_exp_sha256 = "0561e14606106e6b0ec49fb2aefe743ff500f7c3de07557f7041e06aef9509ce"; +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __MINGW32__ + #define ADDAPI __declspec(dllexport) +#else + #define ADDAPI __attribute__((__visibility__("default"))) +#endif + +extern ADDAPI const char * MONERO_wallet2_api_c_h_sha256; +extern ADDAPI const char * MONERO_wallet2_api_c_cpp_sha256; +extern ADDAPI const char * MONERO_wallet2_api_c_exp_sha256; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.cpp index c58fbec..ef48447 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp +++ b/monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.cpp @@ -1,5 +1,5 @@ #include <inttypes.h> -#include "wallet2_api_c.h" +#include "monero_wallet2_api_c.h" #include <unistd.h> #include "helpers.hpp" #include <cstring> @@ -37,7 +37,7 @@ extern "C" // Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr); <------------ We are converting the void* into Monero::Wallet* // Monero::optional<uint64_t> optAmount; <------------- optional by default // if (amount != 0) {------------------\ We set this optional parameter only when it isn't zero -// optAmount = amount; | +// optAmount = amount; | // }___________________________________/ // std::set<uint32_t> subaddr_indices = {}; ------------- Default value // std::set<std::string> preferred_inputs = splitString(std::string(preferredInputs), std::string(separator)); <------------- We are using helpers.cpp function to split a string into std::set @@ -60,8 +60,21 @@ extern "C" // // +const int MONERO_NetworkType_MAINNET = 0; +const int MONERO_NetworkType_TESTNET = 1; +const int MONERO_NetworkType_STAGENET = 2; + // PendingTransaction +const int MONERO_PendingTransactionStatus_Ok = 0; +const int MONERO_PendingTransactionStatus_Error = 1; +const int MONERO_PendingTransactionStatus_Critical = 2; +const int MONERO_Priority_Default = 0; +const int MONERO_Priority_Low = 1; +const int MONERO_Priority_Medium = 2; +const int MONERO_Priority_High = 3; +const int MONERO_Priority_Last = 4; + int MONERO_PendingTransaction_status(void* pendingTx_ptr) { DEBUG_START() Monero::PendingTransaction *pendingTx = reinterpret_cast<Monero::PendingTransaction*>(pendingTx_ptr); @@ -181,6 +194,10 @@ const char* MONERO_PendingTransaction_txKey(void* pendingTx_ptr, const char* sep // UnsignedTransaction +const int MONERO_UnsignedTransactionStatus_Ok = 0; +const int MONERO_UnsignedTransactionStatus_Error = 1; +const int MONERO_UnsignedTransactionStatus_Critical = 2; + int MONERO_UnsignedTransaction_status(void* unsignedTx_ptr) { DEBUG_START() Monero::UnsignedTransaction *unsignedTx = reinterpret_cast<Monero::UnsignedTransaction*>(unsignedTx_ptr); @@ -266,6 +283,9 @@ const char* MONERO_UnsignedTransaction_signUR(void* unsignedTx_ptr, int max_frag DEBUG_END() } // TransactionInfo + +const int MONERO_TransactionInfoDirection_In = 0; +const int MONERO_TransactionInfoDirection_Out = 1; int MONERO_TransactionInfo_direction(void* txInfo_ptr) { DEBUG_START() Monero::TransactionInfo *txInfo = reinterpret_cast<Monero::TransactionInfo*>(txInfo_ptr); @@ -454,7 +474,7 @@ const char* MONERO_AddressBookRow_extra(void* addressBookRow_ptr) { return buffer; DEBUG_END() } -// std::string getAddress() const {return m_address;} +// std::string getAddress() const {return m_address;} const char* MONERO_AddressBookRow_getAddress(void* addressBookRow_ptr) { DEBUG_START() Monero::AddressBookRow *addressBookRow = reinterpret_cast<Monero::AddressBookRow*>(addressBookRow_ptr); @@ -465,7 +485,7 @@ const char* MONERO_AddressBookRow_getAddress(void* addressBookRow_ptr) { return buffer; DEBUG_END() } -// std::string getDescription() const {return m_description;} +// std::string getDescription() const {return m_description;} const char* MONERO_AddressBookRow_getDescription(void* addressBookRow_ptr) { DEBUG_START() Monero::AddressBookRow *addressBookRow = reinterpret_cast<Monero::AddressBookRow*>(addressBookRow_ptr); @@ -476,7 +496,7 @@ const char* MONERO_AddressBookRow_getDescription(void* addressBookRow_ptr) { return buffer; DEBUG_END() } -// std::string getPaymentId() const {return m_paymentId;} +// std::string getPaymentId() const {return m_paymentId;} const char* MONERO_AddressBookRow_getPaymentId(void* addressBookRow_ptr) { DEBUG_START() Monero::AddressBookRow *addressBookRow = reinterpret_cast<Monero::AddressBookRow*>(addressBookRow_ptr); @@ -496,6 +516,12 @@ size_t MONERO_AddressBookRow_getRowId(void* addressBookRow_ptr) { } // AddressBook + +const int MONERO_AddressBookErrorCodeStatus_Ok = 0; +const int MONERO_AddressBookErrorCodeGeneral_Error = 1; +const int MONERO_AddressBookErrorCodeInvalid_Address = 2; +const int MONERO_AddressBookErrorCodeInvalidPaymentId = 3; + // virtual std::vector<AddressBookRow*> getAll() const = 0; int MONERO_AddressBook_getAll_size(void* addressBook_ptr) { DEBUG_START() @@ -509,7 +535,7 @@ void* MONERO_AddressBook_getAll_byIndex(void* addressBook_ptr, int index) { return addressBook->getAll()[index]; DEBUG_END() } -// virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0; +// virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0; bool MONERO_AddressBook_addRow(void* addressBook_ptr, const char* dst_addr , const char* payment_id, const char* description) { DEBUG_START() Monero::AddressBook *addressBook = reinterpret_cast<Monero::AddressBook*>(addressBook_ptr); @@ -530,7 +556,7 @@ bool MONERO_AddressBook_setDescription(void* addressBook_ptr, size_t rowId, cons return addressBook->setDescription(rowId, std::string(description)); DEBUG_END() } -// virtual void refresh() = 0; +// virtual void refresh() = 0; void MONERO_AddressBook_refresh(void* addressBook_ptr) { DEBUG_START() Monero::AddressBook *addressBook = reinterpret_cast<Monero::AddressBook*>(addressBook_ptr); @@ -1049,6 +1075,19 @@ bool MONERO_DeviceProgress_indeterminate(void* deviceProgress_ptr) { DEBUG_END() } +const int MONERO_WalletDevice_Software = 0; +const int MONERO_WalletDevice_Ledger = 1; +const int MONERO_WalletDevice_Trezor = 2; +const int MONERO_WalletStatus_Ok = 0; +const int MONERO_WalletStatus_Error = 1; +const int MONERO_WalletStatus_Critical = 2; +const int MONERO_WalletConnectionStatus_Disconnected = 0; +const int MONERO_WalletConnectionStatus_Connected = 1; +const int MONERO_WalletConnectionStatus_WrongVersion = 2; +const int MONERO_WalletBackgroundSync_Off = 0; +const int MONERO_WalletBackgroundSync_ReusePassword = 1; +const int MONERO_WalletBackgroundSync_CustomPassword = 2; + // Wallet const char* MONERO_Wallet_seed(void* wallet_ptr, const char* seed_offset) { @@ -1341,6 +1380,15 @@ bool MONERO_Wallet_setProxy(void* wallet_ptr, const char* address) { DEBUG_END() } +const int MONERO_LogLevel_Silent = -1; +const int MONERO_LogLevel_0 = 0; +const int MONERO_LogLevel_1 = 1; +const int MONERO_LogLevel_2 = 2; +const int MONERO_LogLevel_3 = 3; +const int MONERO_LogLevel_4 = 4; +const int MONERO_LogLevel_Min = MONERO_LogLevel_Silent; +const int MONERO_LogLevel_Max = MONERO_LogLevel_4; + uint64_t MONERO_Wallet_balance(void* wallet_ptr, uint32_t accountIndex) { DEBUG_START() Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr); @@ -1515,8 +1563,6 @@ const char* MONERO_Wallet_createPolyseed(const char* language) { std::string seed_words = ""; std::string err; Monero::Wallet::createPolyseed(seed_words, err, std::string(language)); - std::cout << "MONERO_Wallet_createPolyseed(language: " << language << "):" << std::endl; - std::cout << " err: " << err << std::endl; 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 @@ -1659,7 +1705,7 @@ const char* MONERO_Wallet_exchangeMultisigKeys(void* wallet_ptr, const char* inf const char* MONERO_Wallet_exportMultisigImages(void* wallet_ptr, const char* separator) { DEBUG_START() Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr); - std::string str; + std::string str; wallet->exportMultisigImages(str); const std::string::size_type size = str.size(); char *buffer = new char[size + 1]; //we need extra char for NUL @@ -2449,7 +2495,7 @@ void MONERO_WalletManagerFactory_setLogCategories(const char* categories) { // 2) int // 3) uint64_t // 4) void* -// 5) const char* +// 5) const char* void MONERO_DEBUG_test0() { return; @@ -2473,13 +2519,13 @@ void* MONERO_DEBUG_test4(uint64_t x) { } const char* MONERO_DEBUG_test5() { - const char *text = "This is a const char* text"; + const char *text = "This is a const char* text"; return text; } const char* MONERO_DEBUG_test5_std() { std::string text("This is a std::string text"); - const char *text2 = "This is a text"; + const char *text2 = "This is a text"; return text2; } diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.h index ff28d68..39bca89 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h +++ b/monero_libwallet2_api_c/src/main/cpp/monero_wallet2_api_c.h @@ -6,6 +6,11 @@ #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ + +#ifndef MONERO_LIBWALLET2_API_C_H +#define MONERO_LIBWALLET2_API_C_H + + #include <stdint.h> #include <stdbool.h> #include <stddef.h> @@ -26,11 +31,11 @@ extern "C" // namespace Monero { // enum NetworkType : uint8_t { // MAINNET = 0, -const int NetworkType_MAINNET = 0; +extern ADDAPI const int MONERO_NetworkType_MAINNET; // TESTNET, -const int NetworkType_TESTNET = 1; +extern ADDAPI const int MONERO_NetworkType_TESTNET; // STAGENET -const int NetworkType_STAGENET = 2; +extern ADDAPI const int MONERO_NetworkType_STAGENET; // }; // namespace Utils { // bool isAddressLocal(const std::string &hostaddr); @@ -53,23 +58,23 @@ const int NetworkType_STAGENET = 2; // { // enum Status { // Status_Ok, -const int PendingTransactionStatus_Ok = 0; +extern ADDAPI const int MONERO_PendingTransactionStatus_Ok; // Status_Error, -const int PendingTransactionStatus_Error = 1; +extern ADDAPI const int MONERO_PendingTransactionStatus_Error; // Status_Critical -const int PendingTransactionStatus_Critical = 2; +extern ADDAPI const int MONERO_PendingTransactionStatus_Critical; // }; // enum Priority { // Priority_Default = 0, -const int Priority_Default = 0; +extern ADDAPI const int MONERO_Priority_Default; // Priority_Low = 1, -const int Priority_Low = 1; +extern ADDAPI const int MONERO_Priority_Low; // Priority_Medium = 2, -const int Priority_Medium = 2; +extern ADDAPI const int MONERO_Priority_Medium; // Priority_High = 3, -const int Priority_High = 3; +extern ADDAPI const int MONERO_Priority_High; // Priority_Last -const int Priority_Last = 4; +extern ADDAPI const int MONERO_Priority_Last; // }; // virtual ~PendingTransaction() = 0; // virtual int status() const = 0; @@ -109,11 +114,11 @@ extern ADDAPI const char* MONERO_PendingTransaction_hex(void* pendingTx_ptr, con // { // enum Status { // Status_Ok, -const int UnsignedTransactionStatus_Ok = 0; +extern ADDAPI const int MONERO_UnsignedTransactionStatus_Ok; // Status_Error, -const int UnsignedTransactionStatus_Error = 1; +extern ADDAPI const int MONERO_UnsignedTransactionStatus_Error; // Status_Critical -const int UnsignedTransactionStatus_Critical = 2; +extern ADDAPI const int MONERO_UnsignedTransactionStatus_Critical; // }; // virtual ~UnsignedTransaction() = 0; // virtual int status() const = 0; @@ -144,9 +149,9 @@ extern ADDAPI const char* MONERO_UnsignedTransaction_signUR(void* unsignedTx_ptr // { // enum Direction { // Direction_In, -const int TransactionInfoDirection_In = 0; +extern ADDAPI const int MONERO_TransactionInfoDirection_In; // Direction_Out -const int TransactionInfoDirection_Out = 1; +extern ADDAPI const int MONERO_TransactionInfoDirection_Out; // }; // struct Transfer { // Transfer(uint64_t _amount, const std::string &address); @@ -211,9 +216,9 @@ extern ADDAPI void MONERO_TransactionHistory_setTxNote(void* txHistory_ptr, cons // AddressBookRow(std::size_t _rowId, const std::string &_address, const std::string &_paymentId, const std::string &_description): // m_rowId(_rowId), // m_address(_address), -// m_paymentId(_paymentId), +// m_paymentId(_paymentId), // m_description(_description) {} - + // private: // std::size_t m_rowId; // std::string m_address; @@ -222,11 +227,11 @@ extern ADDAPI void MONERO_TransactionHistory_setTxNote(void* txHistory_ptr, cons // public: // std::string extra; extern ADDAPI const char* MONERO_AddressBookRow_extra(void* addressBookRow_ptr); -// std::string getAddress() const {return m_address;} +// std::string getAddress() const {return m_address;} extern ADDAPI const char* MONERO_AddressBookRow_getAddress(void* addressBookRow_ptr); -// std::string getDescription() const {return m_description;} +// std::string getDescription() const {return m_description;} extern ADDAPI const char* MONERO_AddressBookRow_getDescription(void* addressBookRow_ptr); -// std::string getPaymentId() const {return m_paymentId;} +// std::string getPaymentId() const {return m_paymentId;} extern ADDAPI const char* MONERO_AddressBookRow_getPaymentId(void* addressBookRow_ptr); // std::size_t getRowId() const {return m_rowId;} extern ADDAPI size_t MONERO_AddressBookRow_getRowId(void* addressBookRow_ptr); @@ -235,25 +240,25 @@ extern ADDAPI size_t MONERO_AddressBookRow_getRowId(void* addressBookRow_ptr); // { // enum ErrorCode { // Status_Ok, -const int AddressBookErrorCodeStatus_Ok = 0; +extern ADDAPI const int MONERO_AddressBookErrorCodeStatus_Ok; // General_Error, -const int AddressBookErrorCodeGeneral_Error = 1; +extern ADDAPI const int MONERO_AddressBookErrorCodeGeneral_Error; // Invalid_Address, -const int AddressBookErrorCodeInvalid_Address = 2; +extern ADDAPI const int MONERO_AddressBookErrorCodeInvalid_Address; // Invalid_Payment_Id -const int AddressBookErrorCodeInvalidPaymentId = 3; +extern ADDAPI const int MONERO_AddressBookErrorCodeInvalidPaymentId; // }; // virtual ~AddressBook() = 0; // virtual std::vector<AddressBookRow*> getAll() const = 0; extern ADDAPI int MONERO_AddressBook_getAll_size(void* addressBook_ptr); extern ADDAPI void* MONERO_AddressBook_getAll_byIndex(void* addressBook_ptr, int index); -// virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0; +// virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0; extern ADDAPI bool MONERO_AddressBook_addRow(void* addressBook_ptr, const char* dst_addr , const char* payment_id, const char* description); // virtual bool deleteRow(std::size_t rowId) = 0; extern ADDAPI bool MONERO_AddressBook_deleteRow(void* addressBook_ptr, size_t rowId); // virtual bool setDescription(std::size_t index, const std::string &description) = 0; extern ADDAPI bool MONERO_AddressBook_setDescription(void* addressBook_ptr, size_t rowId, const char* description); -// virtual void refresh() = 0; +// virtual void refresh() = 0; extern ADDAPI void MONERO_AddressBook_refresh(void* addressBook_ptr); // virtual std::string errorString() const = 0; extern ADDAPI const char* MONERO_AddressBook_errorString(void* addressBook_ptr); @@ -339,7 +344,7 @@ extern ADDAPI void MONERO_Coins_setDescription(void* coins_ptr, const char* publ // m_rowId(_rowId), // m_address(_address), // m_label(_label) {} - + // private: // std::size_t m_rowId; // std::string m_address; @@ -467,35 +472,35 @@ extern ADDAPI bool MONERO_DeviceProgress_indeterminate(void* deviceProgress_ptr) // { // enum Device { // Device_Software = 0, -const int WalletDevice_Software = 0; +extern ADDAPI const int MONERO_WalletDevice_Software; // Device_Ledger = 1, -const int WalletDevice_Ledger = 1; +extern ADDAPI const int MONERO_WalletDevice_Ledger; // Device_Trezor = 2 -const int WalletDevice_Trezor = 2; +extern ADDAPI const int MONERO_WalletDevice_Trezor; // }; // enum Status { // Status_Ok, -const int WalletStatus_Ok = 0; +extern ADDAPI const int MONERO_WalletStatus_Ok; // Status_Error, -const int WalletStatus_Error = 1; +extern ADDAPI const int MONERO_WalletStatus_Error; // Status_Critical -const int WalletStatus_Critical = 2; +extern ADDAPI const int MONERO_WalletStatus_Critical; // }; // enum ConnectionStatus { // ConnectionStatus_Disconnected, -const int WalletConnectionStatus_Disconnected = 0; +extern ADDAPI const int MONERO_WalletConnectionStatus_Disconnected; // ConnectionStatus_Connected, -const int WalletConnectionStatus_Connected = 1; +extern ADDAPI const int MONERO_WalletConnectionStatus_Connected; // ConnectionStatus_WrongVersion -const int WalletConnectionStatus_WrongVersion = 2; +extern ADDAPI const int MONERO_WalletConnectionStatus_WrongVersion; // }; // enum BackgroundSyncType { // BackgroundSync_Off = 0, -const int WalletBackgroundSync_Off = 0; +extern ADDAPI const int MONERO_WalletBackgroundSync_Off; // BackgroundSync_ReusePassword = 1, -const int WalletBackgroundSync_ReusePassword = 1; +extern ADDAPI const int MONERO_WalletBackgroundSync_ReusePassword; // BackgroundSync_CustomPassword = 2 -const int BackgroundSync_CustomPassword = 2; +extern ADDAPI const int MONERO_WalletBackgroundSync_CustomPassword; // }; // virtual ~Wallet() = 0; // virtual std::string seed(const std::string& seed_offset = "") const = 0; @@ -528,7 +533,7 @@ extern ADDAPI int MONERO_Wallet_nettype(void* wallet_ptr); // bool testnet() const { return nettype() == TESTNET; } // bool stagenet() const { return nettype() == STAGENET; } // virtual void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const = 0; -// virtual bool useForkRules(uint8_t version, int64_t early_blocks) const = 0; +// virtual bool useForkRules(uint8_t version, int64_t early_blocks) const = 0; extern ADDAPI uint8_t MONERO_Wallet_useForkRules(void* wallet_ptr, uint8_t version, int64_t early_blocks); // virtual std::string integratedAddress(const std::string &payment_id) const = 0; extern ADDAPI const char* MONERO_Wallet_integratedAddress(void* wallet_ptr, const char* payment_id); @@ -894,16 +899,16 @@ extern ADDAPI void* MONERO_WalletManager_createWalletFromKeys(void* wm_ptr, cons // { // return createWalletFromKeys(path, password, language, testnet ? TESTNET : MAINNET, restoreHeight, addressString, viewKeyString, spendKeyString); // } -// virtual Wallet * createWalletFromKeys(const std::string &path, +// virtual Wallet * createWalletFromKeys(const std::string &path, // const std::string &language, -// NetworkType nettype, +// NetworkType nettype, // uint64_t restoreHeight, // const std::string &addressString, // const std::string &viewKeyString, // const std::string &spendKeyString = "") = 0; -// Wallet * createWalletFromKeys(const std::string &path, +// Wallet * createWalletFromKeys(const std::string &path, // const std::string &language, -// bool testnet, +// bool testnet, // uint64_t restoreHeight, // const std::string &addressString, // const std::string &viewKeyString, @@ -983,14 +988,14 @@ extern ADDAPI const char* MONERO_WalletManager_resolveOpenAlias(void* wm_ptr, co extern ADDAPI bool MONERO_WalletManager_setProxy(void* wm_ptr, const char* address); // }; -int LogLevel_Silent = -1; -int LogLevel_0 = 0; -int LogLevel_1 = 1; -int LogLevel_2 = 2; -int LogLevel_3 = 3; -int LogLevel_4 = 4; -int LogLevel_Min = -1; -int LogLevel_Max = 4; +extern ADDAPI const int MONERO_LogLevel_Silent; +extern ADDAPI const int MONERO_LogLevel_0; +extern ADDAPI const int MONERO_LogLevel_1; +extern ADDAPI const int MONERO_LogLevel_2; +extern ADDAPI const int MONERO_LogLevel_3; +extern ADDAPI const int MONERO_LogLevel_4; +extern ADDAPI const int MONERO_LogLevel_Min; +extern ADDAPI const int MONERO_LogLevel_Max; // struct WalletManagerFactory // { @@ -1040,3 +1045,5 @@ extern ADDAPI const char* MONERO_checksum_wallet2_api_c_exp(); #ifdef __cplusplus } #endif + +#endif // MONERO_LIBWALLET2_API_C_H |
