mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
started WalletListener
This commit is contained in:
parent
71131a84ea
commit
5dbd2b8fc3
@ -47,6 +47,47 @@ namespace {
|
|||||||
static const size_t DEFAULT_MIX = 4;
|
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() {}
|
Wallet::~Wallet() {}
|
||||||
|
|
||||||
string Wallet::displayAmount(uint64_t amount)
|
string Wallet::displayAmount(uint64_t amount)
|
||||||
@ -56,14 +97,17 @@ string Wallet::displayAmount(uint64_t amount)
|
|||||||
|
|
||||||
///////////////////////// WalletImpl implementation ////////////////////////
|
///////////////////////// WalletImpl implementation ////////////////////////
|
||||||
WalletImpl::WalletImpl(bool testnet)
|
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_wallet = new tools::wallet2(testnet);
|
||||||
m_history = new TransactionHistoryImpl(this);
|
m_history = new TransactionHistoryImpl(this);
|
||||||
|
m_wallet2Callback = new Wallet2CallbackImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletImpl::~WalletImpl()
|
WalletImpl::~WalletImpl()
|
||||||
{
|
{
|
||||||
|
delete m_wallet2Callback;
|
||||||
delete m_history;
|
delete m_history;
|
||||||
delete m_wallet;
|
delete m_wallet;
|
||||||
}
|
}
|
||||||
@ -399,6 +443,14 @@ TransactionHistory *WalletImpl::history() const
|
|||||||
return m_history;
|
return m_history;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WalletImpl::setListener(WalletListener *l)
|
||||||
|
{
|
||||||
|
// TODO thread synchronization;
|
||||||
|
m_wallet2Callback->setListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool WalletImpl::connectToDaemon()
|
bool WalletImpl::connectToDaemon()
|
||||||
{
|
{
|
||||||
bool result = m_wallet->check_connection();
|
bool result = m_wallet->check_connection();
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
namespace Bitmonero {
|
namespace Bitmonero {
|
||||||
class TransactionHistoryImpl;
|
class TransactionHistoryImpl;
|
||||||
class PendingTransactionImpl;
|
class PendingTransactionImpl;
|
||||||
|
struct Wallet2CallbackImpl;
|
||||||
|
|
||||||
class WalletImpl : public Wallet
|
class WalletImpl : public Wallet
|
||||||
{
|
{
|
||||||
@ -70,6 +71,7 @@ public:
|
|||||||
PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount);
|
PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount);
|
||||||
virtual void disposeTransaction(PendingTransaction * t);
|
virtual void disposeTransaction(PendingTransaction * t);
|
||||||
virtual TransactionHistory * history() const;
|
virtual TransactionHistory * history() const;
|
||||||
|
virtual void setListener(WalletListener * l);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearStatus();
|
void clearStatus();
|
||||||
@ -84,6 +86,8 @@ private:
|
|||||||
std::string m_password;
|
std::string m_password;
|
||||||
TransactionHistoryImpl * m_history;
|
TransactionHistoryImpl * m_history;
|
||||||
bool m_trustedDaemon;
|
bool m_trustedDaemon;
|
||||||
|
WalletListener * m_walletListener;
|
||||||
|
Wallet2CallbackImpl * m_wallet2Callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.
|
* @brief Interface for wallet operations.
|
||||||
@ -141,6 +148,7 @@ struct Wallet
|
|||||||
virtual PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount) = 0;
|
virtual PendingTransaction * createTransaction(const std::string &dst_addr, uint64_t amount) = 0;
|
||||||
virtual void disposeTransaction(PendingTransaction * t) = 0;
|
virtual void disposeTransaction(PendingTransaction * t) = 0;
|
||||||
virtual TransactionHistory * history() const = 0;
|
virtual TransactionHistory * history() const = 0;
|
||||||
|
virtual void setListener(WalletListener *) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user