Browse Source

Check for pushtx() success in direct_send()

master
Kristaps Kaupe 6 years ago
parent
commit
1d592d9a23
No known key found for this signature in database
GPG Key ID: D47B1B4232B55437
  1. 25
      jmclient/jmclient/taker_utils.py
  2. 10
      scripts/joinmarket-qt.py

25
jmclient/jmclient/taker_utils.py

@ -22,7 +22,7 @@ Currently re-used by CLI script tumbler.py and joinmarket-qt
"""
def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False,
accept_callback=None, info_callback=None,
accept_callback=None, info_callback=None, error_callback=None,
return_transaction=False, with_final_psbt=False,
optin_rbf=False):
"""Send coins directly from one mixdepth to one destination address;
@ -38,8 +38,8 @@ def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False,
returns:
True if accepted, False if not
====
The info_callback takes one parameter, the information message (when tx is
pushed), and returns nothing.
info_callback and error_callback takes one parameter, the information
message (when tx is pushed or error occured), and returns nothing.
This function returns:
1. False if there is any failure.
@ -187,13 +187,18 @@ def direct_send(wallet_service, amount, mixdepth, destination, answeryes=False,
destination, actual_amount, fee_est)
if not accepted:
return False
jm_single().bc_interface.pushtx(tx.serialize())
txid = bintohex(tx.GetTxid()[::-1])
successmsg = "Transaction sent: " + txid
cb = log.info if not info_callback else info_callback
cb(successmsg)
txinfo = txid if not return_transaction else tx
return txinfo
if jm_single().bc_interface.pushtx(tx.serialize()):
txid = bintohex(tx.GetTxid()[::-1])
successmsg = "Transaction sent: " + txid
cb = log.info if not info_callback else info_callback
cb(successmsg)
txinfo = txid if not return_transaction else tx
return txinfo
else:
errormsg = "Transaction broadcast failed!"
cb = log.error if not error_callback else error_callback
cb(errormsg)
return False
def get_tumble_log(logsdir):
tumble_log = logging.getLogger('tumbler')

10
scripts/joinmarket-qt.py

@ -650,8 +650,11 @@ class SpendTab(QWidget):
else:
return False
def infoDirectSend(self, txid):
JMQtMessageBox(self, "Tx sent: " + str(txid), title="Success")
def infoDirectSend(self, msg):
JMQtMessageBox(self, msg, title="Success")
def errorDirectSend(self, msg):
JMQtMessageBox(self, msg, mbtype="warn", title="Error")
def startSingle(self):
if not self.spendstate.runstate == 'ready':
@ -672,7 +675,8 @@ class SpendTab(QWidget):
try:
txid = direct_send(mainWindow.wallet_service, amount, mixdepth,
destaddr, accept_callback=self.checkDirectSend,
info_callback=self.infoDirectSend)
info_callback=self.infoDirectSend,
error_callback=self.errorDirectSend)
except Exception as e:
JMQtMessageBox(self, e.args[0], title="Error", mbtype="warn")
return

Loading…
Cancel
Save