diff --git a/remote-wallet/src/ledger.rs b/remote-wallet/src/ledger.rs index 671a6daf27..a0d0962eb8 100644 --- a/remote-wallet/src/ledger.rs +++ b/remote-wallet/src/ledger.rs @@ -12,6 +12,7 @@ const HARDENED_BIT: u32 = 1 << 31; const APDU_TAG: u8 = 0x05; const APDU_CLA: u8 = 0xe0; const APDU_PAYLOAD_HEADER_LEN: usize = 8; +const P1_NON_CONFIRM: u8 = 0x00; const P1_CONFIRM: u8 = 0x01; const P2_EXTEND: u8 = 0x01; const P2_MORE: u8 = 0x02; @@ -197,15 +198,15 @@ impl LedgerWallet { 0x6982 => Err(RemoteWalletError::Protocol( "Security status not satisfied (Canceled by user)", )), + 0x6985 => Err(RemoteWalletError::UserCancel), 0x6a80 => Err(RemoteWalletError::Protocol("Invalid data")), 0x6a82 => Err(RemoteWalletError::Protocol("File not found")), - 0x6a85 => Err(RemoteWalletError::UserCancel), 0x6b00 => Err(RemoteWalletError::Protocol("Incorrect parameters")), 0x6d00 => Err(RemoteWalletError::Protocol( "Not implemented. Make sure the Ledger Solana Wallet app is running.", )), 0x6faa => Err(RemoteWalletError::Protocol( - "Your Ledger needs to be unplugged", + "Your Ledger device needs to be unplugged", )), 0x6f00..=0x6fff => Err(RemoteWalletError::Protocol("Internal error")), 0x9000 => Ok(()), @@ -224,6 +225,9 @@ impl LedgerWallet { data: &[u8], ) -> Result, RemoteWalletError> { self.write(command, p1, p2, data)?; + if p1 == P1_CONFIRM { + println!("Waiting for remote wallet to approve..."); + } self.read() } @@ -279,7 +283,11 @@ impl RemoteWallet for LedgerWallet { let key = self.send_apdu( commands::GET_PUBKEY, - if confirm_key { 1 } else { 0 }, + if confirm_key { + P1_CONFIRM + } else { + P1_NON_CONFIRM + }, 0, &derivation_path, )?; diff --git a/remote-wallet/src/remote_wallet.rs b/remote-wallet/src/remote_wallet.rs index 991555b4f5..68c0aac3b8 100644 --- a/remote-wallet/src/remote_wallet.rs +++ b/remote-wallet/src/remote_wallet.rs @@ -47,7 +47,7 @@ pub enum RemoteWalletError { #[error("pubkey not found for given address")] PubkeyNotFound, - #[error("operation has been cancelled")] + #[error("remote wallet operation rejected by the user")] UserCancel, } @@ -62,7 +62,9 @@ impl From for SignerError { RemoteWalletError::InvalidInput(input) => SignerError::InvalidInput(input), RemoteWalletError::NoDeviceFound => SignerError::NoDeviceFound, RemoteWalletError::Protocol(e) => SignerError::Protocol(e.to_string()), - RemoteWalletError::UserCancel => SignerError::UserCancel, + RemoteWalletError::UserCancel => { + SignerError::UserCancel("remote wallet operation rejected by the user".to_string()) + } _ => SignerError::CustomError(err.to_string()), } } diff --git a/sdk/src/signature.rs b/sdk/src/signature.rs index 8f6dad2392..b7efb88b34 100644 --- a/sdk/src/signature.rs +++ b/sdk/src/signature.rs @@ -219,8 +219,8 @@ pub enum SignerError { #[error("device protocol error: {0}")] Protocol(String), - #[error("operation has been cancelled")] - UserCancel, + #[error("{0}")] + UserCancel(String), } #[derive(Clone, Debug, Default)]