From dcfc2e969deac810c88a619e9fffa733bdc851bd Mon Sep 17 00:00:00 2001 From: jholdstock Date: Wed, 3 Jun 2020 15:47:40 +0100 Subject: [PATCH] Check if fee already paid before checking if ticket is votable --- webapi/getfeeaddress.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webapi/getfeeaddress.go b/webapi/getfeeaddress.go index ff569a4..8751400 100644 --- a/webapi/getfeeaddress.go +++ b/webapi/getfeeaddress.go @@ -83,6 +83,13 @@ func feeAddress(c *gin.Context) { ticketHash := feeAddressRequest.TicketHash + // Respond early if we already have the fee tx for this ticket. + if ticket.FeeTxHex != "" { + log.Warnf("Fee tx already received from %s: ticketHash=%s", c.ClientIP(), ticket.Hash) + sendErrorResponse("fee tx already received", http.StatusBadRequest, c) + return + } + canVote, err := dcrdClient.CanTicketVote(ticketHash, cfg.NetParams) if err != nil { log.Errorf("canTicketVote error: %v", err) @@ -98,13 +105,6 @@ func feeAddress(c *gin.Context) { // VSP already knows this ticket and has already issued it a fee address. if knownTicket { - // Respond early if we already have the fee tx for this ticket. - if ticket.FeeTxHex != "" { - log.Warnf("Fee tx already received from %s: ticketHash=%s", c.ClientIP(), ticket.Hash) - sendErrorResponse("fee tx already received", http.StatusBadRequest, c) - return - } - // If the expiry period has passed we need to issue a new fee. now := time.Now() if ticket.FeeExpired() {