import bitcoin
import ecdsa
import base58
import random
import logging
# Function to convert private key to Wallet Import Format (WIF)
def private_key_to_wif(private_key):
wif = bitcoin.encode_privkey(bitcoin.decode_privkey(private_key, 'hex'), 'wif')
return wif
# Function to convert private key to Bitcoin address (P2PKH)
def private_key_to_address(private_key):
sk = ecdsa.SigningKey.from_string(bytes.fromhex(private_key), curve=ecdsa.SECP256k1)
vk = sk.get_verifying_key()
compressed_vk = vk.to_string('compressed').hex()
address = bitcoin.pubkey_to_address(compressed_vk)
return address
# Function to calculate Hash 160 of a Bitcoin address
def address_to_hash160(address):
decoded_address = base58.b58decode_check(address)
return decoded_address[1:].hex()
# Function to generate a Bitcoin private key and check if the corresponding address matches the target address
def generate_private_key(target_hash160):
while True:
try:
num_objects = random.randint(15,15)
random_values = random.sample(range(0, 29), num_objects)
random_values.append(29)
private_key_num = sum([2 ** power for power in random_values])
private_key = format(private_key_num, '064x')
bitcoin_address = private_key_to_address(private_key)
hash160 = address_to_hash160(bitcoin_address)
print("Private Key:", private_key)
if hash160 == target_hash160:
with open('private_key.txt', 'w') as file:
file.write(private_key)
logging.info("Private key saved to 'private_key.txt' file.")
break
except Exception as e:
logging.error(f"Error: {str(e)}")
def main():
target_hash160 = 'd39c4704664e1deb76c9331e637564c257d68a08'
logging.basicConfig(filename='bitcoin_keygen.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("Generating private keys...")
generate_private_key(target_hash160)
if __name__ == "__main__":
main()
Can anyone make windows CMD program with the Idea of this script for multiple GPUs?
The changebles to be:
num_objects = random.randint(15,15) - THESE VALUES
random_values = random.sample(range(0, 29), num_objects) - THESE VALUES
random_values.append(29) - THIS VALUE
target_hash160 = 'd39c4704664e1deb76c9331e637564c257d68a08' - THIS VALUE
I am sorry for asking but I don`t have the proper programing skills to do this.
I`ve been playing with python to try to run this script with GPUs but... I just can`t ;(