コード例 #1
0
def _faucet(username, client, wallet):
    """Earn bitcoin from the 21 faucet.

    Because the client is untrusted in general, this command is
    rate-limited by CPU proof-of-work requested from the client, as
    well as heuristics applied to each username.
    """
    ux('earn_faucet_banner', fg='magenta')
    try:
        start_cpu_mining(username, client, wallet, prefix='earn_faucet')
    except MiningDisabledError as e:
        logger.info(e.args[0])
        return
コード例 #2
0
def start_cpu_mining(username, client, wallet, prefix='mining'):
    """ Mine bitcoin on the command line by using the CPU of the system.

    Note that this is primarily used to rate limit mining
    advances. CPU mining, or foreground mining, is when the pool sets
    the difficulty very low and the CPU finds a valid solution.

    Args:
        username (str): username from .two1/two1.json
    """
    enonce1, enonce2_size, reward = set_payout_address(client, wallet)

    start_time = time.time()
    ux(prefix + '_start', username, reward)

    # gets work from the server
    work = get_work(client)

    # kicks off cpu miner to find a solution
    found_share = mine_work(work, enonce1=enonce1, enonce2_size=enonce2_size)

    paid_satoshis = save_work(client, found_share)

    end_time = time.time()
    duration = end_time - start_time

    ux(prefix + '_success', username, paid_satoshis, duration, fg='magenta')

    ux(prefix + '_status')
    status.status_wallet(client, wallet)

    status21 = click.style("21 status", bold=True)
    buy21 = click.style("21 buy", bold=True)
    ux(prefix + '_finish', status21, buy21)
コード例 #3
0
ファイル: mine.py プロジェクト: RdeWilde/two1-python
def start_cpu_mining(username, client, wallet, prefix="mining"):
    """ Mine bitcoin on the command line by using the CPU of the system.

    Note that this is primarily used to rate limit mining
    advances. CPU mining, or foreground mining, is when the pool sets
    the difficulty very low and the CPU finds a valid solution.

    Args:
        username (str): username from .two1/two1.json
    """
    enonce1, enonce2_size, reward = set_payout_address(client, wallet)

    start_time = time.time()
    ux(prefix + "_start", username, reward)

    # gets work from the server
    work = get_work(client)

    # kicks off cpu miner to find a solution
    found_share = mine_work(work, enonce1=enonce1, enonce2_size=enonce2_size)

    paid_satoshis = save_work(client, found_share)

    end_time = time.time()
    duration = end_time - start_time

    ux(prefix + "_success", username, paid_satoshis, duration, fg="magenta")

    ux(prefix + "_status")
    status.status_wallet(client, wallet)

    status21 = click.style("21 status", bold=True)
    buy21 = click.style("21 buy", bold=True)
    ux(prefix + "_finish", status21, buy21)
コード例 #4
0
def _earn(username, client, wallet, invite):
    if invite:
        ux('earn_task_use_faucet')
    else:
        do_faucet(username, client, wallet)
    return 0
コード例 #5
0
ファイル: earn.py プロジェクト: 21dotco/two1-python
def _earn(username, client, wallet, invite):
    if invite:
        ux('earn_task_use_faucet')
    else:
        do_faucet(username, client, wallet)
    return 0