aboutsummaryrefslogtreecommitdiff
path: root/src/device_trezor/device_trezor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/device_trezor/device_trezor.cpp')
-rw-r--r--src/device_trezor/device_trezor.cpp63
1 files changed, 39 insertions, 24 deletions
diff --git a/src/device_trezor/device_trezor.cpp b/src/device_trezor/device_trezor.cpp
index a77f6697f..8bde1cb75 100644
--- a/src/device_trezor/device_trezor.cpp
+++ b/src/device_trezor/device_trezor.cpp
@@ -101,7 +101,7 @@ namespace trezor {
return device_trezor_base::disconnect();
}
- void device_trezor::device_state_reset_unsafe()
+ void device_trezor::device_state_initialize_unsafe()
{
require_connected();
if (m_live_refresh_in_progress)
@@ -117,7 +117,7 @@ namespace trezor {
}
m_live_refresh_in_progress = false;
- device_trezor_base::device_state_reset_unsafe();
+ device_trezor_base::device_state_initialize_unsafe();
}
void device_trezor::live_refresh_thread_main()
@@ -221,7 +221,7 @@ namespace trezor {
CHECK_AND_ASSERT_THROW_MES(!payment_id || !subaddress || subaddress->is_zero(), "Subaddress cannot be integrated");
TREZOR_AUTO_LOCK_CMD();
require_connected();
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
auto req = std::make_shared<messages::monero::MoneroGetAddress>();
@@ -245,7 +245,7 @@ namespace trezor {
const boost::optional<cryptonote::network_type> & network_type){
TREZOR_AUTO_LOCK_CMD();
require_connected();
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
auto req = std::make_shared<messages::monero::MoneroGetWatchKey>();
@@ -274,7 +274,7 @@ namespace trezor {
{
TREZOR_AUTO_LOCK_CMD();
require_connected();
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
auto req = protocol::tx::get_tx_key(tx_aux_data);
@@ -294,15 +294,15 @@ namespace trezor {
TREZOR_AUTO_LOCK_CMD();
require_connected();
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
std::shared_ptr<messages::monero::MoneroKeyImageExportInitRequest> req;
std::vector<protocol::ki::MoneroTransferDetails> mtds;
std::vector<protocol::ki::MoneroExportedKeyImage> kis;
- protocol::ki::key_image_data(wallet, transfers, mtds);
- protocol::ki::generate_commitment(mtds, transfers, req);
+ protocol::ki::key_image_data(wallet, transfers, mtds, client_version() <= 1);
+ protocol::ki::generate_commitment(mtds, transfers, req, client_version() <= 1);
EVENT_PROGRESS(0.);
this->set_msg_addr<messages::monero::MoneroKeyImageExportInitRequest>(req.get());
@@ -386,7 +386,7 @@ namespace trezor {
void device_trezor::live_refresh_start_unsafe()
{
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
auto req = std::make_shared<messages::monero::MoneroLiveRefreshStartRequest>();
@@ -492,7 +492,7 @@ namespace trezor {
TREZOR_AUTO_LOCK_CMD();
require_connected();
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
transaction_versions_check(unsigned_tx, aux_data);
@@ -514,7 +514,7 @@ namespace trezor {
auto & cpend = signed_tx.ptx.back();
cpend.tx = cdata.tx;
cpend.dust = 0;
- cpend.fee = 0;
+ cpend.fee = cpend.tx.rct_signatures.txnFee;
cpend.dust_added_to_fee = false;
cpend.change_dts = cdata.tx_data.change_dts;
cpend.selected_transfers = cdata.tx_data.selected_transfers;
@@ -524,6 +524,7 @@ namespace trezor {
// Transaction check
try {
+ MDEBUG("signed transaction: " << cryptonote::get_transaction_hash(cpend.tx) << ENDL << cryptonote::obj_to_json_str(cpend.tx) << ENDL);
transaction_check(cdata, aux_data);
} catch(const std::exception &e){
throw exc::ProtocolException(std::string("Transaction verification failed: ") + e.what());
@@ -582,7 +583,7 @@ namespace trezor {
require_connected();
if (idx > 0)
- device_state_reset_unsafe();
+ device_state_initialize_unsafe();
require_initialized();
EVENT_PROGRESS(0, 1, 1);
@@ -670,28 +671,42 @@ namespace trezor {
#undef EVENT_PROGRESS
}
- void device_trezor::transaction_versions_check(const ::tools::wallet2::unsigned_tx_set & unsigned_tx, hw::tx_aux_data & aux_data)
+ unsigned device_trezor::client_version()
{
auto trezor_version = get_version();
- unsigned client_version = 1; // default client version for tx
-
if (trezor_version <= pack_version(2, 0, 10)){
- client_version = 0;
+ throw exc::TrezorException("Trezor firmware 2.0.10 and lower are not supported. Please update.");
}
+ // default client version, higher versions check will be added
+ unsigned client_version = 1;
+
+#ifdef WITH_TREZOR_DEBUGGING
+ // Override client version for tests
+ const char *env_trezor_client_version = nullptr;
+ if ((env_trezor_client_version = getenv("TREZOR_CLIENT_VERSION")) != nullptr){
+ auto succ = epee::string_tools::get_xtype_from_string(client_version, env_trezor_client_version);
+ if (succ){
+ MINFO("Trezor client version overriden by TREZOR_CLIENT_VERSION to: " << client_version);
+ }
+ }
+#endif
+ return client_version;
+ }
+
+ void device_trezor::transaction_versions_check(const ::tools::wallet2::unsigned_tx_set & unsigned_tx, hw::tx_aux_data & aux_data)
+ {
+ unsigned cversion = client_version();
+
if (aux_data.client_version){
auto wanted_client_version = aux_data.client_version.get();
- if (wanted_client_version > client_version){
- throw exc::TrezorException("Trezor firmware 2.0.10 and lower does not support current transaction sign protocol. Please update.");
+ if (wanted_client_version > cversion){
+ throw exc::TrezorException("Trezor has too old firmware version. Please update.");
} else {
- client_version = wanted_client_version;
+ cversion = wanted_client_version;
}
}
- aux_data.client_version = client_version;
-
- if (client_version == 0 && aux_data.bp_version && aux_data.bp_version.get() != 1){
- throw exc::TrezorException("Trezor firmware 2.0.10 and lower does not support current transaction sign protocol (BPv2+). Please update.");
- }
+ aux_data.client_version = cversion;
}
void device_trezor::transaction_pre_check(std::shared_ptr<messages::monero::MoneroTransactionInitRequest> init_msg)