WIP: UR support in monero

This commit is contained in:
Czarek Nakamoto
2024-05-16 08:09:57 +02:00
parent 89c7a09ec2
commit 1474a8c5de
4 changed files with 27 additions and 0 deletions

View File

@@ -163,6 +163,15 @@ add_library(utf8proc STATIC IMPORTED)
set_target_properties(utf8proc PROPERTIES IMPORTED_LOCATION
${MONERO_DIR}/build/${HOST_ABI}/external/utf8proc/libutf8proc.a)
#############
# bc-ur
#############
add_library(bc-ur STATIC IMPORTED)
set_target_properties(bc-ur PROPERTIES IMPORTED_LOCATION
${MONERO_DIR}/build/${HOST_ABI}/external/bc-ur/libbc-ur.a)
#############
# Monero
#############
@@ -405,6 +414,8 @@ target_link_libraries( wallet2_api_c
${EXTRA_LIBS_WOWNEROSEED}
utf8proc
bc-ur
ssl
crypto

View File

@@ -178,6 +178,7 @@ _MONERO_Wallet_errorString
_MONERO_Wallet_estimateBlockChainHeight
_MONERO_Wallet_exportKeyImages
_MONERO_Wallet_exportOutputs
_MONERO_Wallet_exportOutputsUR
_MONERO_Wallet_filename
_MONERO_Wallet_genPaymentId
_MONERO_Wallet_getBackgroundSyncType
@@ -197,6 +198,7 @@ _MONERO_Wallet_hasUnknownKeyImages
_MONERO_Wallet_history
_MONERO_Wallet_importKeyImages
_MONERO_Wallet_importOutputs
_MONERO_Wallet_importOutputsUR
_MONERO_Wallet_init
_MONERO_Wallet_init3
_MONERO_Wallet_integratedAddress

View File

@@ -1358,10 +1358,22 @@ bool MONERO_Wallet_exportOutputs(void* wallet_ptr, const char* filename, bool al
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->exportOutputs(std::string(filename), all);
}
const char* MONERO_Wallet_exportOutputsUR(void* wallet_ptr, size_t max_fragment_length, bool all) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
std::string str = wallet->exportOutputsUR(max_fragment_length, all);
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;
}
bool MONERO_Wallet_importOutputs(void* wallet_ptr, const char* filename) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->importOutputs(std::string(filename));
}
bool MONERO_Wallet_importOutputsUR(void* wallet_ptr, const char* input) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->importOutputsUR(std::string(input));
}
// virtual bool setupBackgroundSync(const BackgroundSyncType background_sync_type, const std::string &wallet_password, const optional<std::string> &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<Monero::Wallet*>(wallet_ptr);

View File

@@ -730,8 +730,10 @@ extern ADDAPI bool MONERO_Wallet_exportKeyImages(void* wallet_ptr, const char* f
extern ADDAPI bool MONERO_Wallet_importKeyImages(void* wallet_ptr, const char* filename);
// virtual bool exportOutputs(const std::string &filename, bool all = false) = 0;
extern ADDAPI bool MONERO_Wallet_exportOutputs(void* wallet_ptr, const char* filename, bool all);
extern ADDAPI const char* MONERO_Wallet_exportOutputsUR(void* wallet_ptr, size_t max_fragment_length, bool all);
// virtual bool importOutputs(const std::string &filename) = 0;
extern ADDAPI bool MONERO_Wallet_importOutputs(void* wallet_ptr, const char* filename);
extern ADDAPI bool MONERO_Wallet_importOutputsUR(void* wallet_ptr, const char* input);
// virtual bool scanTransactions(const std::vector<std::string> &txids) = 0;
// virtual bool setupBackgroundSync(const BackgroundSyncType background_sync_type, const std::string &wallet_password, const optional<std::string> &background_cache_password) = 0;
extern ADDAPI bool MONERO_Wallet_setupBackgroundSync(void* wallet_ptr, int background_sync_type, const char* wallet_password, const char* background_cache_password);