aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wallet/api/wallet.cpp10
-rw-r--r--src/wallet/api/wallet.h1
-rw-r--r--src/wallet/wallet2_api.h34
3 files changed, 42 insertions, 3 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 49ccceb13..eef956e80 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -75,8 +75,12 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
virtual void on_new_block(uint64_t height, const cryptonote::block& block)
{
- // TODO;
LOG_PRINT_L3(__FUNCTION__ << ": new block. height: " << height);
+
+ if (m_listener) {
+ m_listener->newBlock(height);
+ m_listener->updated();
+ }
}
virtual void on_money_received(uint64_t height, const cryptonote::transaction& tx, uint64_t amount)
@@ -413,6 +417,10 @@ uint64_t WalletImpl::unlockedBalance() const
return m_wallet->unlocked_balance();
}
+uint64_t WalletImpl::blockChainHeight() const
+{
+ return m_wallet->get_blockchain_current_height();
+}
bool WalletImpl::refresh()
{
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 11880d555..1a34a04fd 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -75,6 +75,7 @@ public:
bool trustedDaemon() const;
uint64_t balance() const;
uint64_t unlockedBalance() const;
+ uint64_t blockChainHeight() const;
bool refresh();
void refreshAsync();
void setAutoRefreshInterval(int seconds);
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 2d2877856..08f010b32 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -114,11 +114,35 @@ struct TransactionHistory
struct WalletListener
{
virtual ~WalletListener() = 0;
+ /**
+ * @brief moneySpent - called when money spent
+ * @param txId - transaction id
+ * @param amount - amount
+ */
virtual void moneySpent(const std::string &txId, uint64_t amount) = 0;
+
+ /**
+ * @brief moneyReceived - called when money received
+ * @param txId - transaction id
+ * @param amount - amount
+ */
virtual void moneyReceived(const std::string &txId, uint64_t amount) = 0;
- // generic callback, called when any event (sent/received/block reveived/etc) happened with the wallet;
+
+ /**
+ * @brief newBlock - called when new block received
+ * @param height - block height
+ */
+ virtual void newBlock(uint64_t height) = 0;
+
+ /**
+ * @brief updated - generic callback, called when any event (sent/received/block reveived/etc) happened with the wallet;
+ */
virtual void updated() = 0;
- // called when wallet refreshed by background thread or explicitly called be calling "refresh" synchronously
+
+
+ /**
+ * @brief refreshed - called when wallet refreshed by background thread or explicitly refreshed by calling "refresh" synchronously
+ */
virtual void refreshed() = 0;
};
@@ -211,6 +235,12 @@ struct Wallet
virtual uint64_t balance() const = 0;
virtual uint64_t unlockedBalance() const = 0;
+ /**
+ * @brief getBlockChainHeight - returns current blockchain height
+ * @return
+ */
+ virtual uint64_t blockChainHeight() const = 0;
+
static std::string displayAmount(uint64_t amount);
static uint64_t amountFromString(const std::string &amount);
static uint64_t amountFromDouble(double amount);