-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlisk-autotoggler.py
48 lines (31 loc) · 1.05 KB
/
lisk-autotoggler.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
import json
import datetime
import requests
import os
# Change to custom address if not using local node
node = 'http://127.0.0.1'
# Mainnet = :8000
# Testnet = :7000
# Betanet = :5000
network_port = ':8000'
# Password used while creating encrypted password
password = ''
# Publickey of your address
publickey = ''
def main():
url = node + network_port + '/api/node/status/forging'
response = requests.get(url)
json_data = response.json()
if json_data['data'][0]['forging'] == True:
message = "Forging was already enabled. No actions taken."
else:
headers = {
'Content-Type': 'application/json',
}
data = '{"password":"%s", "forging": true, "publicKey":"%s"}' % (password, publickey)
response = requests.put(url, headers=headers, data=data, verify=False)
message = "Forging was disabled. Toggled status to 'true'."
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "lisk-autotoggler.log"), "a") as text_file:
text_file.write("%s - %s\n" % (datetime.datetime.now(), message))
if __name__ == "__main__":
main()