diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index f5143a586..37ff1b979 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -295,9 +295,31 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback } } - virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) { /* TODO */ } - virtual boost::optional on_get_password(const char *reason) { return boost::none; } - virtual void on_pool_tx_removed(const crypto::hash &txid) { /* TODO */ } + virtual void on_reorg(std::uint64_t height, std::uint64_t blocks_detached, std::size_t transfers_detached) + { + if (m_listener) { + m_listener->onReorg(height, blocks_detached, transfers_detached); + } + } + + virtual boost::optional on_get_password(const char *reason) + { + if (m_listener) { + auto password = m_listener->onGetPassword(reason); + if (password) { + return boost::make_optional(epee::wipeable_string((*password).data(), (*password).size())); + } + } + return boost::none; + } + + virtual void on_pool_tx_removed(const crypto::hash &txid) + { + std::string txid_hex = epee::string_tools::pod_to_hex(txid); + if (m_listener) { + m_listener->onPoolTxRemoved(txid_hex); + } + } WalletListener * m_listener; WalletImpl * m_wallet; diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index 298345970..928e76d23 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -469,6 +469,21 @@ struct WalletListener * @brief If the listener is created before the wallet this enables to set created wallet object */ virtual void onSetWallet(Wallet * wallet) { (void)wallet; }; + + /** + * @brief called on blockchain reorg + */ + virtual void onReorg(std::uint64_t height, std::uint64_t blocks_detached, std::size_t transfers_detached) = 0; + + /** + * @brief called by scan_output() to decrypt keys + */ + virtual optional onGetPassword(const char *reason) = 0; + + /** + * @brief called when obsolete pool transactions get removed + */ + virtual void onPoolTxRemoved(const std::string &txid) = 0; };