From bd4291ab4563dba14f63543fe110d7ba4cfb6d98 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 14 Nov 2024 18:34:46 +0200 Subject: [PATCH] Add event when BCH mercy tx published. --- basicswap/basicswap.py | 16 +++++++++++----- basicswap/basicswap_util.py | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 22c47bb..7bf25a3 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -3879,19 +3879,25 @@ class BasicSwap(BaseApp): tx_type=TxTypes.XMR_SWAP_A_LOCK_REFUND_SWIPE, txid=bytes.fromhex(txid), ) - self.saveBidInSession(bid_id, bid, session, xmr_swap) - session.commit() - if self.isBchXmrSwap(offer): if ci_from.altruistic(): for_ed25519: bool = True if ci_to.curve_type() == Curves.ed25519 else False kbsf = self.getPathKey(ci_from.coin_type(), ci_to.coin_type(), bid.created_at, xmr_swap.contract_count, KeyTypes.KBSF, for_ed25519) mercy_tx = ci_from.createMercyTx(xmr_swap.a_lock_refund_swipe_tx, h2b(txid), xmr_swap.a_lock_refund_tx_script, kbsf) - txid = ci_from.publishTx(mercy_tx) - self.log.info('Submitted mercy tx for bid {}, txid {}'.format(bid_id.hex(), txid)) + txid_hex: str = ci_from.publishTx(mercy_tx) + bid.txns[TxTypes.BCH_MERCY] = SwapTx( + bid_id=bid_id, + tx_type=TxTypes.BCH_MERCY, + txid=bytes.fromhex(txid_hex), + ) + self.log.info('Submitted mercy tx for bid {}, txid {}'.format(bid_id.hex(), txid_hex)) + self.logBidEvent(bid_id, EventLogTypes.BCH_MERCY_TX_PUBLISHED, '', session) else: self.log.info('Not sending mercy tx for bid {}'.format(bid_id.hex())) + + self.saveBidInSession(bid_id, bid, session, xmr_swap) + session.commit() except Exception as ex: self.log.debug('Trying to publish coin a lock refund swipe tx: %s', str(ex)) diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py index ac44c68..53231f8 100644 --- a/basicswap/basicswap_util.py +++ b/basicswap/basicswap_util.py @@ -186,6 +186,7 @@ class EventLogTypes(IntEnum): PTX_REDEEM_PUBLISHED = auto() PTX_REFUND_PUBLISHED = auto() LOCK_TX_B_IN_MEMPOOL = auto() + BCH_MERCY_TX_PUBLISHED = auto() BCH_MERCY_TX_FOUND = auto() @@ -456,6 +457,8 @@ def describeEventEntry(event_type, event_msg): return 'Participate tx refund tx published' if event_type == EventLogTypes.BCH_MERCY_TX_FOUND: return 'BCH mercy tx found' + if event_type == EventLogTypes.BCH_MERCY_TX_PUBLISHED: + return 'Lock tx B mercy tx published' def getVoutByAddress(txjs, p2sh):