diff --git a/basicswap/http_server.py b/basicswap/http_server.py index aeabbe1..023b21c 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -113,11 +113,12 @@ class HttpHandler(BaseHTTPRequestHandler): content = html_content_start(self.server.title, self.server.title) \ + '

Wallets

' + messages = [] if post_string != '': form_data = urllib.parse.parse_qs(post_string) form_id = form_data[b'formid'][0].decode('utf-8') if self.server.last_form_id.get('wallets', None) == form_id: - content += '

Prevented double submit for form {}.

'.format(form_id) + messages.append('Prevented double submit for form {}.'.format(form_id)) else: self.server.last_form_id['wallets'] = form_id @@ -133,33 +134,38 @@ class HttpHandler(BaseHTTPRequestHandler): subfee = True if bytes('subfee_' + cid, 'utf-8') in form_data else False txid = swap_client.withdrawCoin(c, value, address, subfee) ticker = swap_client.getTicker(c) - content += '

Withdrew {} {} to address {}
In txid: {}

'.format(value, ticker, address, txid) + messages.append('Withdrew {} {} to address {}
In txid: {}'.format(value, ticker, address, txid)) wallets = swap_client.getWalletsInfo() - content += '
' + wallets_formatted = [] for k, w in wallets.items(): - cid = str(int(k)) - content += '

' + w['name'] + '

' - if 'error' in w: - content += '

Error: {}

'.format(w['error']) - + wallets_formatted.append({ + 'cid': str(int(k)), + 'error': w['error'] + }) + continue fee_rate = swap_client.getFeeRateForCoin(k) tx_vsize = swap_client.getContractSpendTxVSize(k) est_fee = (fee_rate * tx_vsize) / 1000 - content += '' \ - + '' \ - + '' \ - + '' \ - + '' \ - + '' \ - + '' \ - + '
Balance:' + w['balance'] + '
Blocks:' + str(w['blocks']) + '
Synced:' + str(w['synced']) + '
' + str(w['deposit_address']) + '
Amount: Address: Subtract fee:
Fee Rate:' + format8(fee_rate * COIN) + 'Est Fee:' + format8(est_fee * COIN) + '
' + wallets_formatted.append({ + 'cid': str(int(k)), + 'fee_rate': format8(fee_rate * COIN), + 'est_fee': format8(est_fee * COIN), + 'balance': w['balance'], + 'blocks': w['blocks'], + 'synced': w['synced'], + 'deposit_address': w['deposit_address'], + }) - content += '
' - content += '

home

' - return bytes(content, 'UTF-8') + template = env.get_template('wallets.html') + return bytes(template.render( + title=self.server.title, + h2=self.server.title, + wallets=wallets_formatted, + form_id=os.urandom(8).hex(), + ), 'UTF-8') def page_newoffer(self, url_split, post_string): swap_client = self.server.swap_client diff --git a/basicswap/templates/wallets.html b/basicswap/templates/wallets.html new file mode 100644 index 0000000..69b0768 --- /dev/null +++ b/basicswap/templates/wallets.html @@ -0,0 +1,35 @@ +{% include 'header.html' %} + +

Wallets

+{% if refresh %} +

Page Refresh: {{ refresh }} seconds

+{% endif %} + +{% for m in messages %} +

{{ m }}

+{% endfor %} + +
+ + +{% for w in wallets %} +

{{ w.name }}

+{% if w.error %} +

Error: {{ w.error }}

+{% else %} + + + + + + + +
Balance:{{ w.balance }}
Blocks:{{ w.blocks }}
Synced:{{ w.synced }}
{{ w.deposit_address }}
Amount: Address: Subtract fee:
Fee Rate:{{ w.fee_rate }}Est Fee:{{ w.est_fee }}
+{% endif %} +{% endfor %} + + +
+ +

home

+ \ No newline at end of file