|
|
|
|
@ -12,6 +12,8 @@ from jmclient import Taker, load_program_config, get_schedule,\
|
|
|
|
|
get_tumble_log, tumbler_taker_finished_update, check_regtest, \ |
|
|
|
|
tumbler_filter_orders_callback, validate_address, get_tumbler_parser, \ |
|
|
|
|
get_max_cj_fee_values |
|
|
|
|
from jmclient.wallet_utils import DEFAULT_MIXDEPTH |
|
|
|
|
from jmclient.schedule import ScheduleGenerationErrorNoFunds |
|
|
|
|
|
|
|
|
|
from jmbase.support import get_log, jmprint, EXIT_SUCCESS, \ |
|
|
|
|
EXIT_FAILURE, EXIT_ARGERROR |
|
|
|
|
@ -38,11 +40,17 @@ def main():
|
|
|
|
|
|
|
|
|
|
#Load the wallet |
|
|
|
|
wallet_name = args[0] |
|
|
|
|
max_mix_depth = options['mixdepthsrc'] + options['mixdepthcount'] |
|
|
|
|
if options['amtmixdepths'] > max_mix_depth: |
|
|
|
|
# as of #1324 the concept of a max_mix_depth distinct from |
|
|
|
|
# the normal wallet value (4) no longer applies, since the |
|
|
|
|
# tumbler cycles; but we keep the `amtmixdepths` option for now, |
|
|
|
|
# deprecating it later. |
|
|
|
|
if options['amtmixdepths'] > DEFAULT_MIXDEPTH: |
|
|
|
|
max_mix_depth = options['amtmixdepths'] |
|
|
|
|
else: |
|
|
|
|
max_mix_depth = DEFAULT_MIXDEPTH |
|
|
|
|
wallet_path = get_wallet_path(wallet_name, None) |
|
|
|
|
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth, wallet_password_stdin=options_org.wallet_password_stdin) |
|
|
|
|
wallet = open_test_wallet_maybe(wallet_path, wallet_name, max_mix_depth, |
|
|
|
|
wallet_password_stdin=options_org.wallet_password_stdin) |
|
|
|
|
wallet_service = WalletService(wallet) |
|
|
|
|
if wallet_service.rpc_error: |
|
|
|
|
sys.exit(EXIT_FAILURE) |
|
|
|
|
@ -109,8 +117,12 @@ def main():
|
|
|
|
|
tumble_log.info("TUMBLE RESTARTING") |
|
|
|
|
else: |
|
|
|
|
#Create a new schedule from scratch |
|
|
|
|
schedule = get_tumble_schedule(options, destaddrs, |
|
|
|
|
wallet.get_balance_by_mixdepth(), wallet_service.mixdepth) |
|
|
|
|
try: |
|
|
|
|
schedule = get_tumble_schedule(options, destaddrs, |
|
|
|
|
wallet.get_balance_by_mixdepth(), wallet_service.mixdepth) |
|
|
|
|
except ScheduleGenerationErrorNoFunds: |
|
|
|
|
jmprint("No funds in wallet to tumble.", "error") |
|
|
|
|
sys.exit(EXIT_FAILURE) |
|
|
|
|
tumble_log.info("TUMBLE STARTING") |
|
|
|
|
with open(os.path.join(logsdir, options['schedulefile']), "wb") as f: |
|
|
|
|
f.write(schedule_to_text(schedule)) |
|
|
|
|
@ -133,10 +145,15 @@ def main():
|
|
|
|
|
involved_parties = len(schedule) # own participation in each CJ |
|
|
|
|
for item in schedule: |
|
|
|
|
involved_parties += item[2] # number of total tumble counterparties |
|
|
|
|
# calculating total coins that will be included in the tumble; |
|
|
|
|
# in almost all cases all coins (unfrozen) in wallet will be tumbled, |
|
|
|
|
# though it's technically possible with a very small mixdepthcount, to start |
|
|
|
|
# at say m0, and only go through to 2 or 3, such that coins in 4 are untouched |
|
|
|
|
# in phase 2 (after having been swept in phase 1). |
|
|
|
|
used_mixdepths = set() |
|
|
|
|
[used_mixdepths.add(x[0]) for x in schedule] |
|
|
|
|
total_tumble_amount = int(0) |
|
|
|
|
max_mix_to_tumble = min(options['mixdepthsrc']+options['mixdepthcount'], \ |
|
|
|
|
max_mix_depth) |
|
|
|
|
for i in range(options['mixdepthsrc'], max_mix_to_tumble): |
|
|
|
|
for i in used_mixdepths: |
|
|
|
|
total_tumble_amount += wallet_service.get_balance_by_mixdepth()[i] |
|
|
|
|
if total_tumble_amount == 0: |
|
|
|
|
raise ValueError("No confirmed coins in the selected mixdepth(s). Quitting") |
|
|
|
|
|