mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-23 11:59:36 +00:00
Create CachedMainWalletAddress if missing.
This commit is contained in:
parent
4d3b842ea8
commit
dd7440b897
4 changed files with 60 additions and 5 deletions
|
@ -1360,7 +1360,14 @@ class BasicSwap(BaseApp):
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
def getCachedMainWalletAddress(self, ci):
|
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):
|
def checkWalletSeed(self, c):
|
||||||
ci = self.ci(c)
|
ci = self.ci(c)
|
||||||
|
|
|
@ -76,14 +76,14 @@ def getCoinName(c):
|
||||||
return chainparams[c]['name'].capitalize()
|
return chainparams[c]['name'].capitalize()
|
||||||
|
|
||||||
|
|
||||||
def listAvailableCoins(swap_client):
|
def listAvailableCoins(swap_client, with_variants=True):
|
||||||
coins = []
|
coins = []
|
||||||
for k, v in swap_client.coin_clients.items():
|
for k, v in swap_client.coin_clients.items():
|
||||||
if k not in chainparams:
|
if k not in chainparams:
|
||||||
continue
|
continue
|
||||||
if v['connection_type'] == 'rpc':
|
if v['connection_type'] == 'rpc':
|
||||||
coins.append((int(k), getCoinName(k)))
|
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_ANON), getCoinName(Coins.PART_ANON)))
|
||||||
coins.append((int(Coins.PART_BLIND), getCoinName(Coins.PART_BLIND)))
|
coins.append((int(Coins.PART_BLIND), getCoinName(Coins.PART_BLIND)))
|
||||||
return coins
|
return coins
|
||||||
|
@ -232,9 +232,33 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
return bytes(template.render(
|
return bytes(template.render(
|
||||||
title=self.server.title,
|
title=self.server.title,
|
||||||
h2=self.server.title,
|
h2=self.server.title,
|
||||||
coins=listAvailableCoins(swap_client),
|
coins=listAvailableCoins(swap_client, with_variants=False),
|
||||||
coin_type=coin_type,
|
coin_type=coin_type,
|
||||||
result=result,
|
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(),
|
form_id=os.urandom(8).hex(),
|
||||||
), 'UTF-8')
|
), 'UTF-8')
|
||||||
|
|
||||||
|
@ -1228,6 +1252,8 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
return self.page_settings(url_split, post_string)
|
return self.page_settings(url_split, post_string)
|
||||||
if url_split[1] == 'rpc':
|
if url_split[1] == 'rpc':
|
||||||
return self.page_rpc(url_split, post_string)
|
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':
|
if url_split[1] == 'explorers':
|
||||||
return self.page_explorers(url_split, post_string)
|
return self.page_explorers(url_split, post_string)
|
||||||
if url_split[1] == 'offer':
|
if url_split[1] == 'offer':
|
||||||
|
|
22
basicswap/templates/debug.html
Normal file
22
basicswap/templates/debug.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% include 'header.html' %}
|
||||||
|
|
||||||
|
<h3>Debug</h3>
|
||||||
|
{% for m in messages %}
|
||||||
|
<p>{{ m }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<p>
|
||||||
|
<input name="reinit_xmr" type="submit" value="Reinitialise XMR wallet" >
|
||||||
|
<input type="hidden" name="formid" value="{{ form_id }}">
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if result %}
|
||||||
|
<textarea class="monospace" rows="40" cols="160">
|
||||||
|
{{ result }}
|
||||||
|
</textarea>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<p><a href="/">home</a></p>
|
||||||
|
</body></html>
|
|
@ -36,7 +36,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td><td>Amount To</td><td><input type="text" id="amt_to" name="amt_to" value="{{ data.amt_to }}" onchange="set_rate('amt_to');"></td><td>The amount you will receive.</td></tr>
|
</td><td>Amount To</td><td><input type="text" id="amt_to" name="amt_to" value="{{ data.amt_to }}" onchange="set_rate('amt_to');"></td><td>The amount you will receive.</td></tr>
|
||||||
</td><td>Rate</td><td><input type="text" id="rate" name="rate" value="{{ data.rate }}" onchange="set_rate('rate');"></td><td>Lock Rate: <input type="checkbox" id="rate_lock" name="rate_lock" value="rl"></td></tr>
|
</td><td>Rate</td><td><input type="text" id="rate" name="rate" value="{{ data.rate }}" onchange="set_rate('rate');"></td><td>Lock Rate: <input type="checkbox" id="rate_lock" name="rate_lock" value="rl" checked="true"></td></tr>
|
||||||
|
|
||||||
<tr><td>Amount Variable</td><td><input type="checkbox" id="amt_var" name="amt_var" value="av" {% if data.amt_var==true %} checked="true"{% endif %}></td></tr>
|
<tr><td>Amount Variable</td><td><input type="checkbox" id="amt_var" name="amt_var" value="av" {% if data.amt_var==true %} checked="true"{% endif %}></td></tr>
|
||||||
<tr><td>Rate Variable</td><td><input type="checkbox" id="rate_var" name="rate_var" value="rv" {% if data.rate_var==true %} checked="true"{% endif %}></td></tr>
|
<tr><td>Rate Variable</td><td><input type="checkbox" id="rate_var" name="rate_var" value="rv" {% if data.rate_var==true %} checked="true"{% endif %}></td></tr>
|
||||||
|
|
Loading…
Reference in a new issue