From b8c7edf0702c17f4d411da72438f1bec19c6f18d Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 22 Oct 2017 12:04:00 +0200 Subject: [PATCH] return bytes in scan_barcode --- gui/qt/main_window.py | 7 ++----- gui/qt/qrtextedit.py | 3 +-- lib/qrscanner.py | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 9dc8730dc..67cfdaddd 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -2056,14 +2056,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): if not data: return # if the user scanned a bitcoin URI - if data.startswith("bitcoin:"): + if str(data).startswith("bitcoin:"): self.pay_to_URI(data) return # else if the user scanned an offline signed tx - # transactions are binary, but qrcode seems to return utf-8... - data = data.decode('utf-8') - z = bitcoin.base_decode(data, length=None, base=43) - data = bh2u(''.join(chr(ord(b)) for b in z)) + data = bh2u(bitcoin.base_decode(data, length=None, base=43)) tx = self.tx_from_text(data) if not tx: return diff --git a/gui/qt/qrtextedit.py b/gui/qt/qrtextedit.py index a83f30510..8f452a882 100644 --- a/gui/qt/qrtextedit.py +++ b/gui/qt/qrtextedit.py @@ -61,8 +61,7 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin): except BaseException as e: self.show_error(str(e)) data = '' - if type(data) != str: - data = '' + data = str(data) self.setText(data) return data diff --git a/lib/qrscanner.py b/lib/qrscanner.py index 249154123..c0af98ce4 100644 --- a/lib/qrscanner.py +++ b/lib/qrscanner.py @@ -62,7 +62,7 @@ def scan_barcode(device='', timeout=-1, display=True, threaded=False): return symbol = libzbar.zbar_symbol_set_first_symbol(symbols) data = libzbar.zbar_symbol_get_data(symbol) - return str(data) + return data def _find_system_cameras(): device_root = "/sys/class/video4linux"