예제 #1
0
def test_convert_private_key_to_address():
    # wif private key is '5HwoXVkHoRM8sL2KmNRS217n1g8mPPBomrY7yehCuXC1115WWsh'
    private_key = 7719472615821079694904732333912527190217998977709370935963838933860875309329

    address = convert_private_key_to_address(private_key, coins['BTC']['address_prefix_bytes'])

    assert address == '1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9'
예제 #2
0
def get_utxo_from_private_keys(coin,
                               wif_private_keys,
                               is_script=False,
                               minimum_input_threshold=None,
                               maximum_input_threshold=None,
                               limit_inputs=None):
    for wif_private_key in set(wif_private_keys):
        private_key, compressed = get_private_key_from_wif_format(
            wif_private_key)
        if is_script:
            prefix_bytes = coin['script_prefix_bytes']
        else:
            prefix_bytes = coin['address_prefix_bytes']
        source_address = convert_private_key_to_address(
            private_key, prefix_bytes, compressed, is_script)
        utxos = get_utxo_from_address(coin, source_address,
                                      minimum_input_threshold,
                                      maximum_input_threshold, limit_inputs)
        for utxo in utxos:
            utxo['private_key'] = private_key
            utxo['source_address'] = source_address
            yield utxo
예제 #3
0
def translate(args):
    output_coin_symbol = args.output_symbol.upper()
    private_key = args.private_key
    file_name = args.file

    if file_name:
        file_handler = logging.FileHandler(file_name)
        logger.addHandler(file_handler)

    if not output_coin_symbol:
        translated_private_key, compressed = get_private_key_from_wif_format(
            private_key)
        return translated_private_key, compressed, ''

    try:
        if args.integer:
            int_private_key = get_integer(private_key)
            wif_private_key = convert_private_key_to_wif_format(
                int_private_key, b'\x80')
        else:
            wif_private_key = private_key
        validate_base58(wif_private_key)
    except ValueError as exc:
        logger.error(exc)
        return '', '', ''

    output_private_key_prefix_bytes = coins[output_coin_symbol][
        'secret_prefix_bytes']
    output_address_prefix_bytes = coins[output_coin_symbol][
        'address_prefix_bytes']
    translated_private_key = translate_private_key(
        wif_private_key, output_private_key_prefix_bytes)
    private_key, compressed = get_private_key_from_wif_format(wif_private_key)
    address = convert_private_key_to_address(private_key,
                                             output_address_prefix_bytes,
                                             compressed)
    return translated_private_key, compressed, address