-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathutils.py
executable file
·43 lines (28 loc) · 966 Bytes
/
utils.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
import requests
import config
import math
import json
def dead_response(message="Invalid Request", rid=config.rid):
return {"error": {"code": 404, "message": message}, "id": rid}
def response(result, error=None, rid=config.rid):
return {"error": error, "id": rid, "result": result}
def make_request(method, params=[]):
headers = {"content-type": "text/plain;"}
data = json.dumps({"id": config.rid, "method": method, "params": params})
try:
return requests.post(config.endpoint, headers=headers, data=data).json()
except Exception:
return dead_response()
def reward(height):
r = 1 + (math.log(1 - 0.3) / (525960 * 2))
return int((5500 * 10000) * math.pow(r, height))
def satoshis(value):
return int(value * math.pow(10, 4))
def amount(value):
return round(value / math.pow(10, 4), 4)
def is_int(string):
try:
int(string)
return True
except Exception:
return False