diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 3b1da83..962203b 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -36,7 +36,7 @@ from .interface.part import PARTInterface, PARTInterfaceAnon, PARTInterfaceBlind from . import __version__ from .rpc import escape_rpcauth from .rpc_xmr import make_xmr_rpc2_func -from .ui.util import getCoinName +from .ui.util import getCoinName, known_chart_coins from .util import ( AutomationConstraint, LockedCoinError, @@ -6484,6 +6484,25 @@ class BasicSwap(BaseApp): settings_copy.pop('coingecko_api_key') settings_changed = True + if 'enabled_chart_coins' in data: + new_value = data['enabled_chart_coins'].strip() + ensure(isinstance(new_value, str), 'New enabled_chart_coins value not a string') + if new_value.lower() == 'all' or new_value == '': + pass + else: + tickers = new_value.split(',') + seen_tickers = [] + for ticker in tickers: + upcased_ticker = ticker.strip().upper() + if upcased_ticker not in known_chart_coins: + raise ValueError(f'Unknown coin: {ticker}') + if upcased_ticker in seen_tickers: + raise ValueError(f'Duplicate coin: {ticker}') + seen_tickers.append(upcased_ticker) + if settings_copy.get('enabled_chart_coins', '') != new_value: + settings_copy['enabled_chart_coins'] = new_value + settings_changed = True + if settings_changed: settings_path = os.path.join(self.data_dir, cfg.CONFIG_FILENAME) settings_path_new = settings_path + '.new' diff --git a/basicswap/templates/header.html b/basicswap/templates/header.html index 81e9861..484a0b6 100644 --- a/basicswap/templates/header.html +++ b/basicswap/templates/header.html @@ -1,6 +1,5 @@ -{% from 'style.html' import notifications_network_offer_svg, notifications_bid_accepted_svg, notifications_unknow_event_svg, notifications_new_bid_on_offer_svg, notifications_close_svg, swap_in_progress_mobile_svg, wallet_svg, page_back_svg, order_book_svg, new_offer_svg, settings_svg, asettings_svg, cog_svg, rpc_svg, debug_svg, explorer_svg, tor_svg, smsg_svg, outputs_svg, automation_svg, shutdown_svg, notifications_svg, debug_nerd_svg, wallet_locked_svg, mobile_menu_svg, wallet_unlocked_svg, tor_purple_svg, sun_svg, moon_svg, swap_in_progress_svg, swap_in_progress_green_svg, available_bids_svg, your_offers_svg, bids_received_svg, bids_sent_svg, header_arrow_down_svg, love_svg %} - +{% from 'style.html' import notifications_network_offer_svg, notifications_bid_accepted_svg, notifications_unknow_event_svg, notifications_new_bid_on_offer_svg, notifications_close_svg, swap_in_progress_mobile_svg, wallet_svg, page_back_svg, order_book_svg, new_offer_svg, settings_svg, asettings_svg, cog_svg, rpc_svg, debug_svg, explorer_svg, tor_svg, smsg_svg, outputs_svg, automation_svg, shutdown_svg, notifications_svg, debug_nerd_svg, wallet_locked_svg, mobile_menu_svg, wallet_unlocked_svg, tor_purple_svg, sun_svg, moon_svg, swap_in_progress_svg, swap_in_progress_green_svg, available_bids_svg, your_offers_svg, bids_received_svg, bids_sent_svg, header_arrow_down_svg, love_svg %} @@ -340,16 +339,16 @@
{% if summary.num_swapping != 0 %} - {{ swap_in_progress_green_svg | safe }} - {% else %} + {{ swap_in_progress_green_svg | safe }} + {% else %} {{ swap_in_progress_svg | safe }} - {% endif %} + {% endif %}
Swaps in Progress {{ summary.num_swapping }}
- +
  • diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index b8683e8..72419b6 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -66,69 +66,73 @@
    -
    -
    -
    -
    +{% if 'BTC' in enabled_chart_coins %} +
    +
    + +
    +
    +
    + Bitcoin +

    + Bitcoin (BTC) +

    +
    +
    +

    + + +

    +
    +
    +
    +
    +
    +
    + VOL: +
    +
    +
    +
    +
    +
    +{% endif %} +{% if 'XMR' in enabled_chart_coins %} +
    +
    - Bitcoin + Monero

    - Bitcoin (BTC) + Monero (XMR)

    -

    +

    - +

    -
    +
    VOL: -
    +
    -
    +
    + BTC: + + +
    - -
    -
    -
    - Monero -

    - Monero (XMR) -

    -
    -
    -

    - - -

    -
    -
    -
    -
    -
    -
    - VOL: -
    -
    -
    -
    - BTC: - - -
    -
    -
    -
    - -
    +
    +{% endif %} +{% if 'PART' in enabled_chart_coins %} +
    Particl @@ -160,7 +164,8 @@
    - +{% endif %} +{% if 'LTC' in enabled_chart_coins %}
    @@ -192,9 +197,10 @@
    -
    - -
    +
    +{% endif %} +{% if 'FIRO' in enabled_chart_coins %} +
    Firo @@ -226,11 +232,12 @@
    - +{% endif %} +{% if 'PIVX' in enabled_chart_coins %}
    - Pivx + PIVX

    PIVX (PIVX)

    @@ -259,7 +266,8 @@
    - +{% endif %} +{% if 'DASH' in enabled_chart_coins %}
    @@ -292,7 +300,8 @@
    - +{% endif %} +{% if 'ETH' in enabled_chart_coins %}
    @@ -325,7 +334,8 @@
    - +{% endif %} +{% if 'DOGE' in enabled_chart_coins %}
    @@ -358,7 +368,8 @@
    - +{% endif %} +{% if 'DCR' in enabled_chart_coins %}
    @@ -391,7 +402,8 @@
    - +{% endif %} +{% if 'ZANO' in enabled_chart_coins %}
    @@ -424,7 +436,8 @@
    - +{% endif %} +{% if 'WOW' in enabled_chart_coins %}
    @@ -457,17 +470,25 @@
    - +{% endif %}
    {% include 'footer.html' %} - \ No newline at end of file + diff --git a/basicswap/templates/unlock.html b/basicswap/templates/unlock.html index e177863..0468ab5 100644 --- a/basicswap/templates/unlock.html +++ b/basicswap/templates/unlock.html @@ -103,8 +103,8 @@ Help / Tutorials

    - {{ title }} - GUI 2.0.2 -

    + {{ title }} - GUI 3.0.0 +

    @@ -187,4 +187,4 @@ passwordToggle.addEventListener('change', function() { - \ No newline at end of file + diff --git a/basicswap/ui/page_offers.py b/basicswap/ui/page_offers.py index 7c05b26..7682040 100644 --- a/basicswap/ui/page_offers.py +++ b/basicswap/ui/page_offers.py @@ -9,14 +9,15 @@ import time from urllib import parse from .util import ( - PAGE_LIMIT, getCoinType, - inputAmount, - setCoinFilter, get_data_entry, - have_data_entry, get_data_entry_or, + have_data_entry, + inputAmount, + known_chart_coins, listAvailableCoins, + PAGE_LIMIT, + setCoinFilter, set_pagination_filters, ) from basicswap.db import ( @@ -815,6 +816,24 @@ def page_offers(self, url_split, post_string, sent=False): offers_count = len(formatted_offers) + enabled_chart_coins = [] + enabled_chart_coins_setting = swap_client.settings.get('enabled_chart_coins', '') + if enabled_chart_coins_setting.lower() == 'all': + enabled_chart_coins = known_chart_coins + elif enabled_chart_coins_setting.strip() == '': + for coin_id in swap_client.coin_clients: + if not swap_client.isCoinActive(coin_id): + continue + enabled_ticker = swap_client.ci(coin_id).ticker_mainnet() + if enabled_ticker not in enabled_chart_coins and enabled_ticker in known_chart_coins: + enabled_chart_coins.append(enabled_ticker) + else: + for ticker in enabled_chart_coins_setting.split(','): + upcased_ticker = ticker.strip().upper() + + if upcased_ticker not in enabled_chart_coins and upcased_ticker in known_chart_coins: + enabled_chart_coins.append(upcased_ticker) + template = server.env.get_template('offers.html') return self.render_template(template, { 'page_type': 'Your Offers' if sent else 'Network Order Book', @@ -834,4 +853,5 @@ def page_offers(self, url_split, post_string, sent=False): 'offers_count': offers_count, 'tla_from': tla_from, 'tla_to': tla_to, + 'enabled_chart_coins': enabled_chart_coins, }) diff --git a/basicswap/ui/page_settings.py b/basicswap/ui/page_settings.py index 4d5b523..ff688b0 100644 --- a/basicswap/ui/page_settings.py +++ b/basicswap/ui/page_settings.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2022-2023 tecnovert +# Copyright (c) 2022-2024 tecnovert # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. @@ -46,6 +46,7 @@ def page_settings(self, url_split, post_string): 'show_chart': toBool(get_data_entry(form_data, 'showchart')), 'chart_api_key': html.unescape(get_data_entry_or(form_data, 'chartapikey', '')), 'coingecko_api_key': html.unescape(get_data_entry_or(form_data, 'coingeckoapikey', '')), + 'enabled_chart_coins': get_data_entry_or(form_data, 'enabledchartcoins', ''), } swap_client.editGeneralSettings(data) elif have_data_entry(form_data, 'apply_tor'): @@ -141,6 +142,7 @@ def page_settings(self, url_split, post_string): 'show_chart': swap_client.settings.get('show_chart', True), 'chart_api_key': chart_api_key, 'coingecko_api_key': coingecko_api_key, + 'enabled_chart_coins': swap_client.settings.get('enabled_chart_coins', ''), } tor_control_password = '' if swap_client.tor_control_password is None else swap_client.tor_control_password diff --git a/basicswap/ui/util.py b/basicswap/ui/util.py index 39f2fe6..19e1c02 100644 --- a/basicswap/ui/util.py +++ b/basicswap/ui/util.py @@ -33,6 +33,7 @@ from basicswap.protocols.xmr_swap_1 import getChainBSplitKey, getChainBRemoteSpl PAGE_LIMIT = 25 invalid_coins_from = [] +known_chart_coins = ['BTC', 'PART', 'XMR', 'LTC', 'FIRO', 'DASH', 'PIVX', 'DOGE', 'ETH', 'DCR', 'ZANO', 'WOW'] def tickerToCoinId(ticker):