Log events when xmr refund and refund spend txns are seen.

2024-05-20_merge
tecnovert 3 years ago
parent 4a7eff0118
commit 82e2b128c9
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
  1. 2
      basicswap/basicswap.py
  2. 10
      basicswap/basicswap_util.py
  3. 8
      basicswap/http_server.py

@ -3375,6 +3375,7 @@ class BasicSwap(BaseApp):
elif spending_txid == xmr_swap.a_lock_refund_tx_id: elif spending_txid == xmr_swap.a_lock_refund_tx_id:
self.log.debug('Coin a lock tx spent by lock refund tx.') self.log.debug('Coin a lock tx spent by lock refund tx.')
bid.setState(BidStates.XMR_SWAP_SCRIPT_TX_PREREFUND) bid.setState(BidStates.XMR_SWAP_SCRIPT_TX_PREREFUND)
self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_A_REFUND_TX_SEEN, '', session)
else: else:
self.setBidError(bid.bid_id, bid, 'Unexpected txn spent coin a lock tx: {}'.format(spend_txid_hex), save_bid=False) self.setBidError(bid.bid_id, bid, 'Unexpected txn spent coin a lock tx: {}'.format(spend_txid_hex), save_bid=False)
@ -3409,6 +3410,7 @@ class BasicSwap(BaseApp):
if spending_txid == xmr_swap.a_lock_refund_spend_tx_id: if spending_txid == xmr_swap.a_lock_refund_spend_tx_id:
self.log.info('Found coin a lock refund spend tx, bid {}'.format(bid_id.hex())) self.log.info('Found coin a lock refund spend tx, bid {}'.format(bid_id.hex()))
self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_A_REFUND_SPEND_TX_SEEN, '', session)
if bid.was_sent: if bid.was_sent:
xmr_swap.a_lock_refund_spend_tx = bytes.fromhex(spend_txn['hex']) # Replace with fully signed tx xmr_swap.a_lock_refund_spend_tx = bytes.fromhex(spend_txn['hex']) # Replace with fully signed tx

@ -144,6 +144,8 @@ class EventLogTypes(IntEnum):
SYSTEM_WARNING = auto() SYSTEM_WARNING = auto()
LOCK_TX_A_SPEND_TX_PUBLISHED = auto() LOCK_TX_A_SPEND_TX_PUBLISHED = auto()
LOCK_TX_B_SPEND_TX_PUBLISHED = auto() LOCK_TX_B_SPEND_TX_PUBLISHED = auto()
LOCK_TX_A_REFUND_TX_SEEN = auto()
LOCK_TX_A_REFUND_SPEND_TX_SEEN = auto()
class XmrSplitMsgTypes(IntEnum): class XmrSplitMsgTypes(IntEnum):
@ -207,6 +209,8 @@ def strBidState(state):
return 'Script coin lock released' return 'Script coin lock released'
if state == BidStates.XMR_SWAP_SCRIPT_TX_REDEEMED: if state == BidStates.XMR_SWAP_SCRIPT_TX_REDEEMED:
return 'Script tx redeemed' return 'Script tx redeemed'
if state == BidStates.XMR_SWAP_SCRIPT_TX_PREREFUND:
return 'Script pre-refund tx in chain'
if state == BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED: if state == BidStates.XMR_SWAP_NOSCRIPT_TX_REDEEMED:
return 'Scriptless tx redeemed' return 'Scriptless tx redeemed'
if state == BidStates.XMR_SWAP_NOSCRIPT_TX_RECOVERED: if state == BidStates.XMR_SWAP_NOSCRIPT_TX_RECOVERED:
@ -219,7 +223,7 @@ def strBidState(state):
return 'Failed' return 'Failed'
if state == BidStates.SWAP_DELAYING: if state == BidStates.SWAP_DELAYING:
return 'Delaying' return 'Delaying'
return 'Unknown' return 'Unknown' + ' ' + str(state)
def strTxState(state): def strTxState(state):
@ -312,6 +316,10 @@ def describeEventEntry(event_type, event_msg):
return 'Lock tx A spend tx published' return 'Lock tx A spend tx published'
if event_type == EventLogTypes.LOCK_TX_B_SPEND_TX_PUBLISHED: if event_type == EventLogTypes.LOCK_TX_B_SPEND_TX_PUBLISHED:
return 'Lock tx B spend tx published' return 'Lock tx B spend tx published'
if event_type == EventLogTypes.LOCK_TX_A_REFUND_TX_SEEN:
return 'Lock tx A refund tx seen in chain'
if event_type == EventLogTypes.LOCK_TX_A_REFUND_SPEND_TX_SEEN:
return 'Lock tx A refund spend tx seen in chain'
if event_type == EventLogTypes.SYSTEM_WARNING: if event_type == EventLogTypes.SYSTEM_WARNING:
return 'Warning: ' + event_msg return 'Warning: ' + event_msg

@ -567,8 +567,8 @@ class HttpHandler(BaseHTTPRequestHandler):
if page_data['amt_var'] or page_data['rate_var']: if page_data['amt_var'] or page_data['rate_var']:
page_data['autoaccept'] = False page_data['autoaccept'] = False
if b'step1' in form_data: if have_data_entry(form_data, 'step1'):
if len(errors) == 0 and b'continue' in form_data: if len(errors) == 0 and have_data_entry(form_data, 'continue'):
page_data['step2'] = True page_data['step2'] = True
return parsed_data, errors return parsed_data, errors
@ -727,6 +727,8 @@ class HttpHandler(BaseHTTPRequestHandler):
for e in errors: for e in errors:
messages.append('Error: {}'.format(str(e))) messages.append('Error: {}'.format(str(e)))
except Exception as e: except Exception as e:
if swap_client.debug is True:
swap_client.log.error(traceback.format_exc())
messages.append('Error: {}'.format(str(e))) messages.append('Error: {}'.format(str(e)))
if len(messages) == 0 and 'submit_offer' in page_data: if len(messages) == 0 and 'submit_offer' in page_data:
@ -735,6 +737,8 @@ class HttpHandler(BaseHTTPRequestHandler):
messages.append('<a href="/offer/' + offer_id.hex() + '">Sent Offer {}</a>'.format(offer_id.hex())) messages.append('<a href="/offer/' + offer_id.hex() + '">Sent Offer {}</a>'.format(offer_id.hex()))
page_data = {} page_data = {}
except Exception as e: except Exception as e:
if swap_client.debug is True:
swap_client.log.error(traceback.format_exc())
messages.append('Error: {}'.format(str(e))) messages.append('Error: {}'.format(str(e)))
if len(messages) == 0 and 'check_offer' in page_data: if len(messages) == 0 and 'check_offer' in page_data:

Loading…
Cancel
Save