Browse Source

update state on unconfirmed, and handle failed pushtx

master
Adam Gibson 10 years ago
parent
commit
2d3a7f227c
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 3
      jmclient/jmclient/taker.py
  2. 26
      scripts/tumbler.py

3
jmclient/jmclient/taker.py

@ -601,6 +601,9 @@ class Taker(object):
self.txid = btc.txhash(tx)
jlog.debug('txid = ' + self.txid)
pushed = jm_single().bc_interface.pushtx(tx)
if not pushed:
self.on_finished_callback(False, fromtx=True)
else:
jm_single().bc_interface.add_tx_notify(
self.latest_tx, self.unconfirm_callback,
self.confirm_callback, self.my_cj_addr)

26
scripts/tumbler.py

@ -99,16 +99,18 @@ def main():
#callback for order checking; dummy/passthrough
def filter_orders_callback(orders_fees, cjamount):
return True
#callback between transactions
def taker_finished(res, fromtx=False, waittime=0.0):
if fromtx:
"""on_finished_callback for tumbler
"""
def unconf_update():
#on taker side, cache index update is only required after tx
#push, to avoid potential of address reuse in case of a crash,
#because addresses are not public until broadcast (whereas for makers,
#they are public *during* negotiation). So updating the cache here
#is sufficient
taker.wallet.update_cache_index()
if res:
#We persist the fact that the transaction is complete to the
#schedule file. Note that if a tweak to the schedule occurred,
#it only affects future (non-complete) transactions, so the final
@ -119,8 +121,20 @@ def main():
"wb") as f:
f.write(schedule_to_text(taker.schedule))
if fromtx == "unconfirmed":
#unconfirmed event means transaction has been propagated,
#we update state to prevent accidentally re-creating it in
#any crash/restart condition
unconf_update()
return
if fromtx:
if res:
tumble_log.info("Completed successfully this entry:")
#the log output depends on if it's a sweep, and if it's to INTERNAL
#this has no effect except in the rare case that confirmation
#is immediate
unconf_update()
#the log output depends on if it's to INTERNAL
hrdestn = None
if taker.schedule[taker.schedule_index][3] == "INTERNAL":
hrdestn = taker.my_cj_addr
@ -128,10 +142,12 @@ def main():
hramt = taker.cjamount
tumble_log.info(human_readable_schedule_entry(
taker.schedule[taker.schedule_index], hramt, hrdestn))
tumble_log.info("Txid was: " + taker.txid)
waiting_message = "Waiting for: " + str(waittime) + " minutes."
tumble_log.info(waiting_message)
sync_wallet(wallet, fast=options['fastsync'])
log.info(waiting_message)
sync_wallet(wallet, fast=options['fastsync'])
reactor.callLater(waittime*60,
clientfactory.getClient().clientStart)
else:

Loading…
Cancel
Save