Exemple #1
0
def main():
    rpc = RPC()

    response = rpc.get_accounts()
    accounts = response["result"]["subaddress_accounts"]
    print("\nTotal accounts:", len(accounts), "\n")

    print_accounts(accounts)
Exemple #2
0
def main():
    """
    Check if the number of churns passed in within our allowed range
    """
    if CHURNS < CHURN_LOWER:
        print("Can't churn less than {} times. Exiting...".format(CHURN_LOWER))
        sys.exit(1)
    elif CHURNS > CHURN_UPPER:
        print("Can't churn more than {} times. Exiting...".format(CHURN_UPPER))
        sys.exit(1)
    """
    Indicate whether it's a dry run
    """
    if IS_DRY_RUN:
        print()
        print("*********************************************")
        print("DRY RUN IN PROGRESS: FUNDS WILL NOT BE MOVED!")
        print("*********************************************")
    """
    Check if we need to create new accounts within the walllet
    """
    rpc = RPC()
    response = rpc.get_accounts()
    accounts = response["result"]["subaddress_accounts"]
    total_accounts = len(accounts)

    print("\nChurns: {}\tTotal accounts: {}\n".format(CHURNS, total_accounts))

    if create_accounts(CHURNS, total_accounts, rpc):
        # Re-fetch accounts
        response = rpc.get_accounts()
        accounts = response["result"]["subaddress_accounts"]
    """
    Sweep all to first account
    Grab a transaction hash, then get churn timings.
    The transaction hash is needed to get the churn times.
    """
    print("\nChurn 1")

    # Send all funds to first account
    # and grab tx_hash to get churn timings
    tx_hash = churn(accounts, 1, rpc, dry_run=IS_DRY_RUN)

    wait_times = []

    if tx_hash is not None:
        print(
            "\n\nUsing transaction hash {} to get wait times".format(tx_hash))
        wait_times = get_wait_times_from_transaction(tx_hash, rpc)
    else:
        wait_times = get_dry_run_wait_times(CHURNS, quick=IS_QUICK)

    print_wait_times(CHURNS, wait_times)
    """
    Using the generated churn times: sleep, churn, repeat
    NOTE: First sweep_all counts as a churn.
    """
    for n in range(2, CHURNS):
        # Sleep first, then churn
        current_wait_time = wait_times[n - 2]
        sleep(current_wait_time)

        # Start a new churn
        print("\n\nChurn", n)
        churn(accounts, n, rpc, dry_run=IS_DRY_RUN)
    """
    Last churn, back to account 0
    """
    # Sleep first, then do the last churn
    current_wait_time = wait_times[len(wait_times) - 1]
    sleep(current_wait_time)

    # Transfer all back to main account
    print("\n\nLast churn ({})".format(CHURNS))

    churn(accounts, 0, rpc, dry_run=IS_DRY_RUN)
    """
    Exit when done
    """
    print(
        "\n\nChurns completed successfully\n"
        "(It may take time for your balance to unlock from the last churn)\n")

    # print("Exiting...\n")
    sys.exit(0)