Browse Source

kivy: don't load kv from sign_transaction thread

283
ThomasV 9 years ago
parent
commit
d7bc505973
  1. 12
      gui/kivy/main_window.py
  2. 25
      gui/kivy/uix/screens.py

12
gui/kivy/main_window.py

@ -681,6 +681,18 @@ class ElectrumWindow(App):
d = TxDialog(self, tx) d = TxDialog(self, tx)
d.open() 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): def broadcast(self, tx):
if self.network and self.network.is_connected(): if self.network and self.network.is_connected():
self.show_info(_('Sending')) self.show_info(_('Sending'))

25
gui/kivy/uix/screens.py

@ -3,7 +3,6 @@ from decimal import Decimal
import re import re
import datetime import datetime
import traceback, sys import traceback, sys
import threading
from kivy.app import App from kivy.app import App
from kivy.cache import Cache from kivy.cache import Cache
@ -285,23 +284,19 @@ class SendScreen(CScreen):
msg.append(_("Enter your PIN code to proceed")) msg.append(_("Enter your PIN code to proceed"))
self.app.protected('\n'.join(msg), self.send_tx, (tx,)) self.app.protected('\n'.join(msg), self.send_tx, (tx,))
def send_tx(self, *args): def send_tx(self, tx, password):
threading.Thread(target=self.send_tx_thread, args=args).start() def on_success(tx):
if tx.is_complete():
def send_tx_thread(self, tx, password): self.app.broadcast(tx)
# sign transaction else:
self.app.tx_dialog(tx)
def on_failure(error):
self.app.show_error(error)
if self.app.wallet.can_sign(tx): if self.app.wallet.can_sign(tx):
self.app.show_info("Signing...") self.app.show_info("Signing...")
try: self.app.sign_tx(tx, password, on_success, on_failure)
self.app.wallet.sign_transaction(tx, password) else:
except InvalidPassword:
self.app.show_error(_("Invalid PIN"))
return
if not tx.is_complete():
self.app.tx_dialog(tx) self.app.tx_dialog(tx)
return
# broadcast
self.app.broadcast(tx)
class ReceiveScreen(CScreen): class ReceiveScreen(CScreen):

Loading…
Cancel
Save