electrum

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

commit d7bc505973faeeef98cf360f210fa5f9c59c24da
parent 2492909ccc16d53d2e3253c01d08bc2939bc36df
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 19 Feb 2016 10:52:09 +0100

kivy: don't load kv from sign_transaction thread

Diffstat:
Mgui/kivy/main_window.py | 12++++++++++++
Mgui/kivy/uix/screens.py | 25++++++++++---------------
2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -681,6 +681,18 @@ class ElectrumWindow(App): d = TxDialog(self, tx) d.open() + def sign_tx(self, *args): + import threading + threading.Thread(target=self._sign_tx, args=args).start() + + def _sign_tx(self, tx, password, on_success, on_failure): + try: + self.wallet.sign_transaction(tx, password) + except InvalidPassword: + Clock.schedule_once(lambda dt: on_failure(_("Invalid PIN"))) + return + Clock.schedule_once(lambda dt: on_success(tx)) + def broadcast(self, tx): if self.network and self.network.is_connected(): self.show_info(_('Sending')) diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -3,7 +3,6 @@ from decimal import Decimal import re import datetime import traceback, sys -import threading from kivy.app import App from kivy.cache import Cache @@ -285,23 +284,19 @@ class SendScreen(CScreen): msg.append(_("Enter your PIN code to proceed")) self.app.protected('\n'.join(msg), self.send_tx, (tx,)) - def send_tx(self, *args): - threading.Thread(target=self.send_tx_thread, args=args).start() - - def send_tx_thread(self, tx, password): - # sign transaction + def send_tx(self, tx, password): + def on_success(tx): + if tx.is_complete(): + self.app.broadcast(tx) + else: + self.app.tx_dialog(tx) + def on_failure(error): + self.app.show_error(error) if self.app.wallet.can_sign(tx): self.app.show_info("Signing...") - try: - self.app.wallet.sign_transaction(tx, password) - except InvalidPassword: - self.app.show_error(_("Invalid PIN")) - return - if not tx.is_complete(): + self.app.sign_tx(tx, password, on_success, on_failure) + else: self.app.tx_dialog(tx) - return - # broadcast - self.app.broadcast(tx) class ReceiveScreen(CScreen):