diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 3cf02a8..ea2e5af 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -1360,7 +1360,14 @@ class BasicSwap(BaseApp): return addr def getCachedMainWalletAddress(self, ci): - return self.getStringKV('main_wallet_addr_' + ci.coin_name().lower()) + db_key = 'main_wallet_addr_' + ci.coin_name().lower() + cached_addr = self.getStringKV(db_key) + if cached_addr is not None: + return cached_addr + self.log.warning(f'Setting {db_key}') + main_address = ci.getMainWalletAddress() + self.setStringKV(db_key, main_address) + return main_address def checkWalletSeed(self, c): ci = self.ci(c) diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 96cfe69..eca218c 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -76,14 +76,14 @@ def getCoinName(c): return chainparams[c]['name'].capitalize() -def listAvailableCoins(swap_client): +def listAvailableCoins(swap_client, with_variants=True): coins = [] for k, v in swap_client.coin_clients.items(): if k not in chainparams: continue if v['connection_type'] == 'rpc': coins.append((int(k), getCoinName(k))) - if k == Coins.PART: + if with_variants and k == Coins.PART: coins.append((int(Coins.PART_ANON), getCoinName(Coins.PART_ANON))) coins.append((int(Coins.PART_BLIND), getCoinName(Coins.PART_BLIND))) return coins @@ -232,9 +232,33 @@ class HttpHandler(BaseHTTPRequestHandler): return bytes(template.render( title=self.server.title, h2=self.server.title, - coins=listAvailableCoins(swap_client), + coins=listAvailableCoins(swap_client, with_variants=False), coin_type=coin_type, result=result, + messages=messages, + form_id=os.urandom(8).hex(), + ), 'UTF-8') + + def page_debug(self, url_split, post_string): + swap_client = self.server.swap_client + + result = None + messages = [] + form_data = self.checkForm(post_string, 'wallets', messages) + if form_data: + if have_data_entry(form_data, 'reinit_xmr'): + try: + swap_client.initialiseWallet(Coins.XMR) + messages.append('Done.') + except Exception as a: + messages.append('Failed.') + + template = env.get_template('debug.html') + return bytes(template.render( + title=self.server.title, + h2=self.server.title, + messages=messages, + result=result, form_id=os.urandom(8).hex(), ), 'UTF-8') @@ -1228,6 +1252,8 @@ class HttpHandler(BaseHTTPRequestHandler): return self.page_settings(url_split, post_string) if url_split[1] == 'rpc': return self.page_rpc(url_split, post_string) + if url_split[1] == 'debug': + return self.page_debug(url_split, post_string) if url_split[1] == 'explorers': return self.page_explorers(url_split, post_string) if url_split[1] == 'offer': diff --git a/basicswap/templates/debug.html b/basicswap/templates/debug.html new file mode 100644 index 0000000..0ab8ca9 --- /dev/null +++ b/basicswap/templates/debug.html @@ -0,0 +1,22 @@ +{% include 'header.html' %} + +

Debug

+{% for m in messages %} +

{{ m }}

+{% endfor %} + +
+

+ + +

+
+ +{% if result %} + +{% endif %} + +

home

+ diff --git a/basicswap/templates/offer_new_1.html b/basicswap/templates/offer_new_1.html index 11be0d1..2f3e131 100644 --- a/basicswap/templates/offer_new_1.html +++ b/basicswap/templates/offer_new_1.html @@ -36,7 +36,7 @@ {% endfor %} Amount ToThe amount you will receive. -RateLock Rate: +RateLock Rate: Amount Variable Rate Variable