Browse Source

Human readable tumbler log entries

master
Adam Gibson 9 years ago
parent
commit
21a0e499cf
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 2
      jmclient/jmclient/__init__.py
  2. 10
      jmclient/jmclient/schedule.py
  3. 2
      scripts/sendpayment.py
  4. 21
      scripts/tumbler.py

2
jmclient/jmclient/__init__.py

@ -31,7 +31,7 @@ from .podle import (set_commitment_file, get_commitment_file,
PoDLE, generate_podle, get_podle_commitments,
update_commitments)
from .schedule import (get_schedule, get_tumble_schedule, schedule_to_text,
tweak_tumble_schedule)
tweak_tumble_schedule, human_readable_schedule_entry)
from .commitment_utils import get_utxo_info, validate_utxo_data, quit
# Set default logging handler to avoid "No handler found" warnings.

10
jmclient/jmclient/schedule.py

@ -176,5 +176,15 @@ def tweak_tumble_schedule(options, schedule, last_completed):
new_schedule[last_completed + 1 + len(tobedone) - 1][1] = 0
return new_schedule
def human_readable_schedule_entry(se, amt=None, destn=None):
hrs = []
hrs.append("From mixdepth " + str(se[0]))
amt_info = str(amt) if amt else str(se[1])
hrs.append("sends amount: " + amt_info + " satoshis")
dest_info = destn if destn else str(se[3])
hrs.append("to destination address: " + dest_info)
hrs.append("after coinjoin with " + str(se[2]) + " counterparties.")
return ", ".join(hrs)
def schedule_to_text(schedule):
return "\n".join([",".join([str(y) for y in x]) for x in schedule])

2
scripts/sendpayment.py

@ -98,6 +98,8 @@ def main():
#of a single transaction
sweeping = False
if options.schedule == '':
#note that sendpayment doesn't support fractional amounts, fractions throw
#here.
amount = int(args[1])
if amount == 0:
sweeping = True

21
scripts/tumbler.py

@ -16,7 +16,7 @@ from jmclient import (Taker, load_program_config, get_schedule, weighted_order_c
validate_address, jm_single, WalletError,
Wallet, sync_wallet, get_tumble_schedule,
RegtestBitcoinCoreInterface, estimate_tx_fee,
tweak_tumble_schedule)
tweak_tumble_schedule, human_readable_schedule_entry)
from jmbase.support import get_log, debug_dump_object, get_password
from cli_options import get_tumbler_parser
@ -79,11 +79,15 @@ def main():
def taker_finished(res, fromtx=False, waittime=0.0):
if fromtx:
if res:
tumble_log.info("Completed successfully.")
tumble_log.info("We sent: " + str(taker.cjamount) + \
" satoshis to address: " + taker.my_cj_addr + \
" from mixdepth: " + \
str(taker.schedule[taker.schedule_index][0]))
tumble_log.info("Completed successfully this entry:")
#the log output depends on if it's a sweep, and if it's to INTERNAL
hrdestn = None
if taker.schedule[taker.schedule_index][3] == "INTERNAL":
hrdestn = taker.my_cj_addr
#Whether sweep or not, the amt is not in satoshis; use taker data
hramt = taker.cjamount
tumble_log.info(human_readable_schedule_entry(
taker.schedule[taker.schedule_index], hramt, hrdestn))
waiting_message = "Waiting for: " + str(waittime) + " seconds."
tumble_log.info(waiting_message)
sync_wallet(wallet, fast=options['fastsync'])
@ -111,6 +115,11 @@ def main():
log.info("Did not complete successfully, shutting down")
else:
log.info("All transactions completed correctly")
tumble_log.info("Completed successfully the last entry:")
#Whether sweep or not, the amt is not in satoshis; use taker data
hramt = taker.cjamount
tumble_log.info(human_readable_schedule_entry(
taker.schedule[taker.schedule_index], hramt))
reactor.stop()
#to allow testing of confirm/unconfirm callback for multiple txs

Loading…
Cancel
Save