From 56c0c95e8a1a9a2c91a628d34f41b8453eb4dbce Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Sun, 14 Apr 2024 14:13:46 +0200 Subject: cake om nom nom nom --- .../src/main/cpp/wallet2_api_c.cpp | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) 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 0160b8c..c75d08f 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 @@ -1695,6 +1695,77 @@ bool MONERO_DEBUG_isPointerNull(void* wallet_ptr) { return (wallet != NULL); } +// rather minimal implementation of the WalletListener +// borrowed from cake, I'm going to explore callbacks in future, but for now this is just enough. +struct MoneroWalletListener : Monero::WalletListener +{ + uint64_t m_height; + bool m_need_to_refresh; + bool m_new_transaction; + + MoneroWalletListener() + { + 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 resetNeedToRefresh() + { + m_need_to_refresh = false; + } + + bool isNeedToRefresh() + { + return m_need_to_refresh; + } + + bool isNewTransactionExist() + { + return m_new_transaction; + } + + void resetIsNewTransactionExist() + { + m_new_transaction = false; + } + + uint64_t height() + { + return m_height; + } +}; + #ifdef __cplusplus } #endif -- cgit v1.2.3