diff options
author | Riccardo Spagni <ric@spagni.net> | 2018-12-12 11:53:42 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2018-12-12 11:53:42 +0200 |
commit | 0b31baf6e4ce272b0b65e9d5337d1a4c933471cb (patch) | |
tree | 64d74190c831dc7b296d9ef1e6ae8c62501ca490 /src/device_trezor/device_trezor_base.hpp | |
parent | Merge pull request #4787 (diff) | |
parent | device/trezor: device/trezor: correct device initialization, status check (diff) | |
download | monero-0b31baf6e4ce272b0b65e9d5337d1a4c933471cb.tar.xz |
Merge pull request #4839
d71f89e2 device/trezor: device/trezor: correct device initialization, status check (Dusan Klinec)
65b9bca7 device/trezor: python2 compatibility - bundle dependencies (Dusan Klinec)
9cf636af device/trezor: ask for KI sync on first refresh (Dusan Klinec)
d21dad70 device: enable to use multiple independent device wallets (Dusan Klinec)
318cc784 device/trezor: passphrase entry on host (Dusan Klinec)
Diffstat (limited to 'src/device_trezor/device_trezor_base.hpp')
-rw-r--r-- | src/device_trezor/device_trezor_base.hpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/device_trezor/device_trezor_base.hpp b/src/device_trezor/device_trezor_base.hpp index 88d419494..3c35e8aca 100644 --- a/src/device_trezor/device_trezor_base.hpp +++ b/src/device_trezor/device_trezor_base.hpp @@ -58,17 +58,6 @@ namespace trezor { class device_trezor_base; /** - * Trezor device callbacks - */ - class trezor_callback { - public: - virtual void on_button_request() {}; - virtual void on_pin_request(epee::wipeable_string & pin) {}; - virtual void on_passphrase_request(bool on_device, epee::wipeable_string & passphrase) {}; - virtual void on_passphrase_state_request(const std::string & state) {}; - }; - - /** * TREZOR device template with basic functions */ class device_trezor_base : public hw::core::device_default { @@ -79,9 +68,12 @@ namespace trezor { mutable boost::mutex command_locker; std::shared_ptr<Transport> m_transport; - std::shared_ptr<trezor_callback> m_callback; + i_device_callback * m_callback; - std::string full_name; + std::string m_full_name; + std::vector<unsigned int> m_wallet_deriv_path; + std::string m_device_state; // returned after passphrase entry, session + std::shared_ptr<messages::management::Features> m_features; // features from the last device reset cryptonote::network_type network_type; @@ -90,8 +82,11 @@ namespace trezor { // void require_connected(); + void require_initialized(); void call_ping_unsafe(); void test_ping(); + void device_state_reset_unsafe(); + void ensure_derivation_path() noexcept; // Communication methods @@ -139,7 +134,7 @@ namespace trezor { // Scoped session closer BOOST_SCOPE_EXIT_ALL(&, this) { if (open_session){ - this->getTransport()->close(); + this->get_transport()->close(); } }; @@ -187,9 +182,13 @@ namespace trezor { msg->add_address_n(x); } } else { + ensure_derivation_path(); for (unsigned int i : DEFAULT_BIP44_PATH) { msg->add_address_n(i); } + for (unsigned int i : m_wallet_deriv_path) { + msg->add_address_n(i); + } } if (network_type){ @@ -212,16 +211,26 @@ namespace trezor { bool reset(); // Default derivation path for Monero - static const uint32_t DEFAULT_BIP44_PATH[3]; + static const uint32_t DEFAULT_BIP44_PATH[2]; - std::shared_ptr<Transport> getTransport(){ + std::shared_ptr<Transport> get_transport(){ return m_transport; } - std::shared_ptr<trezor_callback> getCallback(){ + void set_callback(i_device_callback * callback) override { + m_callback = callback; + } + + i_device_callback * get_callback(){ return m_callback; } + std::shared_ptr<messages::management::Features> & get_features() { + return m_features; + } + + void set_derivation_path(const std::string &deriv_path) override; + /* ======================================================================= */ /* SETUP/TEARDOWN */ /* ======================================================================= */ @@ -249,6 +258,11 @@ namespace trezor { */ bool ping(); + /** + * Performs Initialize call to the Trezor, resets to known state. + */ + void device_state_reset(); + // Protocol callbacks void on_button_request(GenericMessage & resp, const messages::common::ButtonRequest * msg); void on_pin_request(GenericMessage & resp, const messages::common::PinMatrixRequest * msg); |