From 76f3318555377af5709adf95314da9ed9313f067 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 26 May 2020 13:23:26 +0300 Subject: [PATCH] simplewallet: i_wallet2_callback: added "override", changed on_money_received/on_money_spent to on_transfer2 --- src/simplewallet/simplewallet.cpp | 23 ++++++++--------------- src/simplewallet/simplewallet.h | 5 ++--- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index dcbea8ab..1c847e00 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -593,22 +593,15 @@ void simple_wallet::on_new_block(uint64_t height, const currency::block& block) m_refresh_progress_reporter.update(height, false); } //---------------------------------------------------------------------------------------------------- -void simple_wallet::on_money_received(uint64_t height, const currency::transaction& tx, size_t out_index) +void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) { - message_writer(epee::log_space::console_color_green, false) << - "Height " << height << - ", transaction " << get_transaction_hash(tx) << - ", received " << print_money(tx.vout[out_index].amount); - m_refresh_progress_reporter.update(height, true); -} -//---------------------------------------------------------------------------------------------------- -void simple_wallet::on_money_spent(uint64_t height, const currency::transaction& in_tx, size_t out_index, const currency::transaction& spend_tx) -{ - message_writer(epee::log_space::console_color_magenta, false) << - "Height " << height << - ", transaction " << get_transaction_hash(spend_tx) << - ", spent " << print_money(in_tx.vout[out_index].amount); - m_refresh_progress_reporter.update(height, true); + epee::log_space::console_colors color = wti.is_income ? epee::log_space::console_color_green : epee::log_space::console_color_magenta; + message_writer(color, false) << + "height " << wti.height << + ", tx " << wti.tx_hash << + (wti.is_income ? ", received " : ", spent ") << print_money_brief(wti.amount) << + ", balance: " << print_money_brief(balance); + m_refresh_progress_reporter.update(wti.height, true); } //---------------------------------------------------------------------------------------------------- bool simple_wallet::refresh(const std::vector& args) diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index c1ea6d04..d8595c19 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -93,9 +93,8 @@ namespace currency bool try_connect_to_daemon(); //----------------- i_wallet2_callback --------------------- - virtual void on_new_block(uint64_t height, const currency::block& block); - virtual void on_money_received(uint64_t height, const currency::transaction& tx, size_t out_index); - virtual void on_money_spent(uint64_t height, const currency::transaction& in_tx, size_t out_index, const currency::transaction& spend_tx); + virtual void on_new_block(uint64_t height, const currency::block& block) override; + virtual void on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) override; //---------------------------------------------------------- friend class refresh_progress_reporter_t;