diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index b9a0f54..c48508a 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -6447,6 +6447,25 @@ class BasicSwap(BaseApp): settings_copy.pop('chart_api_key') settings_changed = True + if 'coingecko_api_key' in data: + new_value = data['coingecko_api_key'] + ensure(isinstance(new_value, str), 'New coingecko_api_key value not a string') + ensure(len(new_value) <= 128, 'New coingecko_api_keyvalue too long') + if all(c in string.hexdigits for c in new_value): + if settings_copy.get('coingecko_api_key', '') != new_value: + settings_copy['coingecko_api_key'] = new_value + if 'coingecko_api_key_enc' in settings_copy: + settings_copy.pop('coingecko_api_key_enc') + settings_changed = True + else: + # Encode value as hex to avoid escaping + new_value = new_value.encode('utf-8').hex() + if settings_copy.get('coingecko_api_key_enc', '') != new_value: + settings_copy['coingecko_api_key_enc'] = new_value + if 'coingecko_api_key' in settings_copy: + settings_copy.pop('coingecko_api_key') + 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/static/images/coins/Wownero-20.png b/basicswap/static/images/coins/Wownero-20.png new file mode 100644 index 0000000..e0d243c Binary files /dev/null and b/basicswap/static/images/coins/Wownero-20.png differ diff --git a/basicswap/static/images/coins/Wownero.png b/basicswap/static/images/coins/Wownero.png new file mode 100644 index 0000000..504d708 Binary files /dev/null and b/basicswap/static/images/coins/Wownero.png differ diff --git a/basicswap/templates/offers.html b/basicswap/templates/offers.html index 3958683..6eb7a08 100644 --- a/basicswap/templates/offers.html +++ b/basicswap/templates/offers.html @@ -55,7 +55,7 @@ @@ -359,16 +359,77 @@ +
+
+
+ WOWNERO +

+ Wownero (WOW) +

+
+
+

+ + + +

+
+
+
+
+
+
+ VOL: +
+
+
+ +
+
+
+ - + {% endif %}
diff --git a/basicswap/templates/settings.html b/basicswap/templates/settings.html index 3f5440e..2868f6d 100644 --- a/basicswap/templates/settings.html +++ b/basicswap/templates/settings.html @@ -416,7 +416,7 @@ - Chart API Key + Chart API Key (CryptoCompare)
diff --git a/basicswap/ui/page_offers.py b/basicswap/ui/page_offers.py index 4e0dcaf..1d38bd4 100644 --- a/basicswap/ui/page_offers.py +++ b/basicswap/ui/page_offers.py @@ -41,6 +41,7 @@ from basicswap.chainparams import ( ) default_chart_api_key = '95dd900af910656e0e17c41f2ddc5dba77d01bf8b0e7d2787634a16bd976c553' +default_coingecko_api_key = 'CG-8hm3r9iLfpEXv4ied8oLbeUj' def value_or_none(v): @@ -451,6 +452,11 @@ def page_newoffer(self, url_split, post_string): chart_api_key_enc = swap_client.settings.get('chart_api_key_enc', '') chart_api_key = default_chart_api_key if chart_api_key_enc == '' else bytes.fromhex(chart_api_key_enc).decode('utf-8') + coingecko_api_key = swap_client.settings.get('coingecko_api_key', '') + if coingecko_api_key == '': + coingecko_api_key_enc = swap_client.settings.get('coingecko_api_key_enc', '') + coingecko_api_key = default_coingecko_api_key if coingecko_api_key_enc == '' else bytes.fromhex(coingecko_api_key_enc).decode('utf-8') + return self.render_template(template, { 'messages': messages, 'err_messages': err_messages, @@ -464,6 +470,7 @@ def page_newoffer(self, url_split, post_string): 'swap_types': [(strSwapType(x), strSwapDesc(x)) for x in SwapTypes if strSwapType(x)], 'show_chart': swap_client.settings.get('show_chart', True), 'chart_api_key': chart_api_key, + 'coingecko_api_key': coingecko_api_key, }) @@ -796,6 +803,11 @@ def page_offers(self, url_split, post_string, sent=False): chart_api_key_enc = swap_client.settings.get('chart_api_key_enc', '') chart_api_key = default_chart_api_key if chart_api_key_enc == '' else bytes.fromhex(chart_api_key_enc).decode('utf-8') + coingecko_api_key = swap_client.settings.get('coingecko_api_key', '') + if coingecko_api_key == '': + coingecko_api_key_enc = swap_client.settings.get('coingecko_api_key_enc', '') + coingecko_api_key = default_coingecko_api_key if coingecko_api_key_enc == '' else bytes.fromhex(coingecko_api_key_enc).decode('utf-8') + offers_count = len(formatted_offers) template = server.env.get_template('offers.html') @@ -806,6 +818,7 @@ def page_offers(self, url_split, post_string, sent=False): 'messages': messages, 'show_chart': False if sent else swap_client.settings.get('show_chart', True), 'chart_api_key': chart_api_key, + 'coingecko_api_key': coingecko_api_key, 'coins_from': coins_from, 'coins': coins_to, 'messages': messages, diff --git a/basicswap/ui/page_settings.py b/basicswap/ui/page_settings.py index 072dcbc..3306478 100644 --- a/basicswap/ui/page_settings.py +++ b/basicswap/ui/page_settings.py @@ -45,6 +45,7 @@ def page_settings(self, url_split, post_string): data = { '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', '')), } swap_client.editGeneralSettings(data) elif have_data_entry(form_data, 'apply_tor'): @@ -130,9 +131,16 @@ def page_settings(self, url_split, post_string): chart_api_key = html.escape(bytes.fromhex(swap_client.settings.get('chart_api_key_enc', '')).decode('utf-8')) else: chart_api_key = swap_client.settings.get('chart_api_key', '') + + if 'coingecko_api_key_enc' in swap_client.settings: + coingecko_api_key = html.escape(bytes.fromhex(swap_client.settings.get('coingecko_api_key_enc', '')).decode('utf-8')) + else: + coingecko_api_key = swap_client.settings.get('coingecko_api_key', '') + chart_settings = { 'show_chart': swap_client.settings.get('show_chart', True), 'chart_api_key': chart_api_key, + 'coingecko_api_key': coingecko_api_key, } tor_control_password = '' if swap_client.tor_control_password is None else swap_client.tor_control_password