From 82e2b128c9d033b0f0fc05d617b5adade26507b4 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 16 Dec 2021 14:26:21 +0200 Subject: [PATCH] Log events when xmr refund and refund spend txns are seen. --- basicswap/basicswap.py | 2 ++ basicswap/basicswap_util.py | 10 +++++++++- basicswap/http_server.py | 8 ++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 7da9ca3..30fe42b 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -3375,6 +3375,7 @@ class BasicSwap(BaseApp): elif spending_txid == xmr_swap.a_lock_refund_tx_id: self.log.debug('Coin a lock tx spent by lock refund tx.') bid.setState(BidStates.XMR_SWAP_SCRIPT_TX_PREREFUND) + self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_A_REFUND_TX_SEEN, '', session) else: 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: 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: xmr_swap.a_lock_refund_spend_tx = bytes.fromhex(spend_txn['hex']) # Replace with fully signed tx diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py index 4517392..a5e4c31 100644 --- a/basicswap/basicswap_util.py +++ b/basicswap/basicswap_util.py @@ -144,6 +144,8 @@ class EventLogTypes(IntEnum): SYSTEM_WARNING = auto() LOCK_TX_A_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): @@ -207,6 +209,8 @@ def strBidState(state): return 'Script coin lock released' if state == BidStates.XMR_SWAP_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: return 'Scriptless tx redeemed' if state == BidStates.XMR_SWAP_NOSCRIPT_TX_RECOVERED: @@ -219,7 +223,7 @@ def strBidState(state): return 'Failed' if state == BidStates.SWAP_DELAYING: return 'Delaying' - return 'Unknown' + return 'Unknown' + ' ' + str(state) def strTxState(state): @@ -312,6 +316,10 @@ def describeEventEntry(event_type, event_msg): return 'Lock tx A spend tx published' if event_type == EventLogTypes.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: return 'Warning: ' + event_msg diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 4f64379..197a0d4 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -567,8 +567,8 @@ class HttpHandler(BaseHTTPRequestHandler): if page_data['amt_var'] or page_data['rate_var']: page_data['autoaccept'] = False - if b'step1' in form_data: - if len(errors) == 0 and b'continue' in form_data: + if have_data_entry(form_data, 'step1'): + if len(errors) == 0 and have_data_entry(form_data, 'continue'): page_data['step2'] = True return parsed_data, errors @@ -727,6 +727,8 @@ class HttpHandler(BaseHTTPRequestHandler): for e in errors: messages.append('Error: {}'.format(str(e))) except Exception as e: + if swap_client.debug is True: + swap_client.log.error(traceback.format_exc()) messages.append('Error: {}'.format(str(e))) if len(messages) == 0 and 'submit_offer' in page_data: @@ -735,6 +737,8 @@ class HttpHandler(BaseHTTPRequestHandler): messages.append('Sent Offer {}'.format(offer_id.hex())) page_data = {} except Exception as e: + if swap_client.debug is True: + swap_client.log.error(traceback.format_exc()) messages.append('Error: {}'.format(str(e))) if len(messages) == 0 and 'check_offer' in page_data: