kivy: don't load kv from sign_transaction thread

This commit is contained in:
ThomasV 2016-02-19 10:52:09 +01:00
parent 2492909ccc
commit d7bc505973
2 changed files with 22 additions and 15 deletions

View File

@ -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'))

View File

@ -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):