From 93f6b750872c48d0c96b4657e155e3b184882307 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Tue, 15 Oct 2024 18:32:51 +0900 Subject: [PATCH] client/core: Recognize missing redemptions. When sending redemptions, if the server does not know about the match, assume revoked and stop sending. --- client/core/trade.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/client/core/trade.go b/client/core/trade.go index fc3584caa5..d3daa028f9 100644 --- a/client/core/trade.go +++ b/client/core/trade.go @@ -2879,6 +2879,28 @@ func (c *Core) sendRedeemAsync(t *trackedTrade, match *matchTracker, coinID, sec }, }) } + if errors.As(err, &msgErr) && msgErr.Code == msgjson.RPCUnknownMatch { + oid := t.ID() + c.log.Warnf("DEX %s did not report active match %s on order %s - assuming revoked, status %v.", + t.dc.acct.host, match, oid, match.Status) + // We must have missed the revoke notification. Flag to allow recovery + // and subsequent retirement of the match and parent trade. + match.MetaData.Proof.SelfRevoked = true + if err := c.db.UpdateMatch(&match.MetaMatch); err != nil { + c.log.Errorf("Failed to update missing/revoked match: %v", err) + } + + if t.maybeReturnCoins() { + updatedAssets := make(assetMap) + updatedAssets.count(t.wallets.fromWallet.AssetID) + c.updateBalances(updatedAssets) + } + + numMissing := 1 + subject, details := c.formatDetails(TopicMissingMatches, + numMissing, makeOrderToken(t.token()), t.dc.acct.host) + c.notify(newOrderNote(TopicMissingMatches, subject, details, db.ErrorLevel, t.coreOrderInternal())) + } err = fmt.Errorf("error sending 'redeem' message: %w", err) return }