Log events for all sent transactions.

This commit is contained in:
tecnovert 2022-11-08 23:07:58 +02:00
parent 8b2d2b446b
commit ae2ddc4049
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
3 changed files with 30 additions and 0 deletions

View file

@ -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):

View file

@ -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):

View file

@ -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)