From e7a62a6a827d566815570e16114514721cf0dc9f Mon Sep 17 00:00:00 2001 From: tecnovert Date: Wed, 22 Jun 2022 22:51:39 +0200 Subject: [PATCH] debug: Log auto accepting event. --- basicswap/basicswap.py | 7 +++++++ basicswap/basicswap_util.py | 5 +++++ basicswap/protocols/xmr_swap_1.py | 10 ++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 1dead1f..c10eaf1 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -3874,6 +3874,12 @@ class BasicSwap(BaseApp): if identity_stats.num_recv_bids_successful <= identity_stats.num_recv_bids_failed: raise AutomationConstraint('Bidder has too many failed swaps') + self.logEvent(Concepts.BID, + bid.bid_id, + EventLogTypes.AUTOMATION_ACCEPTING_BID, + '', + use_session) + return True except AutomationConstraint as e: self.log.info('Not auto accepting bid {}, {}'.format(bid.bid_id.hex(), str(e))) @@ -3889,6 +3895,7 @@ class BasicSwap(BaseApp): return False finally: if session is None: + use_session.commit() use_session.close() use_session.remove() self.mxDB.release() diff --git a/basicswap/basicswap_util.py b/basicswap/basicswap_util.py index 3bf1739..3ce9935 100644 --- a/basicswap/basicswap_util.py +++ b/basicswap/basicswap_util.py @@ -157,6 +157,7 @@ class EventLogTypes(IntEnum): LOCK_TX_A_REFUND_SPEND_TX_SEEN = auto() ERROR = auto() AUTOMATION_CONSTRAINT = auto() + AUTOMATION_ACCEPTING_BID = auto() class XmrSplitMsgTypes(IntEnum): @@ -335,6 +336,10 @@ def describeEventEntry(event_type, event_msg): return 'Warning: ' + event_msg if event_type == EventLogTypes.ERROR: return 'Error: ' + event_msg + if event_type == EventLogTypes.AUTOMATION_CONSTRAINT: + return 'Failed auto accepting' + if event_type == EventLogTypes.AUTOMATION_ACCEPTING_BID: + return 'Auto accepting' def getVoutByAddress(txjs, p2sh): diff --git a/basicswap/protocols/xmr_swap_1.py b/basicswap/protocols/xmr_swap_1.py index 49eff41..3383a87 100644 --- a/basicswap/protocols/xmr_swap_1.py +++ b/basicswap/protocols/xmr_swap_1.py @@ -46,12 +46,18 @@ def recoverNoScriptTxnWithKey(self, bid_id, encoded_key): ci_to = self.ci(offer.coin_to) for_ed25519 = True if Coins(offer.coin_to) == Coins.XMR else False + + try: + decoded_key_half = ci_to.decodeKey(encoded_key) + except Exception as e: + raise ValueError('Failed to decode provided key-half: ', str(e)) + if bid.was_sent: - kbsl = ci_to.decodeKey(encoded_key) + kbsl = decoded_key_half kbsf = self.getPathKey(offer.coin_from, offer.coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSF, for_ed25519) else: kbsl = self.getPathKey(offer.coin_from, offer.coin_to, bid.created_at, xmr_swap.contract_count, KeyTypes.KBSL, for_ed25519) - kbsf = ci_to.decodeKey(encoded_key) + kbsf = decoded_key_half ensure(ci_to.verifyKey(kbsl), 'Invalid kbsl') ensure(ci_to.verifyKey(kbsf), 'Invalid kbsf') vkbs = ci_to.sumKeys(kbsl, kbsf)