electrum

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

commit 322d1bd1d0debe15e5ea06efc9e8e532eab21e6d
parent 4a40b3a0b2522e6adad58631eba4f57341907d44
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 12 Jan 2018 10:37:32 +0100

Merge branch 'master' of github.com:spesmilo/electrum

Diffstat:
Mgui/qt/main_window.py | 19++++++++++++++++---
Mplugins/ledger/ledger.py | 17++++++++++++++++-
2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -2269,25 +2269,38 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): private_keys = {} addresses = self.wallet.get_addresses() done = False + cancelled = False def privkeys_thread(): for addr in addresses: time.sleep(0.1) - if done: + if done or cancelled: break privkey = self.wallet.export_private_key(addr, password)[0] private_keys[addr] = privkey self.computing_privkeys_signal.emit() - self.computing_privkeys_signal.disconnect() - self.show_privkeys_signal.emit() + if not cancelled: + self.computing_privkeys_signal.disconnect() + self.show_privkeys_signal.emit() def show_privkeys(): s = "\n".join( map( lambda x: x[0] + "\t"+ x[1], private_keys.items())) e.setText(s) b.setEnabled(True) self.show_privkeys_signal.disconnect() + nonlocal done + done = True + + def on_dialog_closed(*args): + nonlocal done + nonlocal cancelled + if not done: + cancelled = True + self.computing_privkeys_signal.disconnect() + self.show_privkeys_signal.disconnect() self.computing_privkeys_signal.connect(lambda: e.setText("Please wait... %d/%d"%(len(private_keys),len(addresses)))) self.show_privkeys_signal.connect(show_privkeys) + d.finished.connect(on_dialog_closed) threading.Thread(target=privkeys_thread).start() if not d.exec_(): diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -60,6 +60,21 @@ class Ledger_Client(): def versiontuple(self, v): return tuple(map(int, (v.split(".")))) + def test_pin_unlocked(func): + """Function decorator to test the Ledger for being unlocked, and if not, + raise a human-readable exception. + """ + def catch_exception(self, *args, **kwargs): + try: + return func(self, *args, **kwargs) + except BTChipException as e: + if e.sw == 0x6982: + raise Exception(_('Your Ledger is locked. Please unlock it.')) + else: + raise + return catch_exception + + @test_pin_unlocked def get_xpub(self, bip32_path, xtype): self.checkDevice() # bip32_path is of the form 44'/0'/1' @@ -80,7 +95,7 @@ class Ledger_Client(): if len(splitPath) > 1: prevPath = "/".join(splitPath[0:len(splitPath) - 1]) nodeData = self.dongleObject.getWalletPublicKey(prevPath) - publicKey = compress_public_key(nodeData['publicKey'])# + publicKey = compress_public_key(nodeData['publicKey']) h = hashlib.new('ripemd160') h.update(hashlib.sha256(publicKey).digest()) fingerprint = unpack(">I", h.digest()[0:4])[0]