cosigner pool: don't block gui
This commit is contained in:
@@ -38,6 +38,7 @@ from electrum.wallet import Multisig_Wallet
|
|||||||
from electrum.util import bh2u, bfh
|
from electrum.util import bh2u, bfh
|
||||||
|
|
||||||
from electrum.gui.qt.transaction_dialog import show_transaction
|
from electrum.gui.qt.transaction_dialog import show_transaction
|
||||||
|
from electrum.gui.qt.util import WaitingDialog
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@@ -170,20 +171,26 @@ class Plugin(BasePlugin):
|
|||||||
return cosigner_xpub in xpub_set
|
return cosigner_xpub in xpub_set
|
||||||
|
|
||||||
def do_send(self, tx):
|
def do_send(self, tx):
|
||||||
|
def on_success(result):
|
||||||
|
window.show_message(_("Your transaction was sent to the cosigning pool.") + '\n' +
|
||||||
|
_("Open your cosigner wallet to retrieve it."))
|
||||||
|
def on_failure(exc_info):
|
||||||
|
e = exc_info[1]
|
||||||
|
try: traceback.print_exception(*exc_info)
|
||||||
|
except OSError: pass
|
||||||
|
window.show_error(_("Failed to send transaction to cosigning pool") + ':\n' + str(e))
|
||||||
|
|
||||||
for window, xpub, K, _hash in self.cosigner_list:
|
for window, xpub, K, _hash in self.cosigner_list:
|
||||||
if not self.cosigner_can_sign(tx, xpub):
|
if not self.cosigner_can_sign(tx, xpub):
|
||||||
continue
|
continue
|
||||||
|
# construct message
|
||||||
raw_tx_bytes = bfh(str(tx))
|
raw_tx_bytes = bfh(str(tx))
|
||||||
public_key = ecc.ECPubkey(K)
|
public_key = ecc.ECPubkey(K)
|
||||||
message = public_key.encrypt_message(raw_tx_bytes).decode('ascii')
|
message = public_key.encrypt_message(raw_tx_bytes).decode('ascii')
|
||||||
try:
|
# send message
|
||||||
server.put(_hash, message)
|
task = lambda: server.put(_hash, message)
|
||||||
except Exception as e:
|
msg = _('Sending transaction to cosigning pool...')
|
||||||
traceback.print_exc(file=sys.stdout)
|
WaitingDialog(window, msg, task, on_success, on_failure)
|
||||||
window.show_error(_("Failed to send transaction to cosigning pool") + ':\n' + str(e))
|
|
||||||
return
|
|
||||||
window.show_message(_("Your transaction was sent to the cosigning pool.") + '\n' +
|
|
||||||
_("Open your cosigner wallet to retrieve it."))
|
|
||||||
|
|
||||||
def on_receive(self, keyhash, message):
|
def on_receive(self, keyhash, message):
|
||||||
self.print_error("signal arrived for", keyhash)
|
self.print_error("signal arrived for", keyhash)
|
||||||
|
|||||||
Reference in New Issue
Block a user