[bugfix] DecodeQR
: handle Compact SeedQR byte data that can be decoded to str
#657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #656
The bug
The QR decoder (decode_qr.py) starts by interpreting QR data as
str
as it tries to figure out the QR format that was just scanned (e.g. animated psbt, address to verify, SeedQR, etc). In most cases, Compact SeedQR byte data will fail the conversion tostr
(raisesUnicodeDecodeError
; all good, we expect that) and the code will carry on to its next step where it assumes the data is still inbytes
format.But in the edge cases where the Compact SeedQR byte data CAN be converted to
str
(e.g. "abandon" x11 + "about" as reported in #656), the successful conversion tostr
then runs into errors in the Compact SeedQR decoding: the data isn'tbytes
, it'sstr
at this point, and so the byte manipulation code errors out. The error is caught and the decoder reports the Compact SeedQR as invalid (even though it IS actually valid).The fix
This PR simply checks and ensures that the data is in
bytes
format before the Compact SeedQR processing begins.TODO: Longer term, the conversion to
str
should be eliminated altogether. But that approach was NOT taken in this PR in order to minimize the impact of this PR and minimize the amount of testing needed.str
.Testing
12-word Compact SeedQR that will fail with
dev
but succeed with this PR:And a 24-word Compact SeedQR:
This pull request is categorized as a:
Checklist
pytest
and made sure all unit tests pass before sumbitting the PRIf you modified or added functionality/workflow, did you add new unit tests?
I have tested this PR on the following platforms/os: