Skip to content

Commit

Permalink
Merge pull request #229 from LedgerHQ/sw5515
Browse files Browse the repository at this point in the history
Handle 0x5515 status word in python client library
  • Loading branch information
bigspider authored Feb 22, 2024
2 parents fc8aacf + 594ecfb commit 4c95b0a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion bitcoin_client/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/**
dist/**
**/.venv
2 changes: 1 addition & 1 deletion bitcoin_client/ledger_bitcoin/client_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def sign_psbt(self, psbt: Union[PSBT, bytes, str], wallet: WalletPolicy, wallet_

all_signature_attempts[i_num] = signature_attempts

result: List[Tuple(int, PartialSignature)] = []
result: List[Tuple[int, PartialSignature]] = []

# Sign any segwit inputs
if has_segwit:
Expand Down
3 changes: 2 additions & 1 deletion bitcoin_client/ledger_bitcoin/exception/device_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

class DeviceException(Exception): # pylint: disable=too-few-public-methods
exc: Dict[int, Any] = {
0x5515: SecurityStatusNotSatisfiedError, # returned by sdk in recent versions
0x6985: DenyError,
0x6982: SecurityStatusNotSatisfiedError,
0x6982: SecurityStatusNotSatisfiedError, # used in older app versions
0x6A80: IncorrectDataError,
0x6A82: NotSupportedError,
0x6A86: WrongP1P2Error,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_status_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def test_status_word(sw_h_path):
expected_status_words: List[Tuple[str, int]] = parse_sw(sw_h_path)
status_words: Dict[int, Any] = DeviceException.exc

assert len(expected_status_words) == len(status_words), (
assert len(expected_status_words) == len(set(status_words.values())), (
f"{expected_status_words} doesn't match {status_words}")

# just keep status words
expected_status_words = [sw for (identifier, sw) in expected_status_words]

for sw in status_words.keys():
assert sw in expected_status_words, f"{status_words[sw]}({hex(sw)}) not found in sw.h!"
if sw != 0x5515: # this is the only one that is defined in the SDK
assert sw in expected_status_words, f"{status_words[sw]}({hex(sw)}) not found in sw.h!"

0 comments on commit 4c95b0a

Please sign in to comment.