forked from asciibene/brainwallet-finder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheth.py
More file actions
139 lines (113 loc) · 5 KB
/
eth.py
File metadata and controls
139 lines (113 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import hashlib
import ecdsa
import base58
import requests
import os
import json
import time
import curses
from eth_account import Account
import re
from urllib.request import urlopen
from time import sleep
from colorama import init, Fore, Style
from concurrent.futures import ThreadPoolExecutor, as_completed
from tqdm import tqdm
from ratelimit import limits, sleep_and_retry
from sys import argv
# Initialize colorama
init(autoreset=True)
# Constants
os.environ['ECC_BACKEND_CLASS'] = 'eth_keys.backends.NativeECCBackend'
RATE_LIMIT = 3# Max request per second
TIME_PERIOD = 1 # Time period in seconds for rate limit
WEI_PER_ETH = 1e10
ES_KEY= "RJWQE7MKV6FCSGP41N8YHNMKJ9VATFN8ZD"
ES_CHAINIDS={"etherscan":1 , 'ftmscan': 250, 'optimistic': 10, 'polygon': 137, 'arbitrum': 42161, 'gnosis': 100,'base': 8453,'avalanche': 43114,'zkSync': 324}
CHECK_TOKENS = False #TODO
TOKEN_CONTRACTS = {"name", 'hexaddr'}
# Adjust the check_balance function
@sleep_and_retry
@limits(calls=RATE_LIMIT, period=TIME_PERIOD)
def check_address_balance_eth(address,privkey):
try:
wallets_multichain=[]
for chain,chainid in ES_CHAINIDS.items():
#Todo : send multiple address in 1 query.. use |
url= f"https://api.etherscan.io/v2/api?chainid={chainid}&module=account&action=balance&address={address}&tag=latest&apikey={ES_KEY}"
htmltext = urlopen(url, timeout=6).read().decode('utf-8')
if htmltext is None: raise("Empty reply from url")
dat=json.loads(htmltext)
#ethscan_info = {t: float(re.search(rf'{t}":"(\d+)', htmltext).group(1)) for t in etherscan_tags}print(dat)
# dat['result'] = float(dat['result']) / WEI_PER_ETH
del dat['status']
#dat['result'] = float(dat['result'])
dat['message'] = Fore.GREEN + dat['message'] + Style.RESET_ALL if dat['message'] == 'OK' else exit()
dat['chain']=f"{chain} ({chainid})"
dat['address'] = address
dat['private_key'] = privkey
wallets_multichain.append(dat)
time.sleep(0.05)
return wallets_multichain
except Exception as e:
print(f"Request failed for address {address}: {e}")
return None
def gen_wallet_eth():
wallet = Account.create()
return wallet.key.hex(), wallet.address
def process_iteration():
private_key, address = gen_wallet_eth()
if not private_key or not address:
raise(Error)
wallets_info = check_address_balance_eth(address,private_key)
#wallet_info['address']=address
#wallet_info['priv_key']=private_key'
return wallets_info
def save_results(output_file,wallet_info):
try:
with open(output_file, 'a+') as f_out:
f_out.write(f"======= ETH =============")
for key, val in wallet_info.items():
f_out.write(f"{key}: {val}\n")
f_out.write("==============================\n")
except IOError as e:
we_got_problems=True
print(f"Failed to write results to {output_file}: {e}")
def main(stdscr):
stdscr.clear()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
output_file = 'wallets.txt'
num_workers = 1
MAX_Y, MAX_X = stdscr.getmaxyx()
we_got_problems=False
with ThreadPoolExecutor(max_workers=num_workers) as executor:
MAX_ITER = int(argv[1]) or 2500
future_to_iter = {executor.submit(process_iteration): i for i in range(1,MAX_ITER)}
found_wallets = 0
found_balance_total = 0
for future in as_completed(future_to_iter):
try:
wallets = future.result()
for w in wallets:
if float(w['result']) > 0:
status = Fore.GREEN + "ACTIVE!" + Style.RESET_ALL
save_results(output_file,w)
found_wallets += 1
found_balance_total += float(w['result'])
else:
status = Fore.RED + "DEAD" + Style.RESET_ALL
# Print the details with status
print(Fore.BLUE + f'Wallet data >>> {w["chain"]}' + Style.RESET_ALL )
for key, val in w.items():
if key == "result" and float(val) > 0:
key = Fore.CYAN + key + Style.RESET_ALL
val = Back.YELLOW + Fore.MAGENTA + val + Style.RESET_ALL
print(f"{key}: {val}")
print(f"Status: {status}")
print((Fore.RED + "We have got an error.." + Style.RESET_ALL ) if we_got_problems else "")
except Exception as e:
print(f"Main Program Loop failed : {e}")
we_got_problems = True
print(f"Processing complete. Results saved to {output_file}")
if __name__ == "__main__":
curses.wrapper(main)