Skip to content

Commit

Permalink
client/core: Recognize missing redemptions.
Browse files Browse the repository at this point in the history
When sending redemptions, if the server does not know about the match,
assume revoked and stop sending.
  • Loading branch information
JoeGruffins committed Oct 15, 2024
1 parent 6420232 commit 4a1b4ee
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions client/core/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,24 @@ 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() {
c.updateAssetBalance(t.wallets.fromWallet.AssetID)
}
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
}
Expand Down

0 comments on commit 4a1b4ee

Please sign in to comment.