electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1825c92bbc873f23167eb72a4dc29127f346c7a5
parent 5e7c1330d4d3d0bad0745cd897c05f9ffafd70ee
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 23 Feb 2018 19:20:18 +0100

Merge pull request #3874 from SomberNight/zbar_windows

zbar for windows
Diffstat:
Mcontrib/build-wine/deterministic.spec | 1+
Mcontrib/build-wine/prepare-wine.sh | 8++++++--
Mlib/qrscanner.py | 10+++++++---
3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/contrib/build-wine/deterministic.spec b/contrib/build-wine/deterministic.spec @@ -34,6 +34,7 @@ datas = [ (home+'lib/wordlist/english.txt', 'electrum/wordlist'), (home+'lib/locale', 'electrum/locale'), (home+'plugins', 'electrum_plugins'), + ('C:\\Program Files (x86)\\ZBar\\bin\\', '.') ] datas += collect_data_files('trezorlib') datas += collect_data_files('btchip') diff --git a/contrib/build-wine/prepare-wine.sh b/contrib/build-wine/prepare-wine.sh @@ -4,6 +4,9 @@ NSIS_URL=https://prdownloads.sourceforge.net/nsis/nsis-3.02.1-setup.exe?download NSIS_SHA256=736c9062a02e297e335f82252e648a883171c98e0d5120439f538c81d429552e +ZBAR_URL=https://sourceforge.net/projects/zbarw/files/zbarw-20121031-setup.exe/download +ZBAR_SHA256=177e32b272fa76528a3af486b74e9cb356707be1c5ace4ed3fcee9723e2c2c02 + LIBUSB_URL=https://prdownloads.sourceforge.net/project/libusb/libusb-1.0/libusb-1.0.21/libusb-1.0.21.7z?download LIBUSB_SHA256=acdde63a40b1477898aee6153f9d91d1a2e8a5d93f832ca8ab876498f3a6d2b8 @@ -88,8 +91,9 @@ $PYTHON -m pip install -r ../../deterministic-build/requirements-binaries.txt $PYTHON -m pip install https://github.com/ecdsa/pyinstaller/archive/fix_2952.zip # Install ZBar -#wget -q -O zbar.exe "https://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download" -#wine zbar.exe +wget -q -O zbar.exe "$ZBAR_URL" +verify_hash zbar.exe $ZBAR_SHA256 +wine zbar.exe /S # Upgrade setuptools (so Electrum can be installed later) diff --git a/lib/qrscanner.py b/lib/qrscanner.py @@ -29,8 +29,8 @@ import ctypes if sys.platform == 'darwin': name = 'libzbar.dylib' -elif sys.platform == 'windows': - name = 'libzbar.dll' +elif sys.platform in ('windows', 'win32'): + name = 'libzbar-0.dll' else: name = 'libzbar.so.0' @@ -40,7 +40,7 @@ except OSError: libzbar = None -def scan_barcode(device='', timeout=-1, display=True, threaded=False): +def scan_barcode(device='', timeout=-1, display=True, threaded=False, try_again=True): if libzbar is None: raise RuntimeError("Cannot start QR scanner; zbar not available.") libzbar.zbar_symbol_get_data.restype = ctypes.c_char_p @@ -50,6 +50,10 @@ def scan_barcode(device='', timeout=-1, display=True, threaded=False): proc = libzbar.zbar_processor_create(threaded) libzbar.zbar_processor_request_size(proc, 640, 480) if libzbar.zbar_processor_init(proc, device.encode('utf-8'), display) != 0: + if try_again: + # workaround for a bug in "ZBar for Windows" + # libzbar.zbar_processor_init always seem to fail the first time around + return scan_barcode(device, timeout, display, threaded, try_again=False) raise RuntimeError("Can not start QR scanner; initialization failed.") libzbar.zbar_processor_set_visible(proc) if libzbar.zbar_process_one(proc, timeout):