aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/wallet/api/wallet.cpp54
-rw-r--r--src/wallet/api/wallet.h4
-rw-r--r--src/wallet/wallet2_api.h8
3 files changed, 65 insertions, 1 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index d9d24b4f0..6170000b7 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -47,6 +47,47 @@ namespace {
static const size_t DEFAULT_MIX = 4;
}
+struct Wallet2CallbackImpl : public tools::i_wallet2_callback
+{
+
+ ~Wallet2CallbackImpl()
+ {
+
+ }
+
+ void setListener(WalletListener * listener)
+ {
+ // TODO;
+ }
+
+ WalletListener * getListener() const
+ {
+ return m_listener;
+ }
+
+ virtual void on_new_block(uint64_t height, const cryptonote::block& block)
+ {
+ // TODO;
+ }
+ virtual void on_money_received(uint64_t height, const cryptonote::transaction& tx, size_t out_index)
+ {
+ // TODO;
+
+ }
+ virtual void on_money_spent(uint64_t height, const cryptonote::transaction& in_tx, size_t out_index,
+ const cryptonote::transaction& spend_tx)
+ {
+ // TODO;
+ }
+
+ virtual void on_skip_transaction(uint64_t height, const cryptonote::transaction& tx)
+ {
+ // TODO;
+ }
+
+ WalletListener * m_listener;
+};
+
Wallet::~Wallet() {}
string Wallet::displayAmount(uint64_t amount)
@@ -56,14 +97,17 @@ string Wallet::displayAmount(uint64_t amount)
///////////////////////// WalletImpl implementation ////////////////////////
WalletImpl::WalletImpl(bool testnet)
- :m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false)
+ :m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false),
+ m_wallet2Callback(nullptr)
{
m_wallet = new tools::wallet2(testnet);
m_history = new TransactionHistoryImpl(this);
+ m_wallet2Callback = new Wallet2CallbackImpl;
}
WalletImpl::~WalletImpl()
{
+ delete m_wallet2Callback;
delete m_history;
delete m_wallet;
}
@@ -399,6 +443,14 @@ TransactionHistory *WalletImpl::history() const
return m_history;
}
+void WalletImpl::setListener(WalletListener *l)
+{
+ // TODO thread synchronization;
+ m_wallet2Callback->setListener(l);
+}
+
+
+
bool WalletImpl::connectToDaemon()
{
bool result = m_wallet->check_connection();
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 3671c2f7a..c0fa31003 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -40,6 +40,7 @@
namespace Bitmonero {
class TransactionHistoryImpl;
class PendingTransactionImpl;
+struct Wallet2CallbackImpl;
class WalletImpl : public Wallet
{
@@ -70,6 +71,7 @@ public:
PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount);
virtual void disposeTransaction(PendingTransaction * t);
virtual TransactionHistory * history() const;
+ virtual void setListener(WalletListener * l);
private:
void clearStatus();
@@ -84,6 +86,8 @@ private:
std::string m_password;
TransactionHistoryImpl * m_history;
bool m_trustedDaemon;
+ WalletListener * m_walletListener;
+ Wallet2CallbackImpl * m_wallet2Callback;
};
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 43f5c9472..8e0830746 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -103,6 +103,13 @@ struct TransactionHistory
};
+struct WalletListener
+{
+ virtual ~WalletListener() = 0;
+ virtual void moneySpent(const std::string &txId, uint64_t amount);
+ virtual void moneyReceived(const std::string &txId, uint64_t amount);
+};
+
/**
* @brief Interface for wallet operations.
@@ -141,6 +148,7 @@ struct Wallet
virtual PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount) = 0;
virtual void disposeTransaction(PendingTransaction * t) = 0;
virtual TransactionHistory * history() const = 0;
+ virtual void setListener(WalletListener *) = 0;
};
/**