-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
38 lines (30 loc) · 799 Bytes
/
common.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
import json
import requests
import sys
regtest = True
debug = True
allow_big_fee = False
amount_to_receive = 30
amount_to_send_offline_to_online = 20
default_tx_fee = 0.0002
def request(url, payload):
resp = requests.post(
url, data=json.dumps(payload), headers={'content-type': 'application/json'}
).json()
if resp["error"] is not None:
print "ERROR!!!"
print payload
print resp["error"]
sys.exit(1)
return resp
# a qrcode image can have more than just a qrcode (ie EAN-13)
# so lets make sure we just grab what we want
def get_qrcode_val_from_str(s):
codes = s.split('\n')
key = "a"
i = 0
while key != "QR-Code":
key = codes[i].split(":")[0]
val = codes[i].split(":")[1]
i += 1
return val