diff --git a/pluginmgr/webapi/plugins.go b/pluginmgr/webapi/plugins.go index 6299901d87e3547c2acd8be3306522e91ad87ec6..76f1df7589bc908190e084fceba4688fd826e047 100644 --- a/pluginmgr/webapi/plugins.go +++ b/pluginmgr/webapi/plugins.go @@ -5,6 +5,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/webapi/autopeering" "github.com/iotaledger/goshimmer/plugins/webapi/data" "github.com/iotaledger/goshimmer/plugins/webapi/drng" + "github.com/iotaledger/goshimmer/plugins/webapi/info" "github.com/iotaledger/goshimmer/plugins/webapi/message" "github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/goshimmer/plugins/webauth" @@ -19,4 +20,5 @@ var PLUGINS = node.Plugins( drng.PLUGIN, message.PLUGIN, autopeering.PLUGIN, + info.PLUGIN, ) diff --git a/plugins/drng/drng.go b/plugins/drng/drng.go index 1f4385d3f477ee9e8a714c1ab91478807cd32658..1af625823414239ed0d43a0e0bfe240f29833660 100644 --- a/plugins/drng/drng.go +++ b/plugins/drng/drng.go @@ -1,7 +1,7 @@ package drng import ( - "encoding/base64" + "encoding/hex" "errors" "fmt" @@ -20,7 +20,7 @@ func parseCommitteeMembers() (result []ed25519.PublicKey, err error) { continue } - pubKey, err := base64.StdEncoding.DecodeString(committeeMember) + pubKey, err := hex.DecodeString(committeeMember) if err != nil { return nil, fmt.Errorf("%w: invalid public key: %s", ErrParsingCommitteeMember, err) } diff --git a/plugins/webapi/info/plugin.go b/plugins/webapi/info/plugin.go new file mode 100644 index 0000000000000000000000000000000000000000..13eaf5e11059bdd540000722b7ca18620d589db7 --- /dev/null +++ b/plugins/webapi/info/plugin.go @@ -0,0 +1,27 @@ +package info + +import ( + "encoding/hex" + "net/http" + + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/node" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI info Endpoint", node.Enabled, configure) + +func configure(plugin *node.Plugin) { + webapi.Server.GET("info", getInfo) +} + +// getInfo returns the info of the node +func getInfo(c echo.Context) error { + return c.JSON(http.StatusOK, Response{PublicKey: hex.EncodeToString(local.GetInstance().PublicKey().Bytes())}) +} + +type Response struct { + PublicKey string `json:"publickey,omitempty"` + Error string `json:"error,omitempty"` +}