From dff8242887d2f374d862386c46fe56e34925255f Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Thu, 3 Sep 2020 13:14:22 -0600 Subject: [PATCH] Don't query modern Ledger wallet app version with deprecated payload size --- remote-wallet/src/ledger.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/remote-wallet/src/ledger.rs b/remote-wallet/src/ledger.rs index 8f512d22d..db7a3f812 100644 --- a/remote-wallet/src/ledger.rs +++ b/remote-wallet/src/ledger.rs @@ -241,14 +241,15 @@ impl LedgerWallet { Ok(message) } - fn send_apdu( + fn _send_apdu( &self, command: u8, p1: u8, p2: u8, data: &[u8], + outdated_app: bool, ) -> Result, RemoteWalletError> { - self.write(command, p1, p2, data, self.outdated_app())?; + self.write(command, p1, p2, data, outdated_app)?; if p1 == P1_CONFIRM && is_last_part(p2) { println!( "Waiting for your approval on {} {}", @@ -263,8 +264,18 @@ impl LedgerWallet { } } + fn send_apdu( + &self, + command: u8, + p1: u8, + p2: u8, + data: &[u8], + ) -> Result, RemoteWalletError> { + self._send_apdu(command, p1, p2, data, self.outdated_app()) + } + fn get_firmware_version(&self) -> Result { - if let Ok(version) = self.send_apdu(commands::GET_APP_CONFIGURATION, 0, 0, &[]) { + if let Ok(version) = self._send_apdu(commands::GET_APP_CONFIGURATION, 0, 0, &[], false) { if version.len() != 5 { return Err(RemoteWalletError::Protocol("Version packet size mismatch")); } @@ -274,7 +285,8 @@ impl LedgerWallet { version[4].into(), )) } else { - let version = self.send_apdu(commands::DEPRECATED_GET_APP_CONFIGURATION, 0, 0, &[])?; + let version = + self._send_apdu(commands::DEPRECATED_GET_APP_CONFIGURATION, 0, 0, &[], true)?; if version.len() != 4 { return Err(RemoteWalletError::Protocol("Version packet size mismatch")); }