ui: Add debug ind option.

2024-05-20_merge
tecnovert 3 years ago
parent fa0600fca3
commit 58e4b506fe
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 1
      basicswap/basicswap.py
  2. 16
      basicswap/http_server.py
  3. 7
      basicswap/js_server.py
  4. 8
      basicswap/templates/offer.html
  5. 4
      tests/basicswap/test_xmr.py

@ -198,6 +198,7 @@ class BasicSwap(BaseApp):
self.check_events_seconds = self.settings.get('check_events_seconds', 10)
self.check_xmr_swaps_seconds = self.settings.get('check_xmr_swaps_seconds', 20)
self.startup_tries = self.settings.get('startup_tries', 21) # Seconds waited for will be (x(1 + x+1) / 2
self.debug_ui = self.settings.get('debug_ui', False)
self._last_checked_progress = 0
self._last_checked_watched = 0
self._last_checked_expired = 0

@ -25,6 +25,7 @@ from .chainparams import (
)
from .basicswap_util import (
SwapTypes,
DebugTypes,
strOfferState,
strBidState,
strTxState,
@ -55,6 +56,7 @@ from .ui import (
setCoinFilter,
get_data_entry,
have_data_entry,
get_data_entry_or,
)
@ -759,6 +761,7 @@ class HttpHandler(BaseHTTPRequestHandler):
ci_from = swap_client.ci(Coins(offer.coin_from))
ci_to = swap_client.ci(Coins(offer.coin_to))
debugind = -1
# Set defaults
bid_amount = ci_from.format_amount(offer.amount_from)
@ -795,9 +798,15 @@ class HttpHandler(BaseHTTPRequestHandler):
amount_from = inputAmount(bid_amount, ci_from)
else:
amount_from = offer.amount_from
debugind = int(get_data_entry_or(form_data, 'debugind', -1))
sent_bid_id = swap_client.postBid(offer_id, amount_from, addr_send_from=addr_from, extra_options=extra_options).hex()
if debugind > -1:
swap_client.setBidDebugInd(bytes.fromhex(sent_bid_id), debugind)
except Exception as ex:
if self.server.swap_client.debug is True:
traceback.print_exc()
messages.append('Error: Send bid failed: ' + str(ex))
show_bid_form = True
@ -825,9 +834,14 @@ class HttpHandler(BaseHTTPRequestHandler):
'rate_negotiable': offer.rate_negotiable,
'bid_amount': bid_amount,
'bid_rate': bid_rate,
'debug_ui': swap_client.debug_ui,
}
data.update(extend_data)
if swap_client.debug_ui:
data['debug_ind'] = debugind
data['debug_options'] = [(int(t), t.name) for t in DebugTypes]
if xmr_offer:
int_fee_rate_now, fee_source = ci_from.get_fee_rate()
data['xmr_type'] = True
@ -975,7 +989,7 @@ class HttpHandler(BaseHTTPRequestHandler):
data = describeBid(swap_client, bid, xmr_swap, offer, xmr_offer, events, edit_bid, show_txns, view_tx_ind, show_lock_transfers=show_lock_transfers)
if bid.debug_ind is not None and bid.debug_ind > 0:
messages.append('Debug flag set: {}'.format(bid.debug_ind))
messages.append('Debug flag set: {}, {}'.format(bid.debug_ind, DebugTypes(bid.debug_ind).name))
old_states = []
num_states = len(bid.states) // 12

@ -186,6 +186,11 @@ def js_bids(self, url_split, post_string, is_json):
extra_options = {
'valid_for_seconds': valid_for_seconds,
}
if have_data_entry(form_data, 'bid_rate'):
extra_options['bid_rate'] = ci_to.make_int(get_data_entry(form_data, 'bid_rate'), r=1)
if have_data_entry(form_data, 'bid_amount'):
amount_from = inputAmount(get_data_entry(form_data, 'bid_amount'), ci_from)
if offer.swap_type == SwapTypes.XMR_SWAP:
bid_id = swap_client.postXmrBid(offer_id, amount_from, addr_send_from=addr_from, extra_options=extra_options)
else:
@ -258,7 +263,7 @@ def js_smsgaddresses(self, url_split, post_string, is_json):
post_data = urllib.parse.parse_qs(post_string)
if url_split[3] == 'new':
addressnote = get_data_entry_or(post_data, 'addressnote', '')
new_addr, pubkey = swap_client.newSMSGAddress(addressnote)
new_addr, pubkey = swap_client.newSMSGAddress(addressnote=addressnote)
return bytes(json.dumps({'new_address': new_addr, 'pubkey': pubkey}), 'UTF-8')
if url_split[3] == 'add':
addressnote = get_data_entry_or(post_data, 'addressnote', '')

@ -69,6 +69,14 @@
{% endif %}
<tr><td>Minutes valid</td><td><input type="number" name="validmins" min="10" max="1440" value="{{ data.nb_validmins }}"></td></tr>
{% if data.debug_ui == true %}
<tr><td>Debug Option</td><td><select name="debugind">
<option{% if data.debug_ind=="-1" %} selected{% endif %} value="-1">-- None --</option>
{% for a in data.debug_options %}
<option{% if data.debug_ind==a[0] %} selected{% endif %} value="{{ a[0] }}">{{ a[1] }}</option>
{% endfor %}
</select></td></tr>
{% endif %}
<tr><td>
<input type="submit" name="sendbid" value="Send Bid">
<input type="submit" name="cancel" value="Cancel">

@ -188,7 +188,6 @@ def prepare_swapclient_dir(datadir, node_id, network_key, network_pubkey, with_l
'bindir': cfg.BITCOIN_BINDIR,
'use_segwit': True,
}
},
'check_progress_seconds': 2,
'check_watched_seconds': 4,
@ -198,7 +197,8 @@ def prepare_swapclient_dir(datadir, node_id, network_key, network_pubkey, with_l
'min_delay_event': 1,
'max_delay_event': 5,
'min_delay_retry': 2,
'max_delay_retry': 10
'max_delay_retry': 10,
'debug_ui': True,
}
if with_ltc:

Loading…
Cancel
Save