aOnly set reversed flag for ads type swaps.

This commit is contained in:
tecnovert 2023-12-01 14:46:57 +02:00
parent 5b6f447692
commit a4c79fb7aa
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
2 changed files with 6 additions and 4 deletions

View File

@ -1523,6 +1523,7 @@ class BasicSwap(BaseApp):
if security_token is not None and len(security_token) != 20: if security_token is not None and len(security_token) != 20:
raise ValueError('Security token must be 20 bytes long.') raise ValueError('Security token must be 20 bytes long.')
bid_reversed: bool = msg_buf.swap_type == SwapTypes.XMR_SWAP and self.is_reverse_ads_bid(msg_buf.coin_from)
session = scoped_session(self.session_factory) session = scoped_session(self.session_factory)
offer = Offer( offer = Offer(
offer_id=offer_id, offer_id=offer_id,
@ -1546,7 +1547,7 @@ class BasicSwap(BaseApp):
created_at=offer_created_at, created_at=offer_created_at,
expire_at=offer_created_at + msg_buf.time_valid, expire_at=offer_created_at + msg_buf.time_valid,
was_sent=True, was_sent=True,
bid_reversed=self.is_reverse_ads_bid(msg_buf.coin_from), bid_reversed=bid_reversed,
security_token=security_token) security_token=security_token)
offer.setState(OfferStates.OFFER_SENT) offer.setState(OfferStates.OFFER_SENT)
@ -4410,6 +4411,7 @@ class BasicSwap(BaseApp):
# Check for sent # Check for sent
existing_offer = self.getOffer(offer_id) existing_offer = self.getOffer(offer_id)
if existing_offer is None: if existing_offer is None:
bid_reversed: bool = offer_data.swap_type == SwapTypes.XMR_SWAP and self.is_reverse_ads_bid(offer_data.coin_from)
offer = Offer( offer = Offer(
offer_id=offer_id, offer_id=offer_id,
active_ind=1, active_ind=1,
@ -4432,7 +4434,7 @@ class BasicSwap(BaseApp):
created_at=msg['sent'], created_at=msg['sent'],
expire_at=msg['sent'] + offer_data.time_valid, expire_at=msg['sent'] + offer_data.time_valid,
was_sent=False, was_sent=False,
bid_reversed=self.is_reverse_ads_bid(offer_data.coin_from)) bid_reversed=bid_reversed)
offer.setState(OfferStates.OFFER_RECEIVED) offer.setState(OfferStates.OFFER_RECEIVED)
session.add(offer) session.add(offer)

View File

@ -488,7 +488,7 @@ def page_offer(self, url_split, post_string):
ci_from = swap_client.ci(Coins(offer.coin_from)) ci_from = swap_client.ci(Coins(offer.coin_from))
ci_to = swap_client.ci(Coins(offer.coin_to)) ci_to = swap_client.ci(Coins(offer.coin_to))
reverse_bid: bool = swap_client.is_reverse_ads_bid(offer.coin_from) reverse_bid: bool = True if offer.bid_reversed else False
# Set defaults # Set defaults
debugind = -1 debugind = -1
@ -590,7 +590,7 @@ def page_offer(self, url_split, post_string):
'is_expired': offer.expire_at <= now, 'is_expired': offer.expire_at <= now,
'active_ind': offer.active_ind, 'active_ind': offer.active_ind,
'swap_type': strSwapDesc(offer.swap_type), 'swap_type': strSwapDesc(offer.swap_type),
'reverse': offer.bid_reversed 'reverse': reverse_bid,
} }
data.update(extend_data) data.update(extend_data)