Don't export types unnecessarily
This commit is contained in:
parent
b8c6ffe1e0
commit
bcb6fd5ec3
@ -73,14 +73,14 @@ func feeAddress(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var feeAddressRequest FeeAddressRequest
|
var request feeAddressRequest
|
||||||
if err := c.ShouldBindJSON(&feeAddressRequest); err != nil {
|
if err := c.ShouldBindJSON(&request); err != nil {
|
||||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ticketHash := feeAddressRequest.TicketHash
|
ticketHash := request.TicketHash
|
||||||
|
|
||||||
// Respond early if we already have the fee tx for this ticket.
|
// Respond early if we already have the fee tx for this ticket.
|
||||||
if ticket.FeeTxStatus == database.FeeReceieved ||
|
if ticket.FeeTxStatus == database.FeeReceieved ||
|
||||||
@ -141,7 +141,7 @@ func feeAddress(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
sendJSONResponse(feeAddressResponse{
|
sendJSONResponse(feeAddressResponse{
|
||||||
Timestamp: now.Unix(),
|
Timestamp: now.Unix(),
|
||||||
Request: feeAddressRequest,
|
Request: request,
|
||||||
FeeAddress: ticket.FeeAddress,
|
FeeAddress: ticket.FeeAddress,
|
||||||
FeeAmount: ticket.FeeAmount,
|
FeeAmount: ticket.FeeAmount,
|
||||||
Expiration: ticket.FeeExpiration,
|
Expiration: ticket.FeeExpiration,
|
||||||
@ -194,7 +194,7 @@ func feeAddress(c *gin.Context) {
|
|||||||
|
|
||||||
sendJSONResponse(feeAddressResponse{
|
sendJSONResponse(feeAddressResponse{
|
||||||
Timestamp: now.Unix(),
|
Timestamp: now.Unix(),
|
||||||
Request: feeAddressRequest,
|
Request: request,
|
||||||
FeeAddress: newAddress,
|
FeeAddress: newAddress,
|
||||||
FeeAmount: int64(fee),
|
FeeAmount: int64(fee),
|
||||||
Expiration: expire,
|
Expiration: expire,
|
||||||
|
|||||||
@ -32,8 +32,8 @@ func payFee(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var payFeeRequest PayFeeRequest
|
var request payFeeRequest
|
||||||
if err := c.ShouldBindJSON(&payFeeRequest); err != nil {
|
if err := c.ShouldBindJSON(&request); err != nil {
|
||||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||||
return
|
return
|
||||||
@ -80,7 +80,7 @@ func payFee(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate VotingKey.
|
// Validate VotingKey.
|
||||||
votingKey := payFeeRequest.VotingKey
|
votingKey := request.VotingKey
|
||||||
votingWIF, err := dcrutil.DecodeWIF(votingKey, cfg.NetParams.PrivateKeyID)
|
votingWIF, err := dcrutil.DecodeWIF(votingKey, cfg.NetParams.PrivateKeyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("%s: Failed to decode WIF (clientIP=%s, ticketHash=%s): %v",
|
log.Warnf("%s: Failed to decode WIF (clientIP=%s, ticketHash=%s): %v",
|
||||||
@ -90,7 +90,7 @@ func payFee(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate VoteChoices.
|
// Validate VoteChoices.
|
||||||
voteChoices := payFeeRequest.VoteChoices
|
voteChoices := request.VoteChoices
|
||||||
err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
err = isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
||||||
@ -100,7 +100,7 @@ func payFee(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate FeeTx.
|
// Validate FeeTx.
|
||||||
feeTx, err := decodeTransaction(payFeeRequest.FeeTx)
|
feeTx, err := decodeTransaction(request.FeeTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("%s: Failed to decode fee tx hex (clientIP=%s, ticketHash=%s): %v",
|
log.Warnf("%s: Failed to decode fee tx hex (clientIP=%s, ticketHash=%s): %v",
|
||||||
funcName, c.ClientIP(), ticket.Hash, err)
|
funcName, c.ClientIP(), ticket.Hash, err)
|
||||||
@ -205,7 +205,7 @@ findAddress:
|
|||||||
// database, and if the ticket is confirmed broadcast the transaction.
|
// database, and if the ticket is confirmed broadcast the transaction.
|
||||||
|
|
||||||
ticket.VotingWIF = votingWIF.String()
|
ticket.VotingWIF = votingWIF.String()
|
||||||
ticket.FeeTxHex = payFeeRequest.FeeTx
|
ticket.FeeTxHex = request.FeeTx
|
||||||
ticket.FeeTxHash = feeTx.TxHash().String()
|
ticket.FeeTxHash = feeTx.TxHash().String()
|
||||||
ticket.VoteChoices = voteChoices
|
ticket.VoteChoices = voteChoices
|
||||||
ticket.FeeTxStatus = database.FeeReceieved
|
ticket.FeeTxStatus = database.FeeReceieved
|
||||||
@ -222,7 +222,7 @@ findAddress:
|
|||||||
funcName, minFee, feePaid, ticket.Hash)
|
funcName, minFee, feePaid, ticket.Hash)
|
||||||
|
|
||||||
if ticket.Confirmed {
|
if ticket.Confirmed {
|
||||||
err = dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
|
err = dcrdClient.SendRawTransaction(request.FeeTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: dcrd.SendRawTransaction for fee tx failed (ticketHash=%s): %v",
|
log.Errorf("%s: dcrd.SendRawTransaction for fee tx failed (ticketHash=%s): %v",
|
||||||
funcName, ticket.Hash, err)
|
funcName, ticket.Hash, err)
|
||||||
@ -255,6 +255,6 @@ findAddress:
|
|||||||
|
|
||||||
sendJSONResponse(payFeeResponse{
|
sendJSONResponse(payFeeResponse{
|
||||||
Timestamp: time.Now().Unix(),
|
Timestamp: time.Now().Unix(),
|
||||||
Request: payFeeRequest,
|
Request: request,
|
||||||
}, c)
|
}, c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,14 +30,14 @@ func setVoteChoices(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var setVoteChoicesRequest SetVoteChoicesRequest
|
var request setVoteChoicesRequest
|
||||||
if err := c.ShouldBindJSON(&setVoteChoicesRequest); err != nil {
|
if err := c.ShouldBindJSON(&request); err != nil {
|
||||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
voteChoices := setVoteChoicesRequest.VoteChoices
|
voteChoices := request.VoteChoices
|
||||||
err := isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
err := isValidVoteChoices(cfg.NetParams, currentVoteVersion(cfg.NetParams), voteChoices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
log.Warnf("%s: Invalid vote choices (clientIP=%s, ticketHash=%s): %v",
|
||||||
@ -81,6 +81,6 @@ func setVoteChoices(c *gin.Context) {
|
|||||||
|
|
||||||
sendJSONResponse(setVoteChoicesResponse{
|
sendJSONResponse(setVoteChoicesResponse{
|
||||||
Timestamp: time.Now().Unix(),
|
Timestamp: time.Now().Unix(),
|
||||||
Request: setVoteChoicesRequest,
|
Request: request,
|
||||||
}, c)
|
}, c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,8 @@ func ticketStatus(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var ticketStatusRequest TicketStatusRequest
|
var request ticketStatusRequest
|
||||||
if err := c.ShouldBindJSON(&ticketStatusRequest); err != nil {
|
if err := c.ShouldBindJSON(&request); err != nil {
|
||||||
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
log.Warnf("%s: Bad request (clientIP=%s): %v", funcName, c.ClientIP(), err)
|
||||||
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
sendErrorWithMsg(err.Error(), errBadRequest, c)
|
||||||
return
|
return
|
||||||
@ -30,7 +30,7 @@ func ticketStatus(c *gin.Context) {
|
|||||||
|
|
||||||
sendJSONResponse(ticketStatusResponse{
|
sendJSONResponse(ticketStatusResponse{
|
||||||
Timestamp: time.Now().Unix(),
|
Timestamp: time.Now().Unix(),
|
||||||
Request: ticketStatusRequest,
|
Request: request,
|
||||||
TicketConfirmed: ticket.Confirmed,
|
TicketConfirmed: ticket.Confirmed,
|
||||||
FeeTxStatus: string(ticket.FeeTxStatus),
|
FeeTxStatus: string(ticket.FeeTxStatus),
|
||||||
FeeTxHash: ticket.FeeTxHash,
|
FeeTxHash: ticket.FeeTxHash,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ type vspInfoResponse struct {
|
|||||||
Revoked int64 `json:"revoked"`
|
Revoked int64 `json:"revoked"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FeeAddressRequest struct {
|
type feeAddressRequest struct {
|
||||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||||
TicketHash string `json:"tickethash" binding:"required"`
|
TicketHash string `json:"tickethash" binding:"required"`
|
||||||
TicketHex string `json:"tickethex" binding:"required"`
|
TicketHex string `json:"tickethex" binding:"required"`
|
||||||
@ -24,10 +24,10 @@ type feeAddressResponse struct {
|
|||||||
FeeAddress string `json:"feeaddress"`
|
FeeAddress string `json:"feeaddress"`
|
||||||
FeeAmount int64 `json:"feeamount"`
|
FeeAmount int64 `json:"feeamount"`
|
||||||
Expiration int64 `json:"expiration"`
|
Expiration int64 `json:"expiration"`
|
||||||
Request FeeAddressRequest `json:"request"`
|
Request feeAddressRequest `json:"request"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PayFeeRequest struct {
|
type payFeeRequest struct {
|
||||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||||
TicketHash string `json:"tickethash" binding:"required"`
|
TicketHash string `json:"tickethash" binding:"required"`
|
||||||
FeeTx string `json:"feetx" binding:"required"`
|
FeeTx string `json:"feetx" binding:"required"`
|
||||||
@ -37,10 +37,10 @@ type PayFeeRequest struct {
|
|||||||
|
|
||||||
type payFeeResponse struct {
|
type payFeeResponse struct {
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
Request PayFeeRequest `json:"request"`
|
Request payFeeRequest `json:"request"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetVoteChoicesRequest struct {
|
type setVoteChoicesRequest struct {
|
||||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||||
TicketHash string `json:"tickethash" binding:"required"`
|
TicketHash string `json:"tickethash" binding:"required"`
|
||||||
VoteChoices map[string]string `json:"votechoices" binding:"required"`
|
VoteChoices map[string]string `json:"votechoices" binding:"required"`
|
||||||
@ -48,10 +48,10 @@ type SetVoteChoicesRequest struct {
|
|||||||
|
|
||||||
type setVoteChoicesResponse struct {
|
type setVoteChoicesResponse struct {
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
Request SetVoteChoicesRequest `json:"request"`
|
Request setVoteChoicesRequest `json:"request"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TicketStatusRequest struct {
|
type ticketStatusRequest struct {
|
||||||
TicketHash string `json:"tickethash" binding:"required"`
|
TicketHash string `json:"tickethash" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,5 +61,5 @@ type ticketStatusResponse struct {
|
|||||||
FeeTxStatus string `json:"feetxstatus"`
|
FeeTxStatus string `json:"feetxstatus"`
|
||||||
FeeTxHash string `json:"feetxhash"`
|
FeeTxHash string `json:"feetxhash"`
|
||||||
VoteChoices map[string]string `json:"votechoices"`
|
VoteChoices map[string]string `json:"votechoices"`
|
||||||
Request TicketStatusRequest `json:"request"`
|
Request ticketStatusRequest `json:"request"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user