aboutsummaryrefslogtreecommitdiff
path: root/src/device_trezor
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-15 09:12:19 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-15 09:12:20 +0200
commit37aea526a9b980ef0cb47403a7a587390baa248f (patch)
tree34ef86d6da9707f3324a8166d34edfeb605a146c /src/device_trezor
parentMerge pull request #5423 (diff)
parentdevice/trezor: add button pressed request (diff)
downloadmonero-37aea526a9b980ef0cb47403a7a587390baa248f.tar.xz
Merge pull request #5355
c68fe787 device/trezor: add button pressed request (Dusan Klinec) 827f52ad wallet: API changes to enable passphrase entry (Dusan Klinec)
Diffstat (limited to 'src/device_trezor')
-rw-r--r--src/device_trezor/device_trezor_base.cpp13
-rw-r--r--src/device_trezor/device_trezor_base.hpp2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/device_trezor/device_trezor_base.cpp b/src/device_trezor/device_trezor_base.cpp
index f3d15c5e2..58abde1d1 100644
--- a/src/device_trezor/device_trezor_base.cpp
+++ b/src/device_trezor/device_trezor_base.cpp
@@ -43,7 +43,7 @@ namespace trezor {
const uint32_t device_trezor_base::DEFAULT_BIP44_PATH[] = {0x8000002c, 0x80000080};
- device_trezor_base::device_trezor_base(): m_callback(nullptr) {
+ device_trezor_base::device_trezor_base(): m_callback(nullptr), m_last_msg_type(messages::MessageType_Success) {
#ifdef WITH_TREZOR_DEBUGGING
m_debug = false;
#endif
@@ -275,6 +275,12 @@ namespace trezor {
// Later if needed this generic message handler can be replaced by a pointer to
// a protocol message handler which by default points to the device class which implements
// the default handler.
+
+ if (m_last_msg_type == messages::MessageType_ButtonRequest){
+ on_button_pressed();
+ }
+ m_last_msg_type = input.m_type;
+
switch(input.m_type){
case messages::MessageType_ButtonRequest:
on_button_request(input, dynamic_cast<const messages::common::ButtonRequest*>(input.m_msg.get()));
@@ -413,6 +419,11 @@ namespace trezor {
resp = read_raw();
}
+ void device_trezor_base::on_button_pressed()
+ {
+ TREZOR_CALLBACK(on_button_pressed);
+ }
+
void device_trezor_base::on_pin_request(GenericMessage & resp, const messages::common::PinMatrixRequest * msg)
{
MDEBUG("on_pin_request");
diff --git a/src/device_trezor/device_trezor_base.hpp b/src/device_trezor/device_trezor_base.hpp
index 8c3c14b29..c106d2099 100644
--- a/src/device_trezor/device_trezor_base.hpp
+++ b/src/device_trezor/device_trezor_base.hpp
@@ -98,6 +98,7 @@ namespace trezor {
std::shared_ptr<messages::management::Features> m_features; // features from the last device reset
boost::optional<epee::wipeable_string> m_pin;
boost::optional<epee::wipeable_string> m_passphrase;
+ messages::MessageType m_last_msg_type;
cryptonote::network_type network_type;
@@ -311,6 +312,7 @@ namespace trezor {
// Protocol callbacks
void on_button_request(GenericMessage & resp, const messages::common::ButtonRequest * msg);
+ void on_button_pressed();
void on_pin_request(GenericMessage & resp, const messages::common::PinMatrixRequest * msg);
void on_passphrase_request(GenericMessage & resp, const messages::common::PassphraseRequest * msg);
void on_passphrase_state_request(GenericMessage & resp, const messages::common::PassphraseStateRequest * msg);