Fix LBTC POST message signing

master
Mark Veidemanis 2 years ago
parent 644444c02f
commit b2b7b3b923
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -58,7 +58,11 @@ class AgoraDesk:
@inlineCallbacks
def callback_api_call(self, response, result):
logger.debug(response)
text = yield response.content()
try:
text = yield response.content()
except: # noqa
self.log.error(f"Error with API call")
return
try:
result["response"] = json.loads(text)
except json.decoder.JSONDecodeError:

@ -169,7 +169,7 @@ class LocalBitcoins:
response = treq.post(
api_call_url,
headers=headers,
data=json.dumps(query_values),
data=query_values,
)
else:
# response = httpx.post(
@ -581,7 +581,6 @@ class LocalBitcoins:
params["reference_type"] = reference_type
if display_reference is not None:
params["display_reference"] = display_reference
return self._api_call(
api_method=f"api/ad/{ad_id}/",
http_method="POST",

@ -551,7 +551,7 @@ class Local(util.Base):
}
if self.platform == "agora":
form["asset"] = asset
form["payment_method_details"] = (settings.Platform.PaymentMethodDetails,)
form["payment_method_details"] = settings.Platform.PaymentMethodDetails
form["online_provider"] = provider
elif self.platform == "lbtc":
form["online_provider"] = self.map_provider(provider, reverse=True)
@ -567,14 +567,13 @@ class Local(util.Base):
form["max_amount"] = round(max_amount, 2)
if self.platform == "lbtc":
form["bank_name"] = bank_name
if edit:
ad = self.api.ad(ad_id=ad_id, **form)
ad = yield self.api.ad(ad_id=ad_id, **form)
else:
ad = self.api.ad_create(**form)
ad = yield self.api.ad_create(**form)
return ad
# TODO: make async
@inlineCallbacks
def dist_countries(self, filter_asset=None):
"""
Distribute our advert into all countries and providers listed in the config.
@ -583,18 +582,22 @@ class Local(util.Base):
:rtype: bool or dict
"""
dist_list = list(self.markets.create_distribution_list(self.platform, filter_asset))
our_ads = self.enum_ads()
our_ads = yield self.enum_ads()
(
supported_currencies,
account_info,
) = self.markets.get_valid_account_details(self.platform)
# Let's get rid of the ad IDs and make it a tuple like dist_list
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
if not our_ads:
self.log.error("Could not get our ads.")
return False
to_return = []
for asset, countrycode, currency, provider in dist_list:
if (asset, countrycode, currency, provider) not in our_ads:
if currency in supported_currencies:
# Create the actual ad and pass in all the stuff
rtrn = self.create_ad(
rtrn = yield self.create_ad(
asset,
countrycode,
currency,
@ -604,9 +607,10 @@ class Local(util.Base):
# Bail on first error, let's not continue
if rtrn is False:
return False
yield rtrn
to_return.append(rtrn)
return to_return
# TODO: make async
@inlineCallbacks
def redist_countries(self):
"""
Redistribute our advert details into all our listed adverts.
@ -616,7 +620,7 @@ class Local(util.Base):
:return: False or dict with response
:rtype: bool or dict
"""
our_ads = self.enum_ads()
our_ads = yield self.enum_ads()
(
supported_currencies,
account_info,
@ -624,9 +628,10 @@ class Local(util.Base):
if not our_ads:
self.log.error("Could not get our ads.")
return False
to_return = []
for asset, ad_id, countrycode, currency, provider in our_ads:
if currency in supported_currencies:
rtrn = self.create_ad(
rtrn = yield self.create_ad(
asset,
countrycode,
currency,
@ -638,7 +643,8 @@ class Local(util.Base):
# Bail on first error, let's not continue
if rtrn is False:
return False
yield (rtrn, ad_id)
to_return.append((rtrn, ad_id))
return to_return
@inlineCallbacks
def strip_duplicate_ads(self):

@ -3,6 +3,7 @@ from json import dumps, loads
# Project imports
from settings import settings
import db
class GenericCommands(object):
@ -117,12 +118,17 @@ class GenericCommands(object):
class redist(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
for x in caller.redist_countries():
def got_redist(redist_output, msg):
for x in redist_output:
if x[0]["success"]:
msg(f"{x[0]['response']['data']['message']}: {x[1]}")
else:
msg(dumps(x[0]["response"]))
msg(dumps(x))
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux, caller):
c = caller.redist_countries()
c.addCallback(GenericCommands.redist.got_redist, msg)
class stripdupes(object):
@staticmethod
@ -432,7 +438,7 @@ class IRCCommands(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
msg(f"References: {', '.join(tx.get_refs())}")
msg(f"References: {', '.join(db.get_refs())}")
class ref(object):
name = "ref"
@ -442,7 +448,7 @@ class IRCCommands(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 2:
ref_data = tx.get_ref(spl[1])
ref_data = db.get_ref(spl[1])
if not ref_data:
msg(f"No such reference: {spl[1]}")
return
@ -456,11 +462,11 @@ class IRCCommands(object):
@staticmethod
def run(cmd, spl, length, authed, msg, agora, tx, ux):
if length == 2:
ref_data = tx.get_ref(spl[1])
ref_data = db.get_ref(spl[1])
if not ref_data:
msg(f"No such reference: {spl[1]}")
return
tx.del_ref(spl[1])
db.del_ref(spl[1])
msg(f"Deleted reference: {spl[1]}")
class arelease(object):

Loading…
Cancel
Save