summaryrefslogtreecommitdiff
path: root/monero_libwallet2_api_c/src/main/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'monero_libwallet2_api_c/src/main/cpp')
-rw-r--r--monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp108
-rw-r--r--monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h9
2 files changed, 117 insertions, 0 deletions
diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp
index a39182c..ab13e15 100644
--- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp
+++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.cpp
@@ -1697,6 +1697,114 @@ bool MONERO_DEBUG_isPointerNull(void* wallet_ptr) {
return (wallet != NULL);
}
+// cake wallet world
+// TODO(mrcyjanek): https://api.dart.dev/stable/3.3.3/dart-ffi/Pointer/fromFunction.html
+// callback to dart should be possible..? I mean why not? But I need to
+// wait for other implementation (Go preferably) to see if this approach
+// will work as expected.
+struct MONERO_cw_WalletListener;
+struct MONERO_cw_WalletListener : Monero::WalletListener
+{
+ uint64_t m_height;
+ bool m_need_to_refresh;
+ bool m_new_transaction;
+
+ MONERO_cw_WalletListener()
+ {
+ m_height = 0;
+ m_need_to_refresh = false;
+ m_new_transaction = false;
+ }
+
+ void moneySpent(const std::string &txId, uint64_t amount)
+ {
+ m_new_transaction = true;
+ }
+
+ void moneyReceived(const std::string &txId, uint64_t amount)
+ {
+ m_new_transaction = true;
+ }
+
+ void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount)
+ {
+ m_new_transaction = true;
+ }
+
+ void newBlock(uint64_t height)
+ {
+ m_height = height;
+ }
+
+ void updated()
+ {
+ m_new_transaction = true;
+ }
+
+ void refreshed()
+ {
+ m_need_to_refresh = true;
+ }
+
+
+ void cw_resetNeedToRefresh()
+ {
+ m_need_to_refresh = false;
+ }
+
+ bool cw_isNeedToRefresh()
+ {
+ return m_need_to_refresh;
+ }
+
+ bool cw_isNewTransactionExist()
+ {
+ return m_new_transaction;
+ }
+
+ void cw_resetIsNewTransactionExist()
+ {
+ m_new_transaction = false;
+ }
+
+ uint64_t cw_height()
+ {
+ return m_height;
+ }
+};
+
+void* MONERO_cw_getWalletListener(void* wallet_ptr) {
+ Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
+ MONERO_cw_WalletListener *listener = new MONERO_cw_WalletListener();
+ wallet->setListener(listener);
+ return reinterpret_cast<void*>(listener);
+}
+
+void MONERO_cw_WalletListener_resetNeedToRefresh(void* cw_walletListener_ptr) {
+ MONERO_cw_WalletListener *listener = reinterpret_cast<MONERO_cw_WalletListener*>(cw_walletListener_ptr);
+ listener->cw_resetNeedToRefresh();
+}
+
+bool MONERO_cw_WalletListener_isNeedToRefresh(void* cw_walletListener_ptr) {
+ MONERO_cw_WalletListener *listener = reinterpret_cast<MONERO_cw_WalletListener*>(cw_walletListener_ptr);
+ return listener->cw_isNeedToRefresh();
+};
+
+bool MONERO_cw_WalletListener_isNewTransactionExist(void* cw_walletListener_ptr) {
+ MONERO_cw_WalletListener *listener = reinterpret_cast<MONERO_cw_WalletListener*>(cw_walletListener_ptr);
+ return listener->cw_isNeedToRefresh();
+};
+
+void MONERO_cw_WalletListener_resetIsNewTransactionExist(void* cw_walletListener_ptr) {
+ MONERO_cw_WalletListener *listener = reinterpret_cast<MONERO_cw_WalletListener*>(cw_walletListener_ptr);
+ listener->cw_isNeedToRefresh();
+};
+
+uint64_t MONERO_cw_WalletListener_height(void* cw_walletListener_ptr) {
+ MONERO_cw_WalletListener *listener = reinterpret_cast<MONERO_cw_WalletListener*>(cw_walletListener_ptr);
+ return listener->cw_isNeedToRefresh();
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h
index afa2a71..f0bd66e 100644
--- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h
+++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h
@@ -976,6 +976,15 @@ extern ADDAPI const char* MONERO_DEBUG_test5();
extern ADDAPI const char* MONERO_DEBUG_test5_std();
extern ADDAPI bool MONERO_DEBUG_isPointerNull(void* wallet_ptr);
+// cake world
+
+extern ADDAPI void* MONERO_cw_getWalletListener(void* wallet_ptr);
+extern ADDAPI void MONERO_cw_WalletListener_resetNeedToRefresh(void* cw_walletListener_ptr);
+extern ADDAPI bool MONERO_cw_WalletListener_isNeedToRefresh(void* cw_walletListener_ptr);
+extern ADDAPI bool MONERO_cw_WalletListener_isNewTransactionExist(void* cw_walletListener_ptr);
+extern ADDAPI void MONERO_cw_WalletListener_resetIsNewTransactionExist(void* cw_walletListener_ptr);
+extern ADDAPI uint64_t MONERO_cw_WalletListener_height(void* cw_walletListener_ptr);
+
#ifdef __cplusplus
}
#endif \ No newline at end of file