# Path: jmclient/jmclient/configure.py
# def validate_address(addr):
#     try:
#         # automatically respects the network
#         # as set in btc.select_chain_params(...)
#         dummyaddr = btc.CCoinAddress(addr)
#     except Exception as e:
#         return False, repr(e)
#     # additional check necessary because python-bitcointx
#     # does not check hash length on p2sh construction.
#     try:
#         dummyaddr.to_scriptPubKey()
#     except Exception as e:
#         return False, repr(e)
#     return True, "address validated"
# 
# def jm_single():
#     return global_singleton


import copy
import random
import sys
from .configure import validate_address, jm_single
from .support import rand_exp_array, rand_norm_array, rand_weighted_choice
                        tx_list_remove.append(tx)
                    else:
                        tx['amount_fraction'] = 0
            [tx_list.remove(t) for t in tx_list_remove]
    schedule = []
    for t in tx_list:
        schedule.append([t['srcmixdepth'], t['amount_fraction'],
                  t['makercount'], t['destination'], t['wait'],
                  t['rounding'], 0])
    return schedule

def tweak_tumble_schedule(options, schedule, last_completed, destaddrs=[]):
    """If a tx in a schedule failed for some reason, and we want
    to make a best effort to complete the schedule, we can tweak
    the failed entry to improve the odds of success on re-try.
    Both the size/amount and the number of counterparties may have
    been a cause for failure, so we change both of those where
    possible.
    Returns a new, altered schedule file (should continue at same index)
    """
    new_schedule = copy.deepcopy(schedule)
    altered = new_schedule[last_completed + 1]
    if not altered[3] in destaddrs:
        altered[3] = "INTERNAL"
    #For sweeps, we'll try with a lower number of counterparties if we can.
    #Note that this is usually counterproductive for non-sweeps, which fall
    #back and so benefit in reliability from *higher* counterparty numbers.
    if altered[1] == 0:
        new_n_cp = altered[2] - 1
        if new_n_cp < jm_single().config.getint("POLICY", "minimum_makers"):

# Path: jmclient/jmclient/configure.py
# def validate_address(addr):
#     try:
#         # automatically respects the network
#         # as set in btc.select_chain_params(...)
#         dummyaddr = btc.CCoinAddress(addr)
#     except Exception as e:
#         return False, repr(e)
#     # additional check necessary because python-bitcointx
#     # does not check hash length on p2sh construction.
#     try:
#         dummyaddr.to_scriptPubKey()
#     except Exception as e:
#         return False, repr(e)
#     return True, "address validated"
# 
# def jm_single():
#     return global_singleton


# Path: jmclient/jmclient/schedule.py
import copy
import random
import sys
from .configure import validate_address, jm_single
from .support import rand_exp_array, rand_norm_array, rand_weighted_choice

                        tx_list_remove.append(tx)
                    else:
                        tx['amount_fraction'] = 0
            [tx_list.remove(t) for t in tx_list_remove]
    schedule = []
    for t in tx_list:
        schedule.append([t['srcmixdepth'], t['amount_fraction'],
                  t['makercount'], t['destination'], t['wait'],
                  t['rounding'], 0])
    return schedule

def tweak_tumble_schedule(options, schedule, last_completed, destaddrs=[]):
    """If a tx in a schedule failed for some reason, and we want
    to make a best effort to complete the schedule, we can tweak
    the failed entry to improve the odds of success on re-try.
    Both the size/amount and the number of counterparties may have
    been a cause for failure, so we change both of those where
    possible.
    Returns a new, altered schedule file (should continue at same index)
    """
    new_schedule = copy.deepcopy(schedule)
    altered = new_schedule[last_completed + 1]
    if not altered[3] in destaddrs:
        altered[3] = "INTERNAL"
    #For sweeps, we'll try with a lower number of counterparties if we can.
    #Note that this is usually counterproductive for non-sweeps, which fall
    #back and so benefit in reliability from *higher* counterparty numbers.
    if altered[1] == 0:
        new_n_cp = altered[2] - 1
        if new_n_cp < jm_single().config.getint("POLICY", "minimum_makers"):

            new_n_cp = jm_single().config.getint("POLICY", "minimum_makers")