-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
47 lines (33 loc) · 1.18 KB
/
test.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
import time
from AlphaProof import Client
API_KEY = "--API--KEY--"
BASE_URL = "--URL--"
TIME_OPEN = "16:11 CEST"
PRICE_OPEN = str(6725.0)
EXCHANGE = "bitstamp"
def main():
client = Client(API_KEY, BASE_URL)
''' Make cleartext commit-reveal
'''
response = client.commit("BUY", PRICE_OPEN, EXCHANGE, TIME_OPEN)
print("\n" + str(response))
time.sleep(90) # wait for transaction to be mined
response = client.open_commits()
print("\n" + str(response))
response = client.reveal()
print("\n" + str(response))
time.sleep(90) # wait for transaction to be mined
''' Make encrypted commit-reveal
'''
encr_key, response = client.commit_encrypted("BUY", PRICE_OPEN, EXCHANGE, TIME_OPEN)
index = response["index"]
print("\n" + str(response))
print("encryption key used: " + str(encr_key))
time.sleep(90) # wait for transaction to be mined
response = client.open_commits()
print("\n" + str(response))
response = client.reveal_encrypted(encr_key, "BUY", PRICE_OPEN, EXCHANGE, TIME_OPEN, index)
print("\n" + str(response))
time.sleep(90) # wait for transaction to be mined
if __name__ == "__main__":
main()