提交代码
This commit is contained in:
87
ton/gpt 优化后的速度版本.py
Normal file
87
ton/gpt 优化后的速度版本.py
Normal file
@@ -0,0 +1,87 @@
|
||||
import random
|
||||
import asyncio
|
||||
import aiohttp
|
||||
from loguru import logger
|
||||
|
||||
from tonutils.client import ToncenterV3Client
|
||||
from tonutils.utils import to_amount
|
||||
from tonutils.wallet import WalletV4R2
|
||||
|
||||
# 日志尽量减少 IO
|
||||
logger.add("wallet_log_{time:YYYY-MM-DD}.log", rotation="1 day", retention="30 days")
|
||||
|
||||
API_KEY = "AFMEX4F23ZRPOUIAAAAPHGIE5QECWZA5M75E54VD72O5IJEGP5IW3LOTXO7Z4QOX7MV6JQQ"
|
||||
IS_TESTNET = False
|
||||
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"authorization": "Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6US",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "Mozilla/5.0",
|
||||
}
|
||||
|
||||
# 全局复用 Toncenter client
|
||||
client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=10, max_retries=1)
|
||||
|
||||
|
||||
async def get_balance(session, address: str):
|
||||
url = f"https://tonapi.io/v2/accounts/{address}"
|
||||
|
||||
for _ in range(8): # 降低重试次数提升速度
|
||||
try:
|
||||
async with session.get(url, headers=headers, timeout=3) as r:
|
||||
data = await r.json()
|
||||
return to_amount(int(data.get("balance", 0)))
|
||||
except Exception:
|
||||
await asyncio.sleep(0.05) # 小延迟即可
|
||||
return None
|
||||
|
||||
|
||||
async def handle_wallet(session, idx: int):
|
||||
wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
|
||||
address = wallet.address.to_str(
|
||||
is_user_friendly=True,
|
||||
is_url_safe=True,
|
||||
is_bounceable=False,
|
||||
is_test_only=False
|
||||
)
|
||||
|
||||
balance = await get_balance(session, address)
|
||||
|
||||
if balance:
|
||||
logger.info(f"[{idx}] Balance={balance} | {address} | Mnemonic={' '.join(mnemonic)}")
|
||||
else:
|
||||
print(f"[{idx}] 余额查询失败 | {address},余额:{balance}")
|
||||
|
||||
|
||||
async def worker(worker_id, session, queue):
|
||||
while True:
|
||||
idx = await queue.get()
|
||||
await handle_wallet(session, idx)
|
||||
queue.task_done()
|
||||
|
||||
|
||||
async def main():
|
||||
queue = asyncio.Queue()
|
||||
|
||||
# 单一 Session 复用,性能最优
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
||||
# 启动固定数量 Worker,提高并行效率
|
||||
workers = [asyncio.create_task(worker(i, session, queue)) for i in range(20)]
|
||||
|
||||
counter = 0
|
||||
while True:
|
||||
counter += 1
|
||||
await queue.put(counter)
|
||||
|
||||
# 控制生成速度
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
for w in workers:
|
||||
w.cancel()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
# .\xray.exe -c .\1_5000_client_am_ip_1v1.json
|
||||
100
ton/ton 优化速度版本.py
Normal file
100
ton/ton 优化速度版本.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import random
|
||||
import threading
|
||||
import time
|
||||
import asyncio
|
||||
import aiohttp
|
||||
from loguru import logger
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from tonutils.client import TonapiClient, ToncenterV3Client
|
||||
from tonutils.utils import to_amount
|
||||
from tonutils.wallet import (
|
||||
WalletV3R1,
|
||||
WalletV3R2,
|
||||
WalletV4R1,
|
||||
WalletV4R2,
|
||||
WalletV5R1,
|
||||
HighloadWalletV2,
|
||||
HighloadWalletV3,
|
||||
)
|
||||
|
||||
# 配置日志文件输出
|
||||
# 按天分割日志文件,文件名包含日期,保留所有日志文件
|
||||
logger.add("wallet_log_{time:YYYY-MM-DD}.log", rotation="1 day", retention="9999 days")
|
||||
|
||||
# API key for accessing the Tonapi (obtainable from https://tonconsole.com)
|
||||
API_KEY = "AFMEX4F23ZRPOUIAAAAPHGIE5QECWZA5M75E54VD72O5IJEGP5IW3LOTXO7Z4QOX7MV6JQQ"
|
||||
|
||||
# Set to True for test network, False for main network
|
||||
IS_TESTNET = False
|
||||
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/json',
|
||||
'dnt': '1',
|
||||
'origin': 'https://tonviewer.com',
|
||||
'pragma': 'no-cache',
|
||||
'priority': 'u=1, i',
|
||||
'referer': 'https://tonviewer.com/',
|
||||
'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'cross-site',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0',
|
||||
}
|
||||
|
||||
|
||||
async def get_ton_num_async(session, address):
|
||||
for i in range(3):
|
||||
try:
|
||||
async with session.get(
|
||||
f'https://tonapi.io/v2/accounts/{address}',
|
||||
headers=headers
|
||||
) as response:
|
||||
data = await response.json()
|
||||
return to_amount(int(data["balance"]))
|
||||
except Exception as e:
|
||||
await asyncio.sleep(random.random())
|
||||
return False
|
||||
|
||||
|
||||
async def main(i) -> None:
|
||||
client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=3, max_retries=3)
|
||||
wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
balance = await get_ton_num_async(session, wallet.address.to_str(is_user_friendly=True, is_url_safe=True,
|
||||
is_bounceable=False, is_test_only=False))
|
||||
if balance:
|
||||
logger.info(
|
||||
f"余额:{balance} Address: {wallet.address.to_str(is_user_friendly=True, is_url_safe=True, is_bounceable=False, is_test_only=False)},D:{' '.join(mnemonic)},")
|
||||
else:
|
||||
|
||||
print(
|
||||
f"{i},余额:{balance} Address: {wallet.address.to_str(is_user_friendly=True, is_url_safe=True, is_bounceable=False, is_test_only=False)},D:{' '.join(mnemonic)},")
|
||||
|
||||
|
||||
async def run_tasks():
|
||||
tasks = []
|
||||
|
||||
n = 0
|
||||
while True:
|
||||
|
||||
n += 1
|
||||
|
||||
task = asyncio.create_task(main(i=n))
|
||||
tasks.append(task)
|
||||
await asyncio.sleep(random.random())
|
||||
# 可以根据实际情况设置任务数量上限,避免创建过多任务
|
||||
if len(tasks) > 100:
|
||||
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
|
||||
tasks = list(pending)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_tasks())
|
||||
116
ton/ton 撞助记词.py
Normal file
116
ton/ton 撞助记词.py
Normal file
@@ -0,0 +1,116 @@
|
||||
import random
|
||||
import threading
|
||||
import time
|
||||
import asyncio
|
||||
|
||||
import requests
|
||||
from loguru import logger
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from tonutils.client import TonapiClient, ToncenterV3Client
|
||||
from tonutils.utils import to_amount
|
||||
from tonutils.wallet import (
|
||||
WalletV3R1,
|
||||
# Uncomment the following lines to use different wallet versions:
|
||||
WalletV3R2,
|
||||
WalletV4R1,
|
||||
WalletV4R2,
|
||||
WalletV5R1,
|
||||
HighloadWalletV2,
|
||||
HighloadWalletV3,
|
||||
)
|
||||
|
||||
# 配置日志文件输出
|
||||
# 按天分割日志文件,文件名包含日期,保留所有日志文件
|
||||
logger.add("wallet_log_{time:YYYY-MM-DD}.log", rotation="1 day", retention="9999 days")
|
||||
|
||||
# API key for accessing the Tonapi (obtainable from https://tonconsole.com)
|
||||
API_KEY = "AFMEX4F23ZRPOUIAAAAPHGIE5QECWZA5M75E54VD72O5IJEGP5IW3LOTXO7Z4QOX7MV6JQQ"
|
||||
|
||||
# Set to True for test network, False for main network
|
||||
IS_TESTNET = False
|
||||
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/json',
|
||||
'dnt': '1',
|
||||
'origin': 'https://tonviewer.com',
|
||||
'pragma': 'no-cache',
|
||||
'priority': 'u=1, i',
|
||||
'referer': 'https://tonviewer.com/',
|
||||
'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'cross-site',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0',
|
||||
}
|
||||
|
||||
|
||||
def get_ton_num(address):
|
||||
headers = {
|
||||
'accept': '*/*',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'authorization': 'Bearer AFPJTKEBPOX3AIYAAAAKA2HWOTRNJP5MUCV5DMDCZAAOCPSAYEYS3CILNQVLF2HWKED6USY',
|
||||
'cache-control': 'no-cache',
|
||||
'content-type': 'application/json',
|
||||
'dnt': '1',
|
||||
'origin': 'https://tonviewer.com',
|
||||
'pragma': 'no-cache',
|
||||
'priority': 'u=1, i',
|
||||
'referer': 'https://tonviewer.com/',
|
||||
'sec-ch-ua': '"Not A(Brand";v="8", "Chromium";v="132", "Microsoft Edge";v="132"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'cross-site',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0',
|
||||
}
|
||||
|
||||
for i in range(3):
|
||||
try:
|
||||
response = requests.get(
|
||||
f'https://tonapi.io/v2/accounts/{address}',
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
return to_amount(int(response.json()["balance"]))
|
||||
except:
|
||||
time.sleep(random.random())
|
||||
|
||||
return False
|
||||
|
||||
|
||||
async def main(i) -> None:
|
||||
client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=2, max_retries=1)
|
||||
wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
|
||||
|
||||
for i1 in range(5):
|
||||
try:
|
||||
response = requests.get(
|
||||
f'https://tonapi.io/v2/accounts/{wallet.address.to_str(is_user_friendly=True, is_url_safe=True, is_bounceable=False, is_test_only=False)}',
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"余额:{to_amount(int(response.json()["balance"]))} Address: {wallet.address.to_str(is_user_friendly=True, is_url_safe=True, is_bounceable=False, is_test_only=False)},D:{' '.join(mnemonic)},")
|
||||
|
||||
break
|
||||
except:
|
||||
time.sleep(random.random())
|
||||
|
||||
|
||||
def main1(i):
|
||||
asyncio.run(main(i))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with ThreadPoolExecutor(max_workers=100) as executor:
|
||||
while True:
|
||||
executor.submit(main1, "grfreg")
|
||||
time.sleep(random.random())
|
||||
42
ton/ton 生成助记词.py
Normal file
42
ton/ton 生成助记词.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from tonutils.client import ToncenterV3Client
|
||||
from tonutils.wallet import (
|
||||
# Uncomment the following lines to use different wallet versions:
|
||||
# WalletV2R1,
|
||||
# WalletV2R2,
|
||||
# WalletV3R1,
|
||||
# WalletV3R2,
|
||||
# WalletV4R1,
|
||||
WalletV4R2,
|
||||
# WalletV5R1,
|
||||
# HighloadWalletV2,
|
||||
# HighloadWalletV3,
|
||||
# PreprocessedWalletV2,
|
||||
# PreprocessedWalletV2R1,
|
||||
)
|
||||
|
||||
# Set to True for test network, False for main network
|
||||
IS_TESTNET = True
|
||||
|
||||
|
||||
def main() -> None:
|
||||
client = ToncenterV3Client(is_testnet=IS_TESTNET, rps=3, max_retries=3)
|
||||
wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
|
||||
|
||||
# Uncomment and use the following lines to create different wallet versions:
|
||||
# wallet, public_key, private_key, mnemonic = WalletV3R2.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = WalletV4R1.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = WalletV4R2.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = WalletV5R1.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = HighloadWalletV2.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = HighloadWalletV3.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = PreprocessedWalletV2.create(client)
|
||||
# wallet, public_key, private_key, mnemonic = PreprocessedWalletV2R1.create(client)
|
||||
|
||||
print("Wallet has been successfully created!")
|
||||
print(f"Address: {wallet.address.to_str()}")
|
||||
print(f"Mnemonic: {mnemonic}")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user