From e3f7b5b79bf09a16672b5b08a742389370b2bded Mon Sep 17 00:00:00 2001 From: tecnovert Date: Sun, 12 Jan 2025 22:23:20 +0200 Subject: [PATCH] Constrain swap state when processing reversed bid accept message. --- basicswap/basicswap.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 756ce04..dfb7d94 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -9548,6 +9548,16 @@ class BasicSwap(BaseApp): ensure(msg["to"] == bid.bid_addr, "Received on incorrect address") ensure(msg["from"] == offer.addr_from, "Sent from incorrect address") + allowed_states = [ + BidStates.BID_REQUEST_SENT, + ] + if bid.was_sent and offer.was_sent: + allowed_states.append(BidStates.BID_REQUEST_ACCEPTED) + ensure( + bid.state in allowed_states, + "Invalid state for bid {}".format(bid.state), + ) + ci_from = self.ci(offer.coin_to) ci_to = self.ci(offer.coin_from)