-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add bitcoin address label to request payment QR code #7636
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
Add bitcoin address label to request payment QR code #7636
Conversation
|
Haven't looked at the code, but screenshot looks good to me, nice work. |
|
Thanks! Having a malicious QRCode can probably only happen if you system, Bitcoin-Core or at least libqrencode is compromise. Your PR would only protect from an attack on libqrencode and only if the user uses a self-compiled Bitcoin-Core (official binaries are static linked). Because, if you could tamper Bitcoin-Core, you could change the address at a core point which would also provide a malicious address below the QRCode. This change would def. make sense if we would have HD for key derivation. IMO this PR does not hurt, although I don't believe that it increases security. UtACK. |
If anything at the printer side is compromised, you're out of luck. But what about a malicious QR code reader? I think it could help there, comparing the address before accepting the transaction in your wallet. |
|
Right, I think it makes sense to have a human readable version of the QR code besides it. Concept ACK. |
|
Yes. I just thought people could already do this because they have the address below the QRCode already. But this PR makes it more prominent available. |
src/qt/receiverequestdialog.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QRCodes should not use anti-aliasing (QT::SmoothTransformation). I guess this should be removed.
|
I removed the anti-aliasing (I should I've imagined that it was bad for qr code scanning) and now it shouldn't have that blurring problem on OSX as it uses the same size as the size it's using to display it ( The only thing that's changed now is the export size, the final image is 44 pixel larger for each dimension. The good thing that is now I can reuse the constant I can squash the three commits to a single one and force push to this branch when needed. |
|
One new warning generated: |
|
So now the window displays the address twice? Maybe just add it to the image when it's being saved...? |
|
@luke-jr If displayed properly, the address is displayed four times! Title bar, image, bitcoin: URL and address. 8) |
src/qt/receiverequestdialog.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a QFont::setPointSize() here to avoid HiDPI differences?
Well at least people can't complain they're missing the address :-) |
|
One thing I do wonder about though: do QR scanners need an empty (white) border around a QR code? If so, how large should it be? |
|
@laanwj: I recently played around with max QR size/bytes, black/white (inverted) and the white-space-border. I could not find any specification about the "quite zone" (white border), but I guess "one square width" as min border size should be more as sufficient. I guess it depends on the QRCode reader implementation. But I could not read the QRCode with common readers if there where no white borders. |
|
Scanners don't need a border I believe, but printers may.
|
|
Seems I misremembered. Some googling shows that the spec actually includes
a quiet zone around the QR code, 4 modules wide, with the same color as the
white modules.
|
src/qt/receiverequestdialog.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some clever rule to detect the width of the text we want to draw – and make it bigger if there is more horizontal space?
Get width:
QFontMetrics fm(painter.font());
int pixelsWide = fm.width(info.address);|
ping @makevoid: I think this PR is almost ready. We just need a way that the font size respects the screen density (HiDPI). |
|
ping @makevoid |
I'd say no because this is exported to an image file. We don't want the output to be dependent on the user's screen resolution. |
|
@laanwj: check #7636 (comment) I can take care about this and finish this PR. |
|
Sorry but I don't have an HiDPI screen to test with yet, is there anything I can do? should I squash the commits? |
Just a matter of misunderstanding / wrong formulation then - what we want here is to use a font size that is fixed in pixel size, just like the QR code itself is. |
|
The QRCode is not rendered HiDPI (not required). Setting the font size in pixel works (because the size of the Here's the diff. diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp
index 1e104bb..b81a039 100644
--- a/src/qt/receiverequestdialog.cpp
+++ b/src/qt/receiverequestdialog.cpp
@@ -183,7 +183,9 @@ void ReceiveRequestDialog::update()
qrAddrImage.fill(0xffffff);
QPainter painter(&qrAddrImage);
painter.drawImage(0, 0, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));
- painter.setFont(QFont(GUIUtil::fixedPitchFont().toString(), 8));
+ QFont font = QFont(GUIUtil::fixedPitchFont().toString());
+ font.setPixelSize(12);
+ painter.setFont(font);
QRect paddedRect = qrAddrImage.rect();
paddedRect.setHeight(QR_IMAGE_SIZE+12);
painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter, info.address); |
fixedPitchFont() already returns QFont. Is this odd constructor necessary? |
|
@MarcoFalke: Oh yes. |
In the Receive 'Tab' of the QT wallet, when 'Show'ing a previously requested payment, add a label underneath the QR Code showing the bitcoin address where the funds will go to. This way the user can be sure that the QR code scanner app the user using is reading the correct bitcoin address, preventing funds to be stolen. Includes fix for HiDPI screens by @jonasschnelli.
54a1eff to
1c2a1ba
Compare
|
utACK 1c2a1ba |
|
Tested ACK 1c2a1ba. Looks also good on Win(10). |
1c2a1ba Add address label to request payment QR Code (QT) (Francesco 'makevoid' Canessa)
1c2a1ba Add address label to request payment QR Code (QT) (Francesco 'makevoid' Canessa)
1c2a1ba Add address label to request payment QR Code (QT) (Francesco 'makevoid' Canessa)










This is a change for the QT wallet
Why this change?
This way the user can be sure that the QR code scanner app he/she's using is not displaying a different address to maliciously steal the funds.
I've seen an android app in the wild that is a simple qr code scanner but when it scans a bitcoin address it replaces it with a different address belonging to the hacker. I'm starting to get worried of bitcoin address qr codes without a label that states the address in clear so that the user can always check that he/she is depositing the funds to the desired address.
That's why I decided to modify the bitcoin qt code.
Code changes: