always request exchange rates over https
This commit is contained in:
parent
1b868a9753
commit
a42743ca2d
|
@ -67,27 +67,6 @@ class Exchanger(threading.Thread):
|
||||||
raise
|
raise
|
||||||
return json_resp
|
return json_resp
|
||||||
|
|
||||||
def get_json_insecure(self, site, get_string):
|
|
||||||
""" get_json_insecure shouldn't be used in production releases
|
|
||||||
It doesn't use SSL, and so prices could be manipulated by a middle man
|
|
||||||
This should be used ONLY when developing plugins when you don't have a
|
|
||||||
SSL certificate that validates against HTTPSConnection
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
connection = httplib.HTTPConnection(site)
|
|
||||||
connection.request("GET", get_string, headers={"User-Agent":"Electrum"})
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
resp = connection.getresponse()
|
|
||||||
if resp.reason == httplib.responses[httplib.NOT_FOUND]:
|
|
||||||
raise
|
|
||||||
try:
|
|
||||||
json_resp = json.loads(resp.read())
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
return json_resp
|
|
||||||
|
|
||||||
|
|
||||||
def exchange(self, btc_amount, quote_currency):
|
def exchange(self, btc_amount, quote_currency):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if self.quote_currencies is None:
|
if self.quote_currencies is None:
|
||||||
|
@ -342,8 +321,7 @@ class Exchanger(threading.Thread):
|
||||||
|
|
||||||
def update_bv(self):
|
def update_bv(self):
|
||||||
try:
|
try:
|
||||||
jsonresp = self.get_json_insecure('api.bitcoinvenezuela.com', "/")
|
jsonresp = self.get_json('api.bitcoinvenezuela.com', "/")
|
||||||
print("**WARNING**: update_bv is using an insecure connection, shouldn't be used on production")
|
|
||||||
except SSLError:
|
except SSLError:
|
||||||
print("SSL Error when accesing bitcoinvenezuela")
|
print("SSL Error when accesing bitcoinvenezuela")
|
||||||
return
|
return
|
||||||
|
@ -364,15 +342,13 @@ class Exchanger(threading.Thread):
|
||||||
|
|
||||||
def update_bpl(self):
|
def update_bpl(self):
|
||||||
try:
|
try:
|
||||||
jsonresp = self.get_json_insecure('btcparalelo.com', "/api/price")
|
jsonresp = self.get_json('btcparalelo.com', "/api/price")
|
||||||
print("**WARNING**: update_bpl is using an insecure connection, shouldn't be used on production")
|
|
||||||
except SSLError:
|
except SSLError:
|
||||||
print("SSL Error when accesing btcparalelo")
|
print("SSL Error when accesing btcparalelo")
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
quote_currencies = {}
|
quote_currencies = {}
|
||||||
try:
|
try:
|
||||||
quote_currencies = {"VEF": Decimal(jsonresp["price"])}
|
quote_currencies = {"VEF": Decimal(jsonresp["price"])}
|
||||||
|
|
Loading…
Reference in New Issue