- Fee tx status is now tracked using a dedicated field, with values none/received/broadcast/confirmed/error. - Fee tx hex and hash are now both set in /payfee. The absense of txhash is no longer used to determine if a fee tx has been broadcast or not. - setvotechoices can no longer be called before a fee is received. - Remove `binding:required` from response types. It has no effect on responses, it is only needed on request types which are validated by gin.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package webapi
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/decred/vspd/database"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin/binding"
|
|
)
|
|
|
|
// ticketStatus is the handler for "GET /ticketstatus".
|
|
func ticketStatus(c *gin.Context) {
|
|
|
|
// Get values which have been added to context by middleware.
|
|
rawRequest := c.MustGet("RawRequest").([]byte)
|
|
ticket := c.MustGet("Ticket").(database.Ticket)
|
|
knownTicket := c.MustGet("KnownTicket").(bool)
|
|
|
|
if !knownTicket {
|
|
log.Warnf("Unknown ticket from %s", c.ClientIP())
|
|
sendError(errUnknownTicket, c)
|
|
return
|
|
}
|
|
|
|
var ticketStatusRequest TicketStatusRequest
|
|
if err := binding.JSON.BindBody(rawRequest, &ticketStatusRequest); err != nil {
|
|
log.Warnf("Bad ticketstatus request from %s: %v", c.ClientIP(), err)
|
|
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
|
return
|
|
}
|
|
|
|
sendJSONResponse(ticketStatusResponse{
|
|
Timestamp: time.Now().Unix(),
|
|
Request: ticketStatusRequest,
|
|
TicketConfirmed: ticket.Confirmed,
|
|
FeeTxStatus: string(ticket.FeeTxStatus),
|
|
FeeTxHash: ticket.FeeTxHash,
|
|
VoteChoices: ticket.VoteChoices,
|
|
}, c)
|
|
}
|