From d57366c0b2d9b09242024ceba3eae802451194d9 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 1 Feb 2024 00:58:14 +0200 Subject: [PATCH] Prevent multiple LOCK_TX_B_SEEN events, use rpcwallet for lockunspent. --- basicswap/__init__.py | 2 +- basicswap/basicswap.py | 2 +- basicswap/basicswap_util.py | 3 +++ basicswap/interface/btc.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/basicswap/__init__.py b/basicswap/__init__.py index e6bd034..f951052 100644 --- a/basicswap/__init__.py +++ b/basicswap/__init__.py @@ -1,3 +1,3 @@ name = "basicswap" -__version__ = "0.12.5" +__version__ = "0.12.6" diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 6356128..db2333f 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -3534,7 +3534,7 @@ class BasicSwap(BaseApp): self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_INVALID, 'Detected invalid lock tx B', session) bid_changed = True elif found_tx is not None: - if bid.xmr_b_lock_tx is None or not bid.xmr_b_lock_tx.chain_height: + if found_tx['height'] != 0 and (bid.xmr_b_lock_tx is None or not bid.xmr_b_lock_tx.chain_height): self.logBidEvent(bid.bid_id, EventLogTypes.LOCK_TX_B_SEEN, '', session) if bid.xmr_b_lock_tx is None: self.log.debug('Found {} lock tx in chain'.format(ci_to.coin_name())) diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py index 996e783..e449ccd 100644 --- a/basicswap/basicswap_util.py +++ b/basicswap/basicswap_util.py @@ -180,6 +180,7 @@ class EventLogTypes(IntEnum): PTX_PUBLISHED = auto() PTX_REDEEM_PUBLISHED = auto() PTX_REFUND_PUBLISHED = auto() + LOCK_TX_B_IN_MEMPOOL = auto() class XmrSplitMsgTypes(IntEnum): @@ -391,6 +392,8 @@ def describeEventEntry(event_type, event_msg): return 'Lock tx B seen in chain' if event_type == EventLogTypes.LOCK_TX_B_CONFIRMED: return 'Lock tx B confirmed in chain' + if event_type == EventLogTypes.LOCK_TX_B_IN_MEMPOOL: + return 'Lock tx B seen in mempool' if event_type == EventLogTypes.DEBUG_TWEAK_APPLIED: return 'Debug tweak applied ' + event_msg if event_type == EventLogTypes.FAILED_TX_B_REFUND: diff --git a/basicswap/interface/btc.py b/basicswap/interface/btc.py index 1faa1dd..e21109c 100644 --- a/basicswap/interface/btc.py +++ b/basicswap/interface/btc.py @@ -981,7 +981,7 @@ class BTCInterface(CoinInterface): inputs = [] for pi in tx.vin: inputs.append({'txid': i2h(pi.prevout.hash), 'vout': pi.prevout.n}) - self.rpc('lockunspent', [True, inputs]) + self.rpc_wallet('lockunspent', [True, inputs]) def signTxWithWallet(self, tx: bytes) -> bytes: rv = self.rpc_wallet('signrawtransactionwithwallet', [tx.hex()])