30 #ifndef ELECTRONEUM_DEVICE_TREZOR_H 31 #define ELECTRONEUM_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> 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;
71 void transaction_pre_check(std::shared_ptr<messages::Electroneum::ElectroneumTransactionInitRequest> init_msg);
72 void transaction_check(
const protocol::tx::TData & tdata,
const hw::tx_aux_data & aux_data);
73 void device_state_reset_unsafe()
override;
74 void live_refresh_start_unsafe();
75 void live_refresh_finish_unsafe();
76 void live_refresh_thread_main();
85 std::shared_ptr<protocol::tx::Signer> & signer);
89 virtual ~device_trezor()
override;
91 device_trezor(
const device_trezor &device) = delete ;
92 device_trezor&
operator=(
const device_trezor &device) =
delete;
94 explicit operator bool()
const override {
return true;}
97 bool release()
override;
98 bool disconnect()
override;
100 device_protocol_t device_protocol()
const override {
return PROTOCOL_COLD; };
102 bool has_ki_cold_sync()
const override {
return true; }
103 bool has_tx_cold_sign()
const override {
return true; }
105 void set_live_refresh_enabled(
bool enabled) { m_live_refresh_enabled = enabled; }
106 bool live_refresh_enabled()
const {
return m_live_refresh_enabled; }
121 std::shared_ptr<messages::Electroneum::ElectroneumAddress>
get_address(
122 const boost::optional<std::vector<uint32_t>> & path = boost::none,
123 const boost::optional<cryptonote::network_type> &
network_type = boost::none);
128 std::shared_ptr<messages::Electroneum::ElectroneumWatchKey> get_view_key(
129 const boost::optional<std::vector<uint32_t>> & path = boost::none,
130 const boost::optional<cryptonote::network_type> &
network_type = boost::none);
135 bool is_get_tx_key_supported()
const override;
146 std::vector<::crypto::secret_key> & tx_keys,
147 const ::hw::device_cold::tx_key_data_t & tx_aux_data,
154 const std::vector<::tools::wallet2::transfer_details> & transfers,
157 bool is_live_refresh_supported()
const override;
159 bool is_live_refresh_enabled()
const;
161 bool has_ki_live_refresh()
const override;
163 void live_refresh_start()
override;
169 size_t real_output_index,
175 void live_refresh_finish()
override;
181 void computing_key_images(
bool started)
override;
187 bool compute_key_image(
188 const ::cryptonote::account_keys& ack,
191 size_t real_output_index,
192 const ::cryptonote::subaddress_index& received_index,
209 #endif //ELECTRONEUM_DEVICE_TREZOR_H
void register_all(std::map< std::string, std::unique_ptr< device >> ®istry)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
std::shared_ptr< messages::Electroneum::ElectroneumGetTxKeyRequest > get_tx_key(const hw::device_cold::tx_key_data_t &tx_data)
tools::wallet2::unsigned_tx_set unsigned_tx_set
void load_tx_key_data(hw::device_cold::tx_key_data_t &res, const std::string &data)
struct hw::wallet_shim wallet_shim
cryptonote::account_public_address get_address(const var_addr_t &inp)
connection< TProtocol > & operator=(const connection< TProtocol > &obj)
std::vector< std::pair< crypto::key_image, crypto::signature > > exported_key_image