From 0f657eb4fe6b143d757a5cd2936b7d04cef6849e Mon Sep 17 00:00:00 2001 From: jholdstock Date: Thu, 12 Nov 2020 10:53:14 +0000 Subject: [PATCH] Register tickets with invalid vote choices. /payfee will no longer reject tickets with invalid vote choices. The tickets will be registered with the VSP and added to voting wallets, but their voting choices will be empty. A warning will be added to server logs. --- webapi/payfee.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/webapi/payfee.go b/webapi/payfee.go index 408c632..ba6abda 100644 --- a/webapi/payfee.go +++ b/webapi/payfee.go @@ -101,14 +101,14 @@ func payFee(c *gin.Context) { return } - // Validate VoteChoices. - voteChoices := request.VoteChoices - err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices) + // Validate VoteChoices. Just log a warning if vote choices are not valid + // for the current vote version - the ticket should still be registered. + validVoteChoices := true + err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), request.VoteChoices) if err != nil { + validVoteChoices = false log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v", funcName, c.ClientIP(), ticket.Hash, err) - sendErrorWithMsg(err.Error(), errInvalidVoteChoices, c) - return } // Validate FeeTx. @@ -219,9 +219,12 @@ findAddress: ticket.VotingWIF = votingWIF.String() ticket.FeeTxHex = request.FeeTx ticket.FeeTxHash = feeTx.TxHash().String() - ticket.VoteChoices = voteChoices ticket.FeeTxStatus = database.FeeReceieved + if validVoteChoices { + ticket.VoteChoices = request.VoteChoices + } + err = db.UpdateTicket(ticket) if err != nil { log.Errorf("%s: db.UpdateTicket error, failed to set fee tx (ticketHash=%s): %v",