-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientEndpoints.py
60 lines (55 loc) · 2.47 KB
/
ClientEndpoints.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
def logInToPasswordEncryptedAccount_ClientEndpoint(Chain, AccountName, Password, auth):
import requests, uuid
url = "http://localhost:3031/v0.0.1/requests/" #server private requests url
ID = str(uuid.uuid4())
headers = {"Authorization": "Bearer " + auth}
requestobj = {
"id": ID,
"request_type": "logInToPasswordEncryptedAccount",
"Chain": Chain,
"AccountName": AccountName,
"Password": Password
}
print(requests.post(url, headers=headers, json = requestobj).text)
def submitEncryptedResponse_ClientEndpoint(url, SwapTicketID, ENC_response_path):
import requests, uuid
ID = str(uuid.uuid4())
headers = {"Authorization": "None"}
resp = file_tools.clean_file_open(ENC_response_path, "r")
requestobj = {
"id": ID,
"request_type":"submitEncryptedResponse",
"SwapTicketID":SwapTicketID,
"encryptedResponseBIN": resp
}
respStr = requests.post(url, headers=headers, json = requestobj).text.replace("\"", "").replace("\\", "\n").replace("n", "")
file_tools.clean_file_open(SwapTicketID + "/ENC_finalization.bin", "w", respStr)
responderJSONPath = SwapTicketID + "/responder.json"
responderInterface.GeneralizedENC_ResponderClaimSubroutine(responderJSONPath)
def requestEncryptedInitiation_ClientEndpoint(url, OrderTypeUUID, ElGamalPubkey):
import requests, uuid
ID = str(uuid.uuid4())
headers = {"Authorization": "None"}
requestobj = {
"id": ID,
"request_type":"requestEncryptedInitiation",
"OrderTypeUUID":OrderTypeUUID,
"ElGamalKey":ElGamalPubkey,
}
respStr = requests.post(url, headers=headers, json = requestobj).text
respObj = json.loads(respStr[1:-1].encode().decode('unicode_escape'))
swapname = respObj["SwapTicketID"]
file_tools.clean_mkdir(swapname) #swapname
file_tools.clean_file_open(respObj["SwapTicketID"] + "/ENC_init.bin", "w", respObj["ENC_init.bin"])
def submitEncryptedResponse_ClientEndpoint(swapID, marketPublicRequestsURL, ENC_response, auth):
import requests, uuid
url = marketPublicRequestsURL #server private requests url
ID = str(uuid.uuid4())
headers = {"Authorization": "Bearer " + auth}
requestobj = {
"id": ID,
"request_type": "submitEncryptedResponse",
"SwapTicketID": swapID,
"encryptedResponseBIN": ENC_response
}
return requests.post(url, headers=headers, json = requestobj).text