mirror of
https://github.com/monero-project/monero.git
synced 2025-08-21 16:08:19 -04:00
device: proper handling of user input
(1) If the user denies something on the Ledger, a proper error message is now shown. (2) Ledger doesn't time out anymore while waiting on user input. (3) Lower the timeout to 2 seconds, this is enough for normal Ledger <-> System communication.
This commit is contained in:
parent
094b0c4d00
commit
6c060e6aaa
5 changed files with 43 additions and 9 deletions
|
@ -148,7 +148,7 @@ namespace hw {
|
|||
return this->usb_device != NULL;
|
||||
}
|
||||
|
||||
int device_io_hid::exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len) {
|
||||
int device_io_hid::exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len, bool user_input) {
|
||||
unsigned char buffer[400];
|
||||
unsigned char padding_buffer[MAX_BLOCK+1];
|
||||
unsigned int result;
|
||||
|
@ -177,7 +177,11 @@ namespace hw {
|
|||
|
||||
//get first response
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
hid_ret = hid_read_timeout(this->usb_device, buffer, MAX_BLOCK, this->timeout);
|
||||
if (!user_input) {
|
||||
hid_ret = hid_read_timeout(this->usb_device, buffer, MAX_BLOCK, this->timeout);
|
||||
} else {
|
||||
hid_ret = hid_read(this->usb_device, buffer, MAX_BLOCK);
|
||||
}
|
||||
ASSERT_X(hid_ret>=0, "Unable to read hidapi response. Error "+std::to_string(result)+": "+ safe_hid_error(this->usb_device));
|
||||
result = (unsigned int)hid_ret;
|
||||
io_hid_log(1, buffer, result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue