vspd/webapi/types.go
Jamie Holdstock ccafd8dec4
Calculate fee from percentage. (#69)
* Calculate fee from percentage.

- Reverted config to accept a fee percentage, not absolute value.
- The fee amount to be paid is now included in the `getfeeaddress` response. The current best block is used to calculate the fee percentage, and new blocks may be mined before the fee is paid, so the fee expiry period is shortened from 24 hours to 1 hour to mitigate this.
- Rename ticket db field to FeeAmount so it is more representative of the data it holds.
- API fields renamed to "FeePercentage" and "FeeAmount"
- Relay fee is still hard coded.

* Use getbestblockhash
2020-05-27 14:44:40 +01:00

62 lines
2.3 KiB
Go

package webapi
type pubKeyResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
PubKey []byte `json:"pubkey" binding:"required"`
}
type feeResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
FeePercentage float64 `json:"feepercentage" binding:"required"`
}
type FeeAddressRequest struct {
Timestamp int64 `json:"timestamp" binding:"required"`
TicketHash string `json:"tickethash" binding:"required"`
}
type feeAddressResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
FeeAddress string `json:"feeaddress" binding:"required"`
FeeAmount float64 `json:"feeamount" binding:"required"`
Expiration int64 `json:"expiration" binding:"required"`
Request FeeAddressRequest `json:"request" binding:"required"`
}
type PayFeeRequest struct {
Timestamp int64 `json:"timestamp" binding:"required"`
TicketHash string `json:"tickethash" binding:"required"`
FeeTx string `json:"feetx" binding:"required"`
VotingKey string `json:"votingkey" binding:"required"`
VoteChoices map[string]string `json:"votechoices" binding:"required"`
}
type payFeeResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
Request PayFeeRequest `json:"request" binding:"required"`
}
type SetVoteChoicesRequest struct {
Timestamp int64 `json:"timestamp" binding:"required"`
TicketHash string `json:"tickethash" binding:"required"`
VoteChoices map[string]string `json:"votechoices" binding:"required"`
}
type setVoteChoicesResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
Request SetVoteChoicesRequest `json:"request" binding:"required"`
VoteChoices map[string]string `json:"votechoices" binding:"required"`
}
type TicketStatusRequest struct {
Timestamp int64 `json:"timestamp" binding:"required"`
TicketHash string `json:"tickethash" binding:"required"`
}
type ticketStatusResponse struct {
Timestamp int64 `json:"timestamp" binding:"required"`
Request TicketStatusRequest `json:"request" binding:"required"`
Status string `json:"status" binding:"required"`
VoteChoices map[string]string `json:"votechoices" binding:"required"`
}