mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
ui: Handle missing txn gracefully on bid page.
This commit is contained in:
parent
eb30369bd4
commit
f29eac0eb5
4 changed files with 18 additions and 6 deletions
|
@ -354,26 +354,27 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
swap_client = self.server.swap_client
|
swap_client = self.server.swap_client
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
|
err_messages = []
|
||||||
show_txns = False
|
show_txns = False
|
||||||
show_offerer_seq_diagram = False
|
show_offerer_seq_diagram = False
|
||||||
show_bidder_seq_diagram = False
|
show_bidder_seq_diagram = False
|
||||||
show_lock_transfers = False
|
show_lock_transfers = False
|
||||||
edit_bid = False
|
edit_bid = False
|
||||||
view_tx_ind = None
|
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 form_data:
|
||||||
if b'abandon_bid' in form_data:
|
if b'abandon_bid' in form_data:
|
||||||
try:
|
try:
|
||||||
swap_client.abandonBid(bid_id)
|
swap_client.abandonBid(bid_id)
|
||||||
messages.append('Bid abandoned')
|
messages.append('Bid abandoned')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
messages.append('Abandon failed ' + str(ex))
|
err_messages.append('Abandon failed ' + str(ex))
|
||||||
elif b'accept_bid' in form_data:
|
elif b'accept_bid' in form_data:
|
||||||
try:
|
try:
|
||||||
swap_client.acceptBid(bid_id)
|
swap_client.acceptBid(bid_id)
|
||||||
messages.append('Bid accepted')
|
messages.append('Bid accepted')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
messages.append('Accept failed ' + str(ex))
|
err_messages.append('Accept failed ' + str(ex))
|
||||||
elif b'show_txns' in form_data:
|
elif b'show_txns' in form_data:
|
||||||
show_txns = True
|
show_txns = True
|
||||||
elif b'show_offerer_seq_diagram' in form_data:
|
elif b'show_offerer_seq_diagram' in form_data:
|
||||||
|
@ -392,10 +393,13 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
swap_client.manualBidUpdate(bid_id, data)
|
swap_client.manualBidUpdate(bid_id, data)
|
||||||
messages.append('Bid edited')
|
messages.append('Bid edited')
|
||||||
except Exception as ex:
|
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:
|
elif b'view_tx_submit' in form_data:
|
||||||
show_txns = True
|
show_txns = True
|
||||||
view_tx_ind = form_data[b'view_tx'][0].decode('utf-8')
|
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:
|
elif b'view_lock_transfers' in form_data:
|
||||||
show_txns = True
|
show_txns = True
|
||||||
show_lock_transfers = True
|
show_lock_transfers = True
|
||||||
|
@ -420,6 +424,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
return self.render_template(template, {
|
return self.render_template(template, {
|
||||||
'bid_id': bid_id.hex(),
|
'bid_id': bid_id.hex(),
|
||||||
'messages': messages,
|
'messages': messages,
|
||||||
|
'err_messages': err_messages,
|
||||||
'data': data,
|
'data': data,
|
||||||
'edit_bid': edit_bid,
|
'edit_bid': edit_bid,
|
||||||
'old_states': old_states,
|
'old_states': old_states,
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
{% for m in messages %}
|
{% for m in messages %}
|
||||||
<p>{{ m }}</p>
|
<p>{{ m }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% for m in err_messages %}
|
||||||
|
<p class="error_msg">Error: {{ m }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{% if data.was_sent == 'True' %}
|
{% if data.was_sent == 'True' %}
|
||||||
|
@ -104,9 +107,13 @@
|
||||||
<table>
|
<table>
|
||||||
<tr><td>View Transaction</td><td>
|
<tr><td>View Transaction</td><td>
|
||||||
<select name="view_tx">
|
<select name="view_tx">
|
||||||
|
{% if data.txns|length %}
|
||||||
{% for tx in data.txns %}
|
{% for tx in data.txns %}
|
||||||
<option value="{{ tx.txid }}"{% if data.view_tx_ind==tx.txid %} selected{% endif %}>{{ tx.type }} {{ tx.txid }}</option>
|
<option value="{{ tx.txid }}"{% if data.view_tx_ind==tx.txid %} selected{% endif %}>{{ tx.type }} {{ tx.txid }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<option value="0">--- None exist yet ---</option>
|
||||||
|
{% endif %}
|
||||||
</select></td></tr>
|
</select></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<input name="view_tx_submit" type="submit" value="View Tx">
|
<input name="view_tx_submit" type="submit" value="View Tx">
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<body>
|
<body>
|
||||||
<h2>{{ title_str }}</h2>
|
<h2>{{ title_str }}</h2>
|
||||||
<p>Error: {{ message_str }}</p>
|
<p>Error: {{ message_str }}</p>
|
||||||
<p><a href=\'/\'>home</a></p>
|
<p><a href="/">home</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
<body>
|
<body>
|
||||||
<h2>{{ title_str }}</h2>
|
<h2>{{ title_str }}</h2>
|
||||||
<p>Info: {{ message_str }}</p>
|
<p>Info: {{ message_str }}</p>
|
||||||
<p><a href=\'/\'>home</a></p>
|
<p><a href="/">home</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue