30 #ifndef MONERO_DEVICE_TREZOR_H
31 #define MONERO_DEVICE_TREZOR_H
36 #ifdef WITH_DEVICE_TREZOR
39 #include <boost/scope_exit.hpp>
40 #include <boost/thread/mutex.hpp>
41 #include <boost/thread/recursive_mutex.hpp>
53 void register_all(std::map<std::string, std::unique_ptr<device>> ®istry);
55 #ifdef WITH_DEVICE_TREZOR
61 class device_trezor :
public hw::trezor::device_trezor_base,
public hw::device_cold {
63 std::atomic<bool> m_live_refresh_in_progress;
64 std::chrono::steady_clock::time_point m_last_live_refresh_time;
65 std::unique_ptr<boost::thread> m_live_refresh_thread;
66 std::atomic<bool> m_live_refresh_thread_running;
67 bool m_live_refresh_enabled;
68 size_t m_num_transations_to_sign;
70 unsigned client_version();
72 void transaction_pre_check(std::shared_ptr<messages::monero::MoneroTransactionInitRequest> init_msg);
73 void transaction_check(
const protocol::tx::TData & tdata,
const hw::tx_aux_data & aux_data);
74 void device_state_initialize_unsafe()
override;
75 void live_refresh_start_unsafe();
76 void live_refresh_finish_unsafe();
77 void live_refresh_thread_main();
86 std::shared_ptr<protocol::tx::Signer> & signer);
90 virtual ~device_trezor()
override;
92 device_trezor(
const device_trezor &device) = delete ;
93 device_trezor& operator=(
const device_trezor &device) =
delete;
95 explicit operator bool()
const override {
return true;}
98 bool release()
override;
99 bool disconnect()
override;
101 device_protocol_t device_protocol()
const override {
return PROTOCOL_COLD; };
103 bool has_ki_cold_sync()
const override {
return true; }
104 bool has_tx_cold_sign()
const override {
return true; }
106 void set_live_refresh_enabled(
bool enabled) { m_live_refresh_enabled = enabled; }
107 bool live_refresh_enabled()
const {
return m_live_refresh_enabled; }
123 std::shared_ptr<messages::monero::MoneroAddress>
get_address(
124 const boost::optional<cryptonote::subaddress_index> & subaddress = boost::none,
125 const boost::optional<crypto::hash8> & payment_id = boost::none,
126 bool show_address =
false,
127 const boost::optional<std::vector<uint32_t>> & path = boost::none,
128 const boost::optional<cryptonote::network_type> &
network_type = boost::none);
133 std::shared_ptr<messages::monero::MoneroWatchKey> get_view_key(
134 const boost::optional<std::vector<uint32_t>> & path = boost::none,
135 const boost::optional<cryptonote::network_type> &
network_type = boost::none);
140 bool is_get_tx_key_supported()
const override;
151 std::vector<::crypto::secret_key> & tx_keys,
152 const ::hw::device_cold::tx_key_data_t & tx_aux_data,
159 const std::vector<::tools::wallet2::transfer_details> & transfers,
162 bool is_live_refresh_supported()
const override;
164 bool is_live_refresh_enabled()
const;
166 bool has_ki_live_refresh()
const override;
168 void live_refresh_start()
override;
174 size_t real_output_index,
180 void live_refresh_finish()
override;
186 void computing_key_images(
bool started)
override;
192 bool compute_key_image(
193 const ::cryptonote::account_keys& ack,
196 size_t real_output_index,
197 const ::cryptonote::subaddress_index& received_index,
214 #endif //MONERO_DEVICE_TREZOR_H