change feeamount from float64 to int64/atoms (#121)
This commit is contained in:
parent
873d89e412
commit
83514385d6
@ -12,12 +12,12 @@ import (
|
||||
// Ticket is serialized to json and stored in bbolt db. The json keys are
|
||||
// deliberately kept short because they are duplicated many times in the db.
|
||||
type Ticket struct {
|
||||
Hash string `json:"hsh"`
|
||||
CommitmentAddress string `json:"cmtaddr"`
|
||||
FeeAddressIndex uint32 `json:"faddridx"`
|
||||
FeeAddress string `json:"faddr"`
|
||||
FeeAmount float64 `json:"famt"`
|
||||
FeeExpiration int64 `json:"fexp"`
|
||||
Hash string `json:"hsh"`
|
||||
CommitmentAddress string `json:"cmtaddr"`
|
||||
FeeAddressIndex uint32 `json:"faddridx"`
|
||||
FeeAddress string `json:"faddr"`
|
||||
FeeAmount int64 `json:"famt"`
|
||||
FeeExpiration int64 `json:"fexp"`
|
||||
|
||||
// Confirmed will be set when the ticket has 6+ confirmations.
|
||||
Confirmed bool `json:"conf"`
|
||||
|
||||
@ -12,7 +12,7 @@ func exampleTicket() Ticket {
|
||||
CommitmentAddress: "Address",
|
||||
FeeAddressIndex: 12345,
|
||||
FeeAddress: "FeeAddress",
|
||||
FeeAmount: 0.1,
|
||||
FeeAmount: 10000000,
|
||||
FeeExpiration: 4,
|
||||
Confirmed: false,
|
||||
VoteChoices: map[string]string{"AgendaID": "Choice"},
|
||||
|
||||
@ -123,7 +123,7 @@ func feeAddress(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
ticket.FeeExpiration = now.Add(feeAddressExpiration).Unix()
|
||||
ticket.FeeAmount = newFee.ToCoin()
|
||||
ticket.FeeAmount = int64(newFee)
|
||||
|
||||
err = db.UpdateTicket(ticket)
|
||||
if err != nil {
|
||||
@ -171,7 +171,7 @@ func feeAddress(c *gin.Context) {
|
||||
FeeAddressIndex: newAddressIdx,
|
||||
FeeAddress: newAddress,
|
||||
Confirmed: confirmed,
|
||||
FeeAmount: fee.ToCoin(),
|
||||
FeeAmount: int64(fee),
|
||||
FeeExpiration: expire,
|
||||
// VotingKey and VoteChoices: set during payfee
|
||||
}
|
||||
@ -190,7 +190,7 @@ func feeAddress(c *gin.Context) {
|
||||
Timestamp: now.Unix(),
|
||||
Request: feeAddressRequest,
|
||||
FeeAddress: newAddress,
|
||||
FeeAmount: fee.ToCoin(),
|
||||
FeeAmount: int64(fee),
|
||||
Expiration: expire,
|
||||
}, c)
|
||||
}
|
||||
|
||||
@ -185,15 +185,10 @@ findAddress:
|
||||
return
|
||||
}
|
||||
|
||||
minFee, err := dcrutil.NewAmount(ticket.FeeAmount)
|
||||
if err != nil {
|
||||
log.Errorf("dcrutil.NewAmount: %v", err)
|
||||
sendError(errInternalError, c)
|
||||
return
|
||||
}
|
||||
|
||||
minFee := dcrutil.Amount(ticket.FeeAmount)
|
||||
if feePaid < minFee {
|
||||
log.Warnf("Fee too small from %s: was %v, expected %v", c.ClientIP(), feePaid, minFee)
|
||||
log.Warnf("Fee too small from %s: was %v, expected %v", c.ClientIP(),
|
||||
feePaid, minFee)
|
||||
sendError(errFeeTooSmall, c)
|
||||
return
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ type FeeAddressRequest struct {
|
||||
type feeAddressResponse struct {
|
||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||
FeeAddress string `json:"feeaddress" binding:"required"`
|
||||
FeeAmount float64 `json:"feeamount" binding:"required"`
|
||||
FeeAmount int64 `json:"feeamount" binding:"required"`
|
||||
Expiration int64 `json:"expiration" binding:"required"`
|
||||
Request FeeAddressRequest `json:"request" binding:"required"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user