add /fee and /pubkey methods (#2)

This commit is contained in:
David Hill 2020-05-14 02:28:05 -05:00 committed by GitHub
parent a1429c7d8d
commit 43f80f009d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -37,6 +37,20 @@ func sendJSONResponse(resp interface{}, code int, c *gin.Context) {
c.Writer.Write(dec) c.Writer.Write(dec)
} }
func pubKey(c *gin.Context) {
sendJSONResponse(pubKeyResponse{
Timestamp: time.Now().Unix(),
PubKey: cfg.pubKey,
}, http.StatusOK, c)
}
func fee(c *gin.Context) {
sendJSONResponse(feeResponse{
Timestamp: time.Now().Unix(),
Fee: cfg.poolFees,
}, http.StatusOK, c)
}
func payFee(c *gin.Context) { func payFee(c *gin.Context) {
// HTTP GET Params required // HTTP GET Params required
// feeTx - serialized wire.MsgTx // feeTx - serialized wire.MsgTx

View File

@ -1,11 +1,11 @@
package main package main
type getPubKeyResponse struct { type pubKeyResponse struct {
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
PubKey []byte `json:"pubKey"` PubKey []byte `json:"pubKey"`
} }
type getFeeResponse struct { type feeResponse struct {
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
Fee float64 `json:"fee"` Fee float64 `json:"fee"`
} }

View File

@ -11,6 +11,8 @@ func newRouter() *gin.Engine {
api.Use() api.Use()
{ {
router.GET("/fee", fee)
router.GET("/pubkey", pubKey)
router.GET("/payfee", payFee) router.GET("/payfee", payFee)
} }