aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/wallet.cpp
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-05-13 16:25:31 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-06-23 16:01:33 +0300
commit060bb62e29ba7e08707942b51734a57c149039e6 (patch)
treeac1f97dc2f840d782981d7727be30703ff3ee194 /src/wallet/api/wallet.cpp
parenti_wallet_callback: virtual dtor (diff)
downloadmonero-060bb62e29ba7e08707942b51734a57c149039e6.tar.xz
WalletListener::moneySpent(), WalletListener::moneyReceived()
Diffstat (limited to '')
-rw-r--r--src/wallet/api/wallet.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 6170000b7..5819e42bc 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -57,7 +57,7 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback
void setListener(WalletListener * listener)
{
- // TODO;
+ m_listener = listener;
}
WalletListener * getListener() const
@@ -68,16 +68,35 @@ 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);
}
+
virtual void on_money_received(uint64_t height, const cryptonote::transaction& tx, size_t out_index)
{
- // TODO;
+ std::string tx_hash = epee::string_tools::pod_to_hex(get_transaction_hash(tx));
+ uint64_t amount = tx.vout[out_index].amount;
+
+ LOG_PRINT_L3(__FUNCTION__ << ": money received. height: " << height
+ << ", tx: " << tx_hash
+ << ", amount: " << print_money(amount));
+ if (m_listener) {
+ m_listener->moneyReceived(tx_hash, amount);
+ }
}
+
virtual void on_money_spent(uint64_t height, const cryptonote::transaction& in_tx, size_t out_index,
const cryptonote::transaction& spend_tx)
{
// TODO;
+ std::string tx_hash = epee::string_tools::pod_to_hex(get_transaction_hash(spend_tx));
+ uint64_t amount = in_tx.vout[out_index].amount;
+ LOG_PRINT_L3(__FUNCTION__ << ": money spent. height: " << height
+ << ", tx: " << tx_hash
+ << ", amount: " << print_money(amount));
+ if (m_listener) {
+ m_listener->moneySpent(tx_hash, amount);
+ }
}
virtual void on_skip_transaction(uint64_t height, const cryptonote::transaction& tx)