-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfirmation_info.py
executable file
·66 lines (48 loc) · 1.75 KB
/
confirmation_info.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
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
#!/usr/bin/env python3
# Create a random seed and a wallet using the seed created
import requests
import json
import argparse
import common
def parse_args():
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
group.add_argument('-b', '--beta', action='store_true', default=False,
help='use beta network')
group.add_argument('-t', '--test', action='store_true', default=False,
help='use test network')
parser.add_argument('--rpc',
help='RPC URL to contact')
parser.add_argument('-r', '--root',
help='root to enquire about')
parser.add_argument('-R', '--representatives', action='store_true', default=False,
help='request representative details')
parser.add_argument('-c', '--nocontents', action='store_true', default=False,
help='do not request contents')
return parser.parse_args()
args = parse_args()
rpc_url = common.get_rpc_url(args)
print('RPC URL = %s' % rpc_url)
session = requests.Session()
if args.root != None:
roots = [args.root]
else:
# if a root was not given, then get roots via confirmation_active
params = {
'action': 'confirmation_active',
}
result = common.post(session, params, rpc_url)
print(json.dumps(result, indent=4))
roots = result['confirmations']
for root in roots:
params = {
'action': 'confirmation_info',
'json_block': 'true',
'root': root
}
if args.nocontents:
params['contents'] = 'false'
if args.representatives:
params['representatives'] = 'true'
result = common.post(session, params, rpc_url)
print(json.dumps(result, indent=4))