aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_ledger.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-08-26 21:10:56 -0400
committerluigi1111 <luigi1111w@gmail.com>2021-08-26 21:10:56 -0400
commitd98787eb1ba9363bb0eeb73107626ea38bc0e552 (patch)
treec28f009f5f35d773002a62dc9698acd5544ad8b7 /src/device/device_ledger.cpp
parentMerge pull request #7822 (diff)
parentcmake: test is a reserved keyword (diff)
downloadmonero-d98787eb1ba9363bb0eeb73107626ea38bc0e552.tar.xz
Merge pull request #7825
ccfed60 cmake: test is a reserved keyword (selsta) f0fa959 cmake: fix ccache detection (anon) 8dbe2e5 Daemon: Update average block size table (rbrunner7) 94bad34 wallet2: Don't auto lock device on process parsed blocks (tobtoht) 3c23aca ledger: don't lock for software device (tobtoht) 49beb8d ledger: use software device if we have view key (tobtoht) d188b5f wallet_api: getPassword (tobtoht) a395f36 depends, docker: fix bintray links (selsta) 0fecd7e blocks: fix cmake syntax (selsta) 76824bf Stop adding more outputs than bulletproof allows (Alex Opie) 67ba733 unit_tests: fix wipeable_string parse_hexstr test with latest gtest (xiphon) 402ba04 cmake: use CMAKE_CURRENT_LIST_DIR in FindLibUSB (selsta) 1565bcb epee: include public openssl header in cmake (selsta) 2e9af2a cmake: treat warnings as error in compiler flag tests (selsta) db564ef wallet_api: fix typo in exportKeyImages (selsta) 8507917 depends: add getmonero package mirror (selsta) 8716d2a cmake: fix non portable code (selsta)
Diffstat (limited to 'src/device/device_ledger.cpp')
-rw-r--r--src/device/device_ledger.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp
index 3e0afeb65..f83ed1e48 100644
--- a/src/device/device_ledger.cpp
+++ b/src/device/device_ledger.cpp
@@ -529,9 +529,7 @@ namespace hw {
}
bool device_ledger::init(void) {
- #ifdef DEBUG_HWDEVICE
this->controle_device = &hw::get_device("default");
- #endif
this->release();
hw_device.init();
MDEBUG( "Device "<<this->id <<" HIDUSB inited");
@@ -697,7 +695,6 @@ namespace hw {
/* ======================================================================= */
bool device_ledger::derive_subaddress_public_key(const crypto::public_key &pub, const crypto::key_derivation &derivation, const std::size_t output_index, crypto::public_key &derived_pub){
- AUTO_LOCK_CMD();
#ifdef DEBUG_HWDEVICE
const crypto::public_key pub_x = pub;
crypto::key_derivation derivation_x;
@@ -721,7 +718,7 @@ namespace hw {
MDEBUG( "derive_subaddress_public_key : PARSE mode with known viewkey");
crypto::derive_subaddress_public_key(pub, derivation, output_index,derived_pub);
} else {
-
+ AUTO_LOCK_CMD();
int offset = set_command_header_noopt(INS_DERIVE_SUBADDRESS_PUBLIC_KEY);
//pub
memmove(this->buffer_send+offset, pub.data, 32);
@@ -750,6 +747,12 @@ namespace hw {
}
crypto::public_key device_ledger::get_subaddress_spend_public_key(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) {
+ if (has_view_key) {
+ cryptonote::account_keys keys_{keys};
+ keys_.m_view_secret_key = this->viewkey;
+ return this->controle_device->get_subaddress_spend_public_key(keys_, index);
+ }
+
AUTO_LOCK_CMD();
crypto::public_key D;
@@ -801,6 +804,12 @@ namespace hw {
}
cryptonote::account_public_address device_ledger::get_subaddress(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) {
+ if (has_view_key) {
+ cryptonote::account_keys keys_{keys};
+ keys_.m_view_secret_key = this->viewkey;
+ return this->controle_device->get_subaddress(keys_, index);
+ }
+
AUTO_LOCK_CMD();
cryptonote::account_public_address address;
@@ -1049,7 +1058,6 @@ namespace hw {
}
bool device_ledger::generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) {
- AUTO_LOCK_CMD();
bool r = false;
#ifdef DEBUG_HWDEVICE
@@ -1070,6 +1078,7 @@ namespace hw {
assert(is_fake_view_key(sec));
r = crypto::generate_key_derivation(pub, this->viewkey, derivation);
} else {
+ AUTO_LOCK_CMD();
int offset = set_command_header_noopt(INS_GEN_KEY_DERIVATION);
//pub
memmove(this->buffer_send+offset, pub.data, 32);