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();
71 void transaction_versions_check(const ::tools::wallet2::unsigned_tx_set & unsigned_tx, hw::tx_aux_data & aux_data);
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();
83 const ::tools::wallet2::unsigned_tx_set & unsigned_tx,
85 hw::tx_aux_data & aux_data,
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;}
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; }
112 bool get_public_address(cryptonote::account_public_address &pubkey)
override;
114 void display_address(
const cryptonote::subaddress_index& index,
const boost::optional<crypto::hash8> &payment_id)
override;
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;
145 void load_tx_key_data(::hw::device_cold::tx_key_data_t &
res,
const std::string & tx_aux_data)
override;
151 std::vector<::crypto::secret_key> & tx_keys,
152 const ::hw::device_cold::tx_key_data_t & tx_aux_data,
153 const ::crypto::secret_key & view_key_priv)
override;
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;
171 const ::crypto::secret_key & view_key_priv,
174 size_t real_output_index,
175 const cryptonote::subaddress_index& received_index,
176 cryptonote::keypair& in_ephemeral,
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,
194 const ::crypto::public_key& out_key,
195 const ::crypto::key_derivation& recv_derivation,
196 size_t real_output_index,
197 const ::cryptonote::subaddress_index& received_index,
198 ::cryptonote::keypair& in_ephemeral,
205 const ::tools::wallet2::unsigned_tx_set & unsigned_tx,
206 ::tools::wallet2::signed_tx_set & signed_tx,
207 hw::tx_aux_data & aux_data)
override;
212 bool get_public_address_with_no_passphrase(cryptonote::account_public_address &pubkey)
override;
217 virtual void reset_session()
override;
222 bool seen_passphrase_entry_prompt()
override;
227 void set_use_empty_passphrase(
bool use_always_empty_passphrase)
override;
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition chaingen.cpp:817
std::vector< std::pair< crypto::key_image, crypto::signature > > exported_key_image
Definition device_cold.hpp:56
crypto::secret_key spendkey
Definition cold-outputs.cpp:44
const char * res
Definition hmac_keccak.cpp:42
static void init()
Definition logging.cpp:42
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:72
POD_CLASS key_derivation
Definition crypto.h:91
POD_CLASS public_key
Definition crypto.h:64
POD_CLASS key_image
Definition crypto.h:95
int bool
Definition hash.h:36
network_type
Definition cryptonote_config.h:302
void load_tx_key_data(hw::device_cold::tx_key_data_t &res, const std::string &data)
Definition protocol.cpp:1022
std::shared_ptr< messages::monero::MoneroGetTxKeyRequest > get_tx_key(const hw::device_cold::tx_key_data_t &tx_data)
Definition protocol.cpp:1053
Definition device_trezor.cpp:35
void register_all()
Definition device_trezor.cpp:779
struct hw::wallet_shim wallet_shim
release(ctx, str device, version, git_tag, release_missing, dry_run, soon, force, add_all, verbose)
Definition support.py:316