api: Add include_sent offers filter.

This commit is contained in:
tecnovert 2023-01-11 10:28:57 +02:00
parent 9729dcf526
commit 553af1a3e8
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
7 changed files with 19 additions and 7 deletions

View file

@ -1,3 +1,3 @@
name = "basicswap"
__version__ = "0.11.57"
__version__ = "0.11.58"

View file

@ -5838,6 +5838,9 @@ class BasicSwap(BaseApp):
filter_coin_to = filters.get('coin_to', None)
if filter_coin_to and filter_coin_to > -1:
q = q.filter(Offer.coin_to == int(filter_coin_to))
filter_include_sent = filters.get('include_sent', None)
if filter_include_sent and filter_include_sent is not True:
q = q.filter(Offer.was_sent == False) # noqa: E712
order_dir = filters.get('sort_dir', 'desc')
order_by = filters.get('sort_by', 'created_at')

View file

@ -171,6 +171,8 @@ def js_offers(self, url_split, post_string, is_json, sent=False) -> bytes:
assert (filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit'
if have_data_entry(post_data, 'active'):
filters['active'] = get_data_entry(post_data, 'active')
if have_data_entry(post_data, 'include_sent'):
filters['include_sent'] = toBool(get_data_entry(post_data, 'include_sent'))
offers = swap_client.listOffers(sent, filters)
rv = []

View file

@ -47,6 +47,8 @@ def ensure(v, err_string):
def toBool(s) -> bool:
if isinstance(s, bool):
return s
return s.lower() in ['1', 'true']

View file

@ -663,7 +663,7 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}):
for key in rv.fingerprints:
gpg.trust_keys(rv.fingerprints[0], 'TRUST_FULLY')
if coin in ('pivx', 'firo'):
if coin in ('firo', ):
pubkey_filename = '{}_{}.pgp'.format('particl', signing_key_name)
else:
pubkey_filename = '{}_{}.pgp'.format(coin, signing_key_name)

View file

@ -117,15 +117,15 @@
(define-public basicswap
(package
(name "basicswap")
(version "0.11.55")
(version "0.11.58")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/tecnovert/basicswap")
(commit "ac07727da7ec0f6bf2df832843dcaafc7dd7046a")))
(commit "9729dcf526917eb5e128dd72b091464d1e72fe54")))
(sha256
(base32
"1xg70jyvggkcr0la7lnj96w34pxrr0sp59d174jpgmlfs625ybbk"))
"0sjxk4c9vzn5fr8dqxrmvgw1267njjkblajxvqf3kls5b2s7l41k"))
(file-name (git-file-name name version))))
(build-system python-build-system)

View file

@ -75,6 +75,7 @@ def readTemplates(known_coins):
offer_template['minrate'] = float(row_data[3])
offer_template['ratetweakpercent'] = float(row_data[4])
offer_template['amount_variable'] = row_data[5].lower() in ('true', 1)
offer_template['address'] = row_data[6]
offer_templates.append(offer_template)
except Exception as e:
print(f'Warning: Skipping row {i}, {e}')
@ -91,7 +92,8 @@ def main():
if not os.path.exists('offer_rules.csv'):
with open('offer_rules.csv', 'w') as fp:
fp.write('coin from,coin to,offer value,min rate,rate tweak percent,amount variable')
# Set address to -1 to use new addresses
fp.write('coin from,coin to,offer value,min rate,rate tweak percent,amount variable,address')
known_coins = read_json_api(args.port, 'coins')
coins_map = {}
@ -104,6 +106,9 @@ def main():
offer_templates = readTemplates(known_coins)
try:
recieved_offers = read_json_api(args.port, 'offers', {'active': 'active', 'include_sent': False})
print('recieved_offers', recieved_offers)
sent_offers = read_json_api(args.port, 'sentoffers', {'active': 'active'})
for offer_template in offer_templates:
@ -133,7 +138,7 @@ def main():
print('Creating offer for: {} at rate: {}'.format(offer_template, use_rate))
offer_data = {
'addr_from': '-1',
'addr_from': offer_template['address'],
'coin_from': coin_from_data['ticker'],
'coin_to': coin_to_data['ticker'],
'amt_from': offer_template['amount'],