ui: Handle missing txn gracefully on bid page.

2024-05-20_merge
tecnovert 2 years ago
parent eb30369bd4
commit f29eac0eb5
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 13
      basicswap/http_server.py
  2. 7
      basicswap/templates/bid_xmr.html
  3. 2
      basicswap/templates/error.html
  4. 2
      basicswap/templates/info.html

@ -354,26 +354,27 @@ class HttpHandler(BaseHTTPRequestHandler):
swap_client = self.server.swap_client
messages = []
err_messages = []
show_txns = False
show_offerer_seq_diagram = False
show_bidder_seq_diagram = False
show_lock_transfers = False
edit_bid = False
view_tx_ind = None
form_data = self.checkForm(post_string, 'bid', messages)
form_data = self.checkForm(post_string, 'bid', err_messages)
if form_data:
if b'abandon_bid' in form_data:
try:
swap_client.abandonBid(bid_id)
messages.append('Bid abandoned')
except Exception as ex:
messages.append('Abandon failed ' + str(ex))
err_messages.append('Abandon failed ' + str(ex))
elif b'accept_bid' in form_data:
try:
swap_client.acceptBid(bid_id)
messages.append('Bid accepted')
except Exception as ex:
messages.append('Accept failed ' + str(ex))
err_messages.append('Accept failed ' + str(ex))
elif b'show_txns' in form_data:
show_txns = True
elif b'show_offerer_seq_diagram' in form_data:
@ -392,10 +393,13 @@ class HttpHandler(BaseHTTPRequestHandler):
swap_client.manualBidUpdate(bid_id, data)
messages.append('Bid edited')
except Exception as ex:
messages.append('Edit failed ' + str(ex))
err_messages.append('Edit failed ' + str(ex))
elif b'view_tx_submit' in form_data:
show_txns = True
view_tx_ind = form_data[b'view_tx'][0].decode('utf-8')
if len(view_tx_ind) != 64:
err_messages.append('Invalid transaction selected.')
view_tx_ind = None
elif b'view_lock_transfers' in form_data:
show_txns = True
show_lock_transfers = True
@ -420,6 +424,7 @@ class HttpHandler(BaseHTTPRequestHandler):
return self.render_template(template, {
'bid_id': bid_id.hex(),
'messages': messages,
'err_messages': err_messages,
'data': data,
'edit_bid': edit_bid,
'old_states': old_states,

@ -10,6 +10,9 @@
{% for m in messages %}
<p>{{ m }}</p>
{% endfor %}
{% for m in err_messages %}
<p class="error_msg">Error: {{ m }}</p>
{% endfor %}
<table>
{% if data.was_sent == 'True' %}
@ -104,9 +107,13 @@
<table>
<tr><td>View Transaction</td><td>
<select name="view_tx">
{% if data.txns|length %}
{% for tx in data.txns %}
<option value="{{ tx.txid }}"{% if data.view_tx_ind==tx.txid %} selected{% endif %}>{{ tx.type }} {{ tx.txid }}</option>
{% endfor %}
{% else %}
<option value="0">--- None exist yet ---</option>
{% endif %}
</select></td></tr>
</table>
<input name="view_tx_submit" type="submit" value="View Tx">

@ -7,6 +7,6 @@
<body>
<h2>{{ title_str }}</h2>
<p>Error: {{ message_str }}</p>
<p><a href=\'/\'>home</a></p>
<p><a href="/">home</a></p>
</body>
</html>

@ -7,6 +7,6 @@
<body>
<h2>{{ title_str }}</h2>
<p>Info: {{ message_str }}</p>
<p><a href=\'/\'>home</a></p>
<p><a href="/">home</a></p>
</body>
</html>

Loading…
Cancel
Save