forked from sigwo/pywavestools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrichlist.py
35 lines (31 loc) · 1018 Bytes
/
richlist.py
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
import requests
import argparse
NODE = 'http://localhost:6869'
API_KEY = ''
parser = argparse.ArgumentParser(description='Waves Rich List')
parser.add_argument('-t', '--top', type=int, help='lists only the specified top positions')
args = parser.parse_args()
if args.top:
top = args.top
else:
top = -1
states = requests.get('%s/debug/state' % NODE, headers={ "api_key": API_KEY}).json()
print("-" * 64)
print(str.center("Waves Rich List", 64))
if top > 0:
print(str.center("Top %d balances" % top, 64))
print(" # Address Balance")
print("-" * 64)
n = 0
total_balance = 0
for i in sorted(states.items(), key=lambda x: -x[1]):
balance = i[1]
if len(i[0]) == 35 and balance > 0:
address = i[0]
total_balance += balance
n += 1
print("%6d %-38s %18.8f " % (n, address, balance / 1e8))
if n == top:
break
print("-" * 64)
print(" %18.8f" % (total_balance / 1e8))