mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 07:52:25 +00:00
started WalletListener
This commit is contained in:
parent
e6fdd5dd10
commit
374577018d
3 changed files with 65 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue