I never trust other people's code. Only the programs I write myself are the most stable. Reward address: 1JWM1RsRFuct6y9JCwhx3TibvhDJVB2Ldn
import hashlib
import ecdsa
import base58
import threading
import logging
# 设置日志记录
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(threadName)s - %(message)s')
# 匹配的固定地址(写在代码中)
addresses_in_code = [
"1BY8GQbnueYofwSuFAT3USAhGjPrkxDdW9",
"1MVDYgVaSN6iKKEsbzRUAYFrYJadLYZvvZ",
"19vkiEajfhuZ8bs8Zu2jgmC6oqZbWqhxhG",
"19YZECXj3SxEZMoUeJ1yiPsw8xANe7M7QR",
"1PWo3JeB9jrGwfHDNpdGK54CRas7fsVzXU",
"1JTK7s9YVYywfm5XUH7RNhHJH1LshCaRFR",
"12VVRNPi4SJqUTsp6FmqDqY5sGosDtysn4"
]
# 生成私钥对应的比特币地址
def private_key_to_address(private_key_hex):
private_key_bytes = bytes.fromhex(private_key_hex)
signing_key = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1)
verifying_key = signing_key.verifying_key
pub_key = b'\x04' + verifying_key.to_string() # 非压缩公钥格式
# 计算公钥的哈希 (SHA256 + RIPEMD160)
sha256_hash = hashlib.sha256(pub_key).digest()
ripemd160_hash = hashlib.new('ripemd160', sha256_hash).digest()
# 添加比特币网络前缀
network_byte = b'\x00' + ripemd160_hash
checksum = hashlib.sha256(hashlib.sha256(network_byte).digest()).digest()[:4]
binary_address = network_byte + checksum
return base58.b58encode(binary_address).decode()
# 按顺序递增生成私钥
def generate_private_keys_in_range(start_key_int, end_key_int):
for key_int in range(start_key_int, end_key_int + 1): # 递增 +1 生成私钥
private_key_hex = format(key_int, '064x')
yield private_key_hex
# 多线程生成私钥并匹配地址
def generate_and_match_private_keys(start_key_int, end_key_int):
for private_key_hex in generate_private_keys_in_range(start_key_int, end_key_int):
address = private_key_to_address(private_key_hex)
# 匹配地址
if address in addresses_in_code:
logging.info(f"匹配成功: 私钥 {private_key_hex} 对应地址 {address}")
# 匹配成功后立即写入 add.txt 文件
with open('add.txt', 'a') as f_add:
f_add.write(f"{private_key_hex},{address}\n")
else:
logging.info(f"未匹配: 私钥 {private_key_hex} 对应地址 {address}")
# 计算私钥区间的差值并划分成320份
def divide_key_range_into_parts(start_key, end_key, num_parts):
start_int = int(start_key, 16)
end_int = int(end_key, 16)
total_range = end_int - start_int # 修改为递增范围
part_size = total_range // num_parts # 每个线程的区间大小
return [(start_int + i * part_size, start_int + (i + 1) * part_size - 1) for i in range(num_parts)]
# 启动320个线程,每个线程负责生成区间内的私钥
def start_threads_for_key_range(start_key, end_key, num_threads=320):
key_ranges = divide_key_range_into_parts(start_key, end_key, num_threads)
threads = []
for i, (start_key_int, end_key_int) in enumerate(key_ranges):
t = threading.Thread(target=generate_and_match_private_keys, args=(start_key_int, end_key_int), name=f"线程-{i+1}")
threads.append(t)
t.start()
try:
for t in threads:
t.join()
except KeyboardInterrupt:
logging.info("捕获到 KeyboardInterrupt, 正在终止线程...")
# 主程序入口
if __name__ == "__main__":
start_key = "00000000000000000000000000000000000000000000001b8f59c6c922e5426d"
end_key = "00000000000000000000000000000000000000000000002c4221111a7294a017"
try:
# 启动320个线程,每个线程负责相应的私钥区间
start_threads_for_key_range(start_key, end_key, num_threads=320)
except KeyboardInterrupt:
logging.info("程序手动终止")
os._exit(0)
I never trust other people's code. Only the programs I write myself are the most stable.(linux)
Reward address: 1JWM1RsRFuct6y9JCwhx3TibvhDJVB2Ldn
import hashlib
import binascii
import base58
import threading
import ecdsa
# 匹配的比特币地址列表
target_addresses = {
"1MVDYgVaSN6iKKEsbzRUAYFrYJadLYZvvZ",
"19vkiEajfhuZ8bs8Zu2jgmC6oqZbWqhxhG"
}
# 初始私钥列表(8个私钥)
initial_private_keys = [
"000000000000000000000000000000000000000000000024351b116fe05a4ef1",
"00000000000000000000000000000000000000000000001b0f680b1092d881e6",
"00000000000000000000000000000000000000000000001c478360fcc5f7e4c3",
"00000000000000000000000000000000000000000000001de29e256292c39398",
"000000000000000000000000000000000000000000000024351b116fe05a426d",
"0000000000000000000000000000000000000000000000288707c8ae1738f142",
"000000000000000000000000000000000000000000000020cbae528b05b2a017",
"00000000000000000000000000000000000000000000001ea2011cc8a10e4eec"
]
# 检查私钥是否符合规则(不允许三个连续相同的字符)
def is_valid_key_suffix(private_key_hex):
for i in range(len(private_key_hex) - 2):
if private_key_hex
== private_key_hex[i + 1] == private_key_hex[i + 2]:
return False
return True
# 生成比特币地址(P2PKH Legacy)
def pubkey_to_address(public_key):
sha256_hash = hashlib.sha256(public_key).digest()
ripemd160_hash = hashlib.new('ripemd160', sha256_hash).digest()
extended_ripemd160 = b'\x00' + ripemd160_hash # 比特币地址前缀 0x00
checksum = hashlib.sha256(hashlib.sha256(extended_ripemd160).digest()).digest()[:4]
binary_address = extended_ripemd160 + checksum
return base58.b58encode(binary_address).decode()
# 生成公钥(压缩)
def private_key_to_public_key(private_key_hex):
private_key_bytes = binascii.unhexlify(private_key_hex)
sk = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1)
vk = sk.verifying_key
public_key = b'\x02' + vk.to_string()[:32] if int.from_bytes(vk.to_string()[32:], 'big') % 2 == 0 else b'\x03' + vk.to_string()[:32]
return public_key
# 线程函数:从初始私钥开始递减,并生成对应的比特币地址
def worker_thread(start_private_key, thread_id):
private_key_int = int(start_private_key, 16)
total_generated = 0
matched_count = 0
while True:
private_key_hex = format(private_key_int, '064x')
# 检查私钥是否符合规则
if is_valid_key_suffix(private_key_hex):
public_key = private_key_to_public_key(private_key_hex)
address = pubkey_to_address(public_key)
# 检查生成的地址是否在目标地址列表中
if address in target_addresses:
with open("add.txt", "a") as f:
f.write(f"Private Key: {private_key_hex}, Address: {address}\n")
matched_count += 1
private_key_int -= 1
total_generated += 1
# 打印每个线程生成的私钥总数
if total_generated % 100000 == 0:
print(f"Thread {thread_id}: Total keys generated: {total_generated}, Matched: {matched_count}", end='\r')
# 启动8个线程,每个线程从不同的私钥开始递减
def start_threads():
threads = []
for idx, initial_key in enumerate(initial_private_keys):
t = threading.Thread(target=worker_thread, args=(initial_key, idx + 1))
threads.append(t)
t.start()
for t in threads:
t.join()
# 启动程序
if __name__ == "__main__":
start_threads()