-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfleet_status.py
More file actions
133 lines (107 loc) · 3.93 KB
/
Copy pathfleet_status.py
File metadata and controls
133 lines (107 loc) · 3.93 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
#!/usr/bin/env python3
"""
fleet_status.py — Quick status check for all configured bots.
Shows balance, tier, mining eligibility, and staking for each bot.
Usage:
python fleet_status.py
python fleet_status.py --config path/to/config.json
"""
import json
import sys
import uuid
import argparse
from pathlib import Path
try:
from litcoin import Agent
from litcoin.api import APIError
except ImportError:
print("ERROR: litcoin package not installed. Run: pip install litcoin")
sys.exit(1)
def load_config(path="config.json"):
p = Path(path)
if not p.exists():
print(f"ERROR: Config file not found: {path}")
print("Copy config.example.json to config.json and fill in your values.")
sys.exit(1)
with open(p) as f:
return json.load(f)
def check_bot(bot_cfg):
"""Check status for a single bot. Returns a dict of results."""
name = bot_cfg["name"]
result = {"name": name, "error": None}
try:
agent = Agent(bot_cfg["api_key"])
# Balance
bal = agent.balance()
result["free_lit"] = bal.get("litcoin", 0)
# Staking
try:
stk = agent.stake_info()
result["staked"] = stk.get("amount", 0)
result["tier"] = stk.get("tier", 0)
result["locked_until"] = stk.get("lockedUntil", None)
except Exception:
result["staked"] = 0
result["tier"] = 0
result["total"] = result["free_lit"] + result["staked"]
# Mining boost
try:
result["boost"] = agent.mining_boost()
except Exception:
result["boost"] = 0
# Mining eligibility check
nonce = uuid.uuid4().hex[:32]
try:
ch = agent.api.get_challenge(nonce, agent.auth.token)
result["earned_today"] = ch.get("earnedToday", 0)
result["daily_cap"] = ch.get("dailyCap", 0)
if ch.get("capped"):
result["mining_status"] = "CAPPED"
elif ch.get("poolExhausted"):
result["mining_status"] = "POOL_EXHAUSTED"
else:
result["mining_status"] = "READY"
except APIError as e:
if "Insufficient" in str(e.message):
result["mining_status"] = "BLOCKED (insufficient balance)"
else:
result["mining_status"] = f"ERROR: {e.message}"
except Exception as e:
result["mining_status"] = f"ERROR: {e}"
except Exception as e:
result["error"] = str(e)
return result
def main():
parser = argparse.ArgumentParser(description="Check LITCOIN fleet status")
parser.add_argument("--config", default="config.json", help="Path to config file")
args = parser.parse_args()
config = load_config(args.config)
bots = [b for b in config.get("bots", []) if b.get("enabled", True)]
if not bots:
print("No enabled bots found in config.")
sys.exit(1)
print(f"{'='*60}")
print(f" LITCOIN Fleet Status — {len(bots)} bot(s)")
print(f"{'='*60}")
for bot_cfg in bots:
result = check_bot(bot_cfg)
name = result["name"]
if result.get("error"):
print(f"\n {name}: ERROR — {result['error']}")
continue
free = result.get("free_lit", 0)
staked = result.get("staked", 0)
total = result.get("total", 0)
tier = result.get("tier", 0)
boost = result.get("boost", 0)
mining = result.get("mining_status", "UNKNOWN")
earned = result.get("earned_today", 0)
cap = result.get("daily_cap", 0)
print(f"\n {name}")
print(f" Balance: {free:>12,.0f} free | {staked:>12,.0f} staked | {total:>12,.0f} total")
print(f" Tier: {tier} Boost: {boost/100:.0f}%")
print(f" Mining: {mining}")
print(f" Earned: {earned:,.0f} / {cap:,.0f} daily cap")
print(f"\n{'='*60}")
if __name__ == "__main__":
main()