From 11ae481752223265cc07bd937b8f5f9933bd5378 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:41:03 +0100 Subject: [PATCH 1/4] Add .venv folders to .gitignore --- bitcoin_client/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitcoin_client/.gitignore b/bitcoin_client/.gitignore index 0021b4fb3..108413e8c 100644 --- a/bitcoin_client/.gitignore +++ b/bitcoin_client/.gitignore @@ -1 +1,2 @@ -dist/** \ No newline at end of file +dist/** +**/.venv From 2e9ea2a204451e334c4af6360aad264c88593f51 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:41:23 +0100 Subject: [PATCH 2/4] Fix wrong type annotation --- bitcoin_client/ledger_bitcoin/client_legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin_client/ledger_bitcoin/client_legacy.py b/bitcoin_client/ledger_bitcoin/client_legacy.py index f5d45f366..1f21a922a 100644 --- a/bitcoin_client/ledger_bitcoin/client_legacy.py +++ b/bitcoin_client/ledger_bitcoin/client_legacy.py @@ -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: From 729b07fce2369baf47f457d7aa7b7197d089c862 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:07:08 +0100 Subject: [PATCH 3/4] Map both 0x5515 0x6982 to SecurityStatusNotSatisfiedError --- bitcoin_client/ledger_bitcoin/exception/device_exception.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitcoin_client/ledger_bitcoin/exception/device_exception.py b/bitcoin_client/ledger_bitcoin/exception/device_exception.py index 63c2333fd..7596420ad 100644 --- a/bitcoin_client/ledger_bitcoin/exception/device_exception.py +++ b/bitcoin_client/ledger_bitcoin/exception/device_exception.py @@ -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, From 594ecfbf79536d5ccb236c36239000108f4bb711 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Mon, 19 Feb 2024 10:29:33 +0100 Subject: [PATCH 4/4] Fix test on the status words --- tests/test_status_word.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_status_word.py b/tests/test_status_word.py index 5af1b3908..22916b194 100644 --- a/tests/test_status_word.py +++ b/tests/test_status_word.py @@ -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!"