From c68fe7873bec21d6163b10d9e8f7c8d4d53f5a23 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Fri, 5 Apr 2019 21:47:24 +0200 Subject: device/trezor: add button pressed request --- src/wallet/api/wallet.cpp | 7 +++++++ src/wallet/api/wallet2_api.h | 5 +++++ src/wallet/wallet2.cpp | 12 ++++++++++++ src/wallet/wallet2.h | 3 +++ 4 files changed, 27 insertions(+) (limited to 'src/wallet') diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 2a972cf78..032b873d6 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -249,6 +249,13 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback } } + virtual void on_device_button_pressed() + { + if (m_listener) { + m_listener->onDeviceButtonPressed(); + } + } + virtual boost::optional on_device_pin_request() { if (m_listener) { diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index 377330401..0af3b1867 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -385,6 +385,11 @@ struct WalletListener */ virtual void onDeviceButtonRequest(uint64_t code) { (void)code; } + /** + * @brief called by device if the button was pressed + */ + virtual void onDeviceButtonPressed() { } + /** * @brief called by device when PIN is needed */ diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 0e82f1a91..b30556a45 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -978,6 +978,12 @@ void wallet_device_callback::on_button_request(uint64_t code) wallet->on_device_button_request(code); } +void wallet_device_callback::on_button_pressed() +{ + if (wallet) + wallet->on_device_button_pressed(); +} + boost::optional wallet_device_callback::on_pin_request() { if (wallet) @@ -12855,6 +12861,12 @@ void wallet2::on_device_button_request(uint64_t code) m_callback->on_device_button_request(code); } //---------------------------------------------------------------------------------------------------- +void wallet2::on_device_button_pressed() +{ + if (nullptr != m_callback) + m_callback->on_device_button_pressed(); +} +//---------------------------------------------------------------------------------------------------- boost::optional wallet2::on_device_pin_request() { if (nullptr != m_callback) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 2eb7de94a..0f6791bee 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -105,6 +105,7 @@ namespace tools virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {} // Device callbacks virtual void on_device_button_request(uint64_t code) {} + virtual void on_device_button_pressed() {} virtual boost::optional on_device_pin_request() { return boost::none; } virtual boost::optional on_device_passphrase_request(bool on_device) { return boost::none; } virtual void on_device_progress(const hw::device_progress& event) {}; @@ -118,6 +119,7 @@ namespace tools public: wallet_device_callback(wallet2 * wallet): wallet(wallet) {}; void on_button_request(uint64_t code=0) override; + void on_button_pressed() override; boost::optional on_pin_request() override; boost::optional on_passphrase_request(bool on_device) override; void on_progress(const hw::device_progress& event) override; @@ -1367,6 +1369,7 @@ namespace tools wallet_device_callback * get_device_callback(); void on_device_button_request(uint64_t code); + void on_device_button_pressed(); boost::optional on_device_pin_request(); boost::optional on_device_passphrase_request(bool on_device); void on_device_progress(const hw::device_progress& event); -- cgit v1.2.3