broadcast tx in a separate thread
This commit is contained in:
parent
60bea77d1e
commit
88d4dab6cb
|
@ -180,6 +180,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
self.connect(self, QtCore.SIGNAL('banner_signal'), lambda: self.console.showMessage(self.network.banner) )
|
self.connect(self, QtCore.SIGNAL('banner_signal'), lambda: self.console.showMessage(self.network.banner) )
|
||||||
self.connect(self, QtCore.SIGNAL('transaction_signal'), lambda: self.notify_transactions() )
|
self.connect(self, QtCore.SIGNAL('transaction_signal'), lambda: self.notify_transactions() )
|
||||||
self.connect(self, QtCore.SIGNAL('send_tx2'), self.send_tx2)
|
self.connect(self, QtCore.SIGNAL('send_tx2'), self.send_tx2)
|
||||||
|
self.connect(self, QtCore.SIGNAL('send_tx3'), self.send_tx3)
|
||||||
|
|
||||||
self.history_list.setFocus(True)
|
self.history_list.setFocus(True)
|
||||||
|
|
||||||
|
@ -265,6 +266,8 @@ class ElectrumWindow(QMainWindow):
|
||||||
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
|
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
|
||||||
self.setWindowTitle( title )
|
self.setWindowTitle( title )
|
||||||
self.update_wallet()
|
self.update_wallet()
|
||||||
|
self.config.set_key('default_wallet_path', self.wallet.storage.path, True)
|
||||||
|
|
||||||
# Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized
|
# Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized
|
||||||
self.notify_transactions()
|
self.notify_transactions()
|
||||||
self.update_account_selector()
|
self.update_account_selector()
|
||||||
|
@ -888,6 +891,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
# call hook to see if plugin needs gui interaction
|
# call hook to see if plugin needs gui interaction
|
||||||
run_hook('send_tx', tx)
|
run_hook('send_tx', tx)
|
||||||
|
|
||||||
|
# sign the tx
|
||||||
def sign_thread():
|
def sign_thread():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
keypairs = {}
|
keypairs = {}
|
||||||
|
@ -895,8 +899,6 @@ class ElectrumWindow(QMainWindow):
|
||||||
self.wallet.sign_transaction(tx, keypairs, password)
|
self.wallet.sign_transaction(tx, keypairs, password)
|
||||||
self.signed_tx_data = (tx, fee, label)
|
self.signed_tx_data = (tx, fee, label)
|
||||||
self.emit(SIGNAL('send_tx2'))
|
self.emit(SIGNAL('send_tx2'))
|
||||||
|
|
||||||
# sign the tx
|
|
||||||
self.tx_wait_dialog = self.waiting_dialog('Signing..')
|
self.tx_wait_dialog = self.waiting_dialog('Signing..')
|
||||||
threading.Thread(target=sign_thread).start()
|
threading.Thread(target=sign_thread).start()
|
||||||
|
|
||||||
|
@ -920,23 +922,29 @@ class ElectrumWindow(QMainWindow):
|
||||||
if label:
|
if label:
|
||||||
self.wallet.set_label(tx.hash(), label)
|
self.wallet.set_label(tx.hash(), label)
|
||||||
|
|
||||||
if tx.is_complete:
|
if not tx.is_complete:
|
||||||
|
self.show_transaction(tx)
|
||||||
|
return
|
||||||
|
|
||||||
d = self.waiting_dialog('Broadcasting...')
|
# broadcast the tx
|
||||||
h = self.wallet.send_tx(tx)
|
def broadcast_thread():
|
||||||
self.wallet.tx_event.wait()
|
self.tx_broadcast_result = self.wallet.sendtx(tx)
|
||||||
d.accept()
|
self.emit(SIGNAL('send_tx3'))
|
||||||
|
self.tx_broadcast_dialog = self.waiting_dialog('Broadcasting..')
|
||||||
|
threading.Thread(target=broadcast_thread).start()
|
||||||
|
|
||||||
status, msg = self.wallet.receive_tx( h, tx )
|
|
||||||
|
def send_tx3(self):
|
||||||
|
self.tx_broadcast_dialog.accept()
|
||||||
|
status, msg = self.tx_broadcast_result
|
||||||
if status:
|
if status:
|
||||||
QMessageBox.information(self, '', _('Payment sent.') + '\n' + msg, _('OK'))
|
QMessageBox.information(self, '', _('Payment sent.') + '\n' + msg, _('OK'))
|
||||||
self.do_clear()
|
self.do_clear()
|
||||||
self.update_contacts_tab()
|
self.update_contacts_tab()
|
||||||
else:
|
else:
|
||||||
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
||||||
else:
|
|
||||||
|
|
||||||
self.show_transaction(tx)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue