chatgpt/btc_tracker/kraken_fetch_client.py

43 lines
986 B
Python
Raw Normal View History

2023-01-13 22:26:31 +02:00
#!/usr/bin/python3
"""
client for kraken_fetch.py
"""
import requests
import ecdsa
import sqlite3
config_file = "./kraken_fetch_client.conf"
# Just for testing and early development
private_key = '039e1c137aa296d7af0cd55b468018ad1020949c2731e5141d032b8371490f48'
def read_config():
"""
read $config_file and returns users private key
"""
return private_key
def get_server_public_key(url):
"""
fetches the servers public key
"""
rurl = url+'/serverkey'
response = requests.get(rurl)
if response.status_code == 200: # if the fetch was success...
server_public_key = response.content
return server_public_key
# when the fetch was not successfull
print(f"Error fetching data from the server.")
return 'Error'
def fetch_data_from_the_server(url):
"""
query the kraken_fetch server for new data
"""
# we need to do some time calculations here...
response = requests.get(url)
return response