Skip to content

Commit

Permalink
bug: Handle Ledger error 0x6804 (#87)
Browse files Browse the repository at this point in the history
If the Ledger is locked, don't panic, return an error instead.

Though this code doesn't appear to be officially documented anywhere,
I've seen it referred to as "unlock device error", and it consistently
appears while the ledger is locked.
  • Loading branch information
cloudhead authored Aug 23, 2021
1 parent d6bbef9 commit a6c2206
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ledger/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ pub enum APDUResponseCodes {
ExecutionError = 0x6400,
/// WrongLength
WrongLength = 0x6700,
/// UnlockDeviceError
UnlockDeviceError = 0x6804,
/// EmptyBuffer
EmptyBuffer = 0x6982,
/// OutputBufferTooSmall
Expand Down Expand Up @@ -231,6 +233,9 @@ impl APDUResponseCodes {
"[APDU_CODE_EXECUTION_ERROR] No information given (NV-Ram not changed)"
}
APDUResponseCodes::WrongLength => "[APDU_CODE_WRONG_LENGTH] Wrong length",
APDUResponseCodes::UnlockDeviceError => {
"[APDU_CODE_UNLOCK_DEVICE_ERROR] Device is locked"
}
APDUResponseCodes::EmptyBuffer => "[APDU_CODE_EMPTY_BUFFER]",
APDUResponseCodes::OutputBufferTooSmall => "[APDU_CODE_OUTPUT_BUFFER_TOO_SMALL]",
APDUResponseCodes::DataInvalid => {
Expand Down Expand Up @@ -264,6 +269,7 @@ impl From<u16> for APDUResponseCodes {
0x9000 => APDUResponseCodes::NoError,
0x6400 => APDUResponseCodes::ExecutionError,
0x6700 => APDUResponseCodes::WrongLength,
0x6804 => APDUResponseCodes::UnlockDeviceError,
0x6982 => APDUResponseCodes::EmptyBuffer,
0x6983 => APDUResponseCodes::OutputBufferTooSmall,
0x6984 => APDUResponseCodes::DataInvalid,
Expand Down

0 comments on commit a6c2206

Please sign in to comment.