Skip to content

Add UR decoding capability to scanners on desktop & Android#10518

Open
hectorchu wants to merge 2 commits intospesmilo:masterfrom
ltc-electrum:ur_scanner
Open

Add UR decoding capability to scanners on desktop & Android#10518
hectorchu wants to merge 2 commits intospesmilo:masterfrom
ltc-electrum:ur_scanner

Conversation

@hectorchu
Copy link

As title. Only decoding - no encoding was added.

@SomberNight
Copy link
Member

(ref #7905)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the qtmultimedia toolchain is only used on Windows and macOS. Desktop Linux uses zbar.
But perhaps this is something we should reconsider.
See comment here:

# We have two toolchains to scan qr codes:
# 1. access camera via QtMultimedia, take picture, feed picture to zbar
# 2. let zbar handle whole flow (including accessing the camera)
#
# notes:
# - zbar needs to be compiled with platform-dependent extra config options to be able
# to access the camera
# - zbar fails to access the camera on macOS
# - qtmultimedia seems to support more cameras on Windows than zbar
# - qtmultimedia is often not packaged with PyQt
# in particular, on debian, you need both "python3-pyqt6" and "python3-pyqt6.qtmultimedia"
# - older versions of qtmultimedia don't seem to work reliably
#
# Considering the above, we use QtMultimedia for Windows and macOS, as there
# most users run our binaries where we can make sure the packaged versions work well.
# On Linux where many people run from source, we use zbar.

Copy link
Member

@SomberNight SomberNight Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this. It looks like a solid start.
Would you be interested in adding also the encode/display qr code parts to the GUIs?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the encoding change for QRCodeWidget, but it currently generates the parts upfront, and then these are passed to the QRCodeWidget which then cycles them. But this was only for compatibility with Cake Wallet, which makes the assumption there are n-fixed parts. UR codes are actually intended to be used as a fountain code. See the description I wrote up here.

So I would take this change, but instead the QRCodeWidget should accept the data string and an argument encode_ur, if the latter is True then use a UREncoder to generate a new part on every refresh. These changes aren't difficult and I doubt they are difficult for the Android one also, but I haven't looked at the Android code. Could you do it?

Copy link
Author

@hectorchu hectorchu Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the QRCodeWidget should just accept a UR|str, because a UR also includes a type, and it would be better for all that to be created by the caller.
The widget creates encoder = UREncoder(ur), then the widget would just call encoder.next_part() per refresh.

@pony-montana
Copy link

HI! Here just to signal two python projects that implements these feature, hoping it could be useful :)

SeedQReader
bitcoin-qr-tools

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.

3 participants