-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
129 lines (102 loc) Β· 4.28 KB
/
main.py
File metadata and controls
129 lines (102 loc) Β· 4.28 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
#!/usr/bin/env python3
"""
TON Wallet Manager - Main Application
A modular async wallet management system for TON blockchain
"""
import asyncio
from datetime import datetime
from src.utils import generate_seeds
from src.deploy import deploy_wallet
from src.transfer import transfer_from_one_to_another, transfer_from_all_to_one
from src.balance_checker import check_wallet_balances
def display_menu():
"""Display the main menu options"""
print("\n" + "="*50)
print("π΅ TON Wallet Manager")
print("="*50)
print("1. Generate new seed phrases")
print("2. Deploy wallets (activate)")
print("3. Transfer from main to all wallets")
print("4. Transfer from all wallets to main")
print("5. Check wallet balances")
print("0. Exit")
print("="*50)
async def handle_option(option: str):
"""Handle the selected menu option"""
try:
if option == "1":
# Ask user how to save seeds
print("\nThis will generate new seed phrases.")
print("How do you want to save them?")
print("1. Overwrite existing wallets.txt")
print("2. Create a new file (e.g., wallets_YYYYMMDD_HHMMSS.txt)")
choice = ""
while choice not in ["1", "2"]:
choice = input("Select an option (1-2): ").strip()
filename = "wallets.txt"
if choice == "2":
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filename = f"wallets_{timestamp}.txt"
print(f"Will create new file: {filename}")
else:
# Ask for confirmation before overwriting
confirm = input("This will overwrite wallets.txt. Are you sure? (y/n): ").lower().strip()
if confirm != 'y':
print("Operation cancelled.")
return True # To show menu again
print("Will overwrite wallets.txt")
# Get number of seeds from user
while True:
try:
num_seeds_str = input("Enter number of seeds to generate (default: 50): ").strip()
if not num_seeds_str:
num_seeds = 50
break
num_seeds = int(num_seeds_str)
if num_seeds > 0:
break
print("Please enter a positive number")
except ValueError:
print("Please enter a valid number")
# Generate seeds with chosen number and filename
await generate_seeds(num_seeds, filename)
elif option == "2":
await deploy_wallet()
elif option == "3":
await transfer_from_one_to_another()
elif option == "4":
await transfer_from_all_to_one()
elif option == "5":
await check_wallet_balances()
elif option == "0":
print("π Goodbye!")
return False
else:
print("β Invalid option! Please try again.")
except KeyboardInterrupt:
print("\n\nβ οΈ Operation cancelled by user")
except Exception as e:
print(f"\nβ Error: {str(e)}")
print("Please try again or contact support if the issue persists")
return True
async def main():
"""Main application loop"""
print("π Starting TON Wallet Manager...")
try:
while True:
display_menu()
option = input("Select an option (0-5): ").strip()
# Handle the option
should_continue = await handle_option(option)
if not should_continue:
break
# Pause before showing menu again
input("\nPress Enter to continue...")
except KeyboardInterrupt:
print("\n\nπ Application terminated by user")
except Exception as e:
print(f"\nπ₯ Fatal error: {str(e)}")
print("Application will exit")
if __name__ == "__main__":
# Run the async main function
asyncio.run(main())