Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handle for Ledger devices #718

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

brunoerg
Copy link
Contributor

Discovered it while reviewing #bitcoin/24313. The ledger_exception function was not dealing with ApduException exceptions. It's basically similar to BTChipException and we can use its "error code" to return friendly error messages.

e.g for displayaddress:

before:
{"error": "Exception: invalid status 0x6985", "code": -13}
after:
{"error": "display_singlesig_address canceled", "code": -14}

@brunoerg
Copy link
Contributor Author

cc: @Sjors

@Sjors
Copy link
Member

Sjors commented Dec 27, 2023

@bigspider is there a complete list of (Bitcoin app) error codes published somewhere?

@bigspider
Copy link
Contributor

@bigspider is there a complete list of (Bitcoin app) error codes published somewhere?

This mapping is currently as good as it gets. The IncorrectDataError (SW 0x6A80) is the most common error and it's returned for way too many distinct error situations; hopefully I find some time to improve it with more fine-grained error results.

@achow101
Copy link
Member

ACK 0d5412a

@achow101 achow101 merged commit 59eeb85 into bitcoin-core:master Jan 17, 2024
253 of 255 checks passed
@Sjors
Copy link
Member

Sjors commented Feb 16, 2024

0x5515 is what I get when the app is in screensaver mode (Ledger Nano X, BTC app 2.1.3)

@bigspider
Copy link
Contributor

0x5515 is what I get when the app is in screensaver mode (Ledger Nano X, BTC app 2.1.3)

Indeed, that situation used to be managed by the app directly, while now it's handled in the app sdk, so the error code changed. I'll add the error code to the client libraries, thanks!

@brunoerg brunoerg deleted the 2023-12-fix-ledger-errors branch September 2, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants