From 55ded71686d087bc601f94e766115fa67cd4f9f6 Mon Sep 17 00:00:00 2001
From: tecnovert <tecnovert@tecnovert.net>
Date: Sat, 29 Jul 2023 11:58:19 +0200
Subject: [PATCH] Add tx in mempool and in chain statuses.

---
 basicswap/basicswap.py      | 7 ++++++-
 basicswap/basicswap_util.py | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py
index 6cb1a69..51271cc 100644
--- a/basicswap/basicswap.py
+++ b/basicswap/basicswap.py
@@ -3409,6 +3409,7 @@ class BasicSwap(BaseApp):
                     chain_height=found_tx['height'],
                 )
                 bid_changed = True
+                bid.xmr_b_lock_tx.setState(TxStates.TX_IN_CHAIN)
             else:
                 bid.xmr_b_lock_tx.chain_height = found_tx['height']
                 bid_changed = True
@@ -3551,9 +3552,13 @@ class BasicSwap(BaseApp):
                 if lock_tx_chain_info is None:
                     return rv
 
+                if bid.xmr_a_lock_tx.state == TxStates.TX_NONE and lock_tx_chain_info['height'] == 0:
+                    bid.xmr_a_lock_tx.setState(TxStates.TX_IN_MEMPOOL)
+
                 if not bid.xmr_a_lock_tx.chain_height and lock_tx_chain_info['height'] != 0:
                     self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_A_SEEN, '', session)
                     self.setTxBlockInfoFromHeight(ci_from, bid.xmr_a_lock_tx, lock_tx_chain_info['height'])
+                    bid.xmr_a_lock_tx.setState(TxStates.TX_IN_CHAIN)
 
                     bid_changed = True
                 if bid.xmr_a_lock_tx.chain_height != lock_tx_chain_info['height'] and lock_tx_chain_info['height'] != 0:
@@ -5265,7 +5270,7 @@ class BasicSwap(BaseApp):
             txid=b_lock_tx_id,
         )
         xmr_swap.b_lock_tx_id = b_lock_tx_id
-        bid.xmr_b_lock_tx.setState(TxStates.TX_NONE)
+        bid.xmr_b_lock_tx.setState(TxStates.TX_SENT)
         self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_PUBLISHED, '', session)
 
         self.saveBidInSession(bid_id, bid, session, xmr_swap, save_in_progress=offer)
diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py
index 6fb2d66..535023e 100644
--- a/basicswap/basicswap_util.py
+++ b/basicswap/basicswap_util.py
@@ -111,6 +111,8 @@ class TxStates(IntEnum):
     TX_CONFIRMED = auto()
     TX_REDEEMED = auto()
     TX_REFUNDED = auto()
+    TX_IN_MEMPOOL = auto()
+    TX_IN_CHAIN = auto()
 
 
 class TxTypes(IntEnum):
@@ -323,6 +325,10 @@ def strTxState(state):
         return 'Redeemed'
     if state == TxStates.TX_REFUNDED:
         return 'Refunded'
+    if state == TxStates.TX_IN_MEMPOOL:
+        return 'In Mempool'
+    if state == TxStates.TX_IN_CHAIN:
+        return 'In Chain'
     return 'Unknown'