From 43f80f009da19290d59d567e5f39be8f91441f92 Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 14 May 2020 02:28:05 -0500 Subject: [PATCH] add /fee and /pubkey methods (#2) --- methods.go | 14 ++++++++++++++ responses.go | 4 ++-- router.go | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/methods.go b/methods.go index 65b2d09..e01be6f 100644 --- a/methods.go +++ b/methods.go @@ -37,6 +37,20 @@ func sendJSONResponse(resp interface{}, code int, c *gin.Context) { 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) { // HTTP GET Params required // feeTx - serialized wire.MsgTx diff --git a/responses.go b/responses.go index 2422607..4d9c185 100644 --- a/responses.go +++ b/responses.go @@ -1,11 +1,11 @@ package main -type getPubKeyResponse struct { +type pubKeyResponse struct { Timestamp int64 `json:"timestamp"` PubKey []byte `json:"pubKey"` } -type getFeeResponse struct { +type feeResponse struct { Timestamp int64 `json:"timestamp"` Fee float64 `json:"fee"` } diff --git a/router.go b/router.go index 1f7f694..b542353 100644 --- a/router.go +++ b/router.go @@ -11,6 +11,8 @@ func newRouter() *gin.Engine { api.Use() { + router.GET("/fee", fee) + router.GET("/pubkey", pubKey) router.GET("/payfee", payFee) }