summaryrefslogtreecommitdiff
path: root/libbridge/src/main/cpp/wallet2_api_c.cpp
diff options
context:
space:
mode:
authorCzarek Nakamoto <cyjan@mrcyjanek.net>2023-12-27 23:05:56 +0100
committerCzarek Nakamoto <cyjan@mrcyjanek.net>2023-12-27 23:05:56 +0100
commit07f56276b0d8aaa6870e317340676e1454ea5de6 (patch)
treeef50b0357d4b946bb209891e7ea614b2333b28fd /libbridge/src/main/cpp/wallet2_api_c.cpp
parentfb76ef5dddd4403e7feca268680b86d331bb6957 (diff)
implement some functions to perform testing
Diffstat (limited to 'libbridge/src/main/cpp/wallet2_api_c.cpp')
-rw-r--r--libbridge/src/main/cpp/wallet2_api_c.cpp120
1 files changed, 95 insertions, 25 deletions
diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp
index 4818e1d..3a5895c 100644
--- a/libbridge/src/main/cpp/wallet2_api_c.cpp
+++ b/libbridge/src/main/cpp/wallet2_api_c.cpp
@@ -25,42 +25,112 @@ extern "C"
{
#endif
-// void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType)
-void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType) {
- Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
- std::cout << "WE GOT OUT\n";
- std::string _path(path);
- std::string _password(password);
- std::string _language(language);
- std::cout << "_path = " << _path << "\n";
- std::cout << "_password = " << _password << "\n";
- std::cout << "_language = " << _language << "\n";
-
- Monero::Wallet *wallet =
- Monero::WalletManagerFactory::getWalletManager()->createWallet(
- _path,
- _password,
- _language,
- _networkType);
-
- return reinterpret_cast<void*>(wallet);
+const char* MONERO_Wallet_seed(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->seed().c_str();
}
-// virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, NetworkType nettype, uint64_t restoreHeight = 0) = 0;
+int MONERO_Wallet_status(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->status();
+}
const char* MONERO_Wallet_errorString(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->errorString().c_str();
}
-int MONERO_Wallet_status(void* wallet_ptr) {
+const char* MONERO_Wallet_address(void* wallet_ptr, uint64_t accountIndex, uint64_t addressIndex) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
- return wallet->status();
+ return wallet->address(accountIndex, addressIndex).c_str();
+}
+
+const char* MONERO_Wallet_secretViewKey(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->secretViewKey().c_str();
+}
+
+const char* MONERO_Wallet_publicViewKey(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->publicViewKey().c_str();
+}
+
+const char* MONERO_Wallet_secretSpendKey(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->secretSpendKey().c_str();
+}
+
+const char* MONERO_Wallet_publicSpendKey(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->publicSpendKey().c_str();
+}
+
+void MONERO_Wallet_stop(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ wallet->stop();
+}
+
+void MONERO_Wallet_store(void* wallet_ptr, const char* path) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ wallet->store(std::string(path));
+}
+
+uint64_t MONERO_Wallet_balance(void* wallet_ptr, uint32_t accountIndex) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->balance(accountIndex);
}
-int MONERO_DEBUG_sleep(int time) {
- sleep(time);
- return time-1;
+uint64_t MONERO_Wallet_unlockedBalance(void* wallet_ptr, uint32_t accountIndex) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return wallet->unlockedBalance(accountIndex);
+}
+
+void* MONERO_WalletManager_createWallet(const char* path, const char* password, const char* language, int networkType) {
+ Monero::Wallet *wallet =
+ Monero::WalletManagerFactory::getWalletManager()->createWallet(
+ std::string(path),
+ std::string(password),
+ std::string(language),
+ static_cast<Monero::NetworkType>(networkType));
+ return reinterpret_cast<void*>(wallet);
+}
+
+void* MONERO_WalletManager_openWallet(const char* path, const char* password, int networkType) {
+ Monero::Wallet *wallet =
+ Monero::WalletManagerFactory::getWalletManager()->openWallet(
+ std::string(path),
+ std::string(password),
+ static_cast<Monero::NetworkType>(networkType));
+ return reinterpret_cast<void*>(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) {
+ // (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(
+ std::string(path),
+ std::string(password),
+ std::string(mnemonic),
+ static_cast<Monero::NetworkType>(networkType),
+ restoreHeight,
+ kdfRounds,
+ std::string(seedOffset));
+ return reinterpret_cast<void*>(wallet);
+}
+
+bool MONERO_WalletManager_closeWallet(void* wallet_ptr, bool store) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ return Monero::WalletManagerFactory::getWalletManager()->closeWallet(
+ wallet,
+ store);
+}
+
+// DEBUG functions
+
+// the Answer to the Ultimate Question of Life, the Universe, and Everything.
+int MONERO_DEBUG_theAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything(int x) {
+ return x*42;
}
#ifdef __cplusplus