diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index a562bcd..ead0982 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -2040,6 +2040,7 @@ class BasicSwap(BaseApp): script=script, ) bid.setITxState(TxStates.TX_SENT) + self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.ITX_PUBLISHED, '', None) # Check non-bip68 final try: @@ -2758,6 +2759,7 @@ class BasicSwap(BaseApp): txid = self.ci(coin_to).publishTx(bytes.fromhex(txn)) self.log.debug('Submitted participate txn %s to %s chain for bid %s', txid, chainparams[coin_to]['name'], bid_id.hex()) bid.setPTxState(TxStates.TX_SENT) + self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.PTX_PUBLISHED, '', None) else: bid.participate_tx = SwapTx( bid_id=bid_id, @@ -2811,6 +2813,7 @@ class BasicSwap(BaseApp): txn = self.createRedeemTxn(ci_to.coin_type(), bid) txid = ci_to.publishTx(bytes.fromhex(txn)) self.log.debug('Submitted participate redeem txn %s to %s chain for bid %s', txid, ci_to.coin_name(), bid_id.hex()) + self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.PTX_REDEEM_PUBLISHED, '', None) # TX_REDEEMED will be set when spend is detected # TODO: Wait for depth? @@ -3291,6 +3294,7 @@ class BasicSwap(BaseApp): try: txid = ci_from.publishTx(bid.initiate_txn_refund) self.log.debug('Submitted initiate refund txn %s to %s chain for bid %s', txid, chainparams[coin_from]['name'], bid_id.hex()) + self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.ITX_REFUND_PUBLISHED, '', None) # State will update when spend is detected except Exception as ex: if 'non-BIP68-final' not in str(ex) and 'non-final' not in str(ex): @@ -3301,6 +3305,7 @@ class BasicSwap(BaseApp): try: txid = ci_to.publishTx(bid.participate_txn_refund) self.log.debug('Submitted participate refund txn %s to %s chain for bid %s', txid, chainparams[coin_to]['name'], bid_id.hex()) + self.logEvent(Concepts.BID, bid.bid_id, EventLogTypes.PTX_REFUND_PUBLISHED, '', None) # State will update when spend is detected except Exception as ex: if 'non-BIP68-final' not in str(ex) and 'non-final' not in str(ex): diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py index bc25a45..00b414f 100644 --- a/basicswap/basicswap_util.py +++ b/basicswap/basicswap_util.py @@ -162,6 +162,12 @@ class EventLogTypes(IntEnum): ERROR = auto() AUTOMATION_CONSTRAINT = auto() AUTOMATION_ACCEPTING_BID = auto() + ITX_PUBLISHED = auto() + ITX_REDEEM_PUBLISHED = auto() + ITX_REFUND_PUBLISHED = auto() + PTX_PUBLISHED = auto() + PTX_REDEEM_PUBLISHED = auto() + PTX_REFUND_PUBLISHED = auto() class XmrSplitMsgTypes(IntEnum): @@ -357,6 +363,18 @@ def describeEventEntry(event_type, event_msg): return 'Failed auto accepting' if event_type == EventLogTypes.AUTOMATION_ACCEPTING_BID: return 'Auto accepting' + if event_type == EventLogTypes.ITX_PUBLISHED: + return 'Initiate tx published' + if event_type == EventLogTypes.ITX_REDEEM_PUBLISHED: + return 'Initiate tx redeem tx published' + if event_type == EventLogTypes.ITX_REFUND_PUBLISHED: + return 'Initiate tx refund tx published' + if event_type == EventLogTypes.PTX_PUBLISHED: + return 'Participate tx published' + if event_type == EventLogTypes.PTX_REDEEM_PUBLISHED: + return 'Participate tx redeem tx published' + if event_type == EventLogTypes.PTX_REFUND_PUBLISHED: + return 'Participate tx refund tx published' def getVoutByAddress(txjs, p2sh): diff --git a/basicswap/protocols/atomic_swap_1.py b/basicswap/protocols/atomic_swap_1.py index 62774ae..325f3ef 100644 --- a/basicswap/protocols/atomic_swap_1.py +++ b/basicswap/protocols/atomic_swap_1.py @@ -4,12 +4,18 @@ # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. +from basicswap.db import ( + Concepts, +) from basicswap.util import ( SerialiseNum, ) from basicswap.script import ( OpCodes, ) +from basicswap.basicswap_util import ( + EventLogTypes, +) INITIATE_TX_TIMEOUT = 40 * 60 # TODO: make variable per coin ABS_LOCK_TIME_LEEWAY = 10 * 60 @@ -59,3 +65,4 @@ def redeemITx(self, bid_id, session): bid.initiate_tx.spend_txid = bytes.fromhex(txid) self.log.debug('Submitted initiate redeem txn %s to %s chain for bid %s', txid, ci_from.coin_name(), bid_id.hex()) + self.logEvent(Concepts.BID, bid_id, EventLogTypes.ITX_REDEEM_PUBLISHED, '', session)