diff --git a/internal/hmyapi/README.md b/internal/hmyapi/README.md index acd84eecc..6baabdb31 100644 --- a/internal/hmyapi/README.md +++ b/internal/hmyapi/README.md @@ -10,6 +10,7 @@ * [x] hmy_protocolVersion - check protocol version * [ ] net_version - get network id * [ ] net_peerCount - peer count +* [x] hmy_getNodeMetadata - get node's version, bls key ### BlockChain info related * [ ] hmy_gasPrice - return min-gas-price @@ -87,4 +88,4 @@ The ``shh`` is for the whisper protocol to communicate p2p and broadcast * [ ] shh_newFilter * [ ] shh_uninstallFilter * [ ] shh_getFilterChanges -* [ ] shh_getMessages \ No newline at end of file +* [ ] shh_getMessages diff --git a/internal/hmyapi/harmony.go b/internal/hmyapi/harmony.go index eb9e988a5..1951a8e71 100644 --- a/internal/hmyapi/harmony.go +++ b/internal/hmyapi/harmony.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/harmony-one/harmony/api/proto" + nodeconfig "github.com/harmony-one/harmony/internal/configs/node" ) // PublicHarmonyAPI provides an API to access Harmony related information. @@ -41,3 +42,18 @@ func (s *PublicHarmonyAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { // TODO(ricl): add SuggestPrice API return (*hexutil.Big)(big.NewInt(1)), nil } + +type NodeMetadata struct { + BLSPublicKey string `json:"blskey"` + Version string `json:"version"` + NetworkType string `json:"network"` +} + +func (s *PublicHarmonyAPI) GetNodeMetadata() NodeMetadata { + cfg := nodeconfig.GetDefaultConfig() + return NodeMetadata{ + cfg.ConsensusPubKey.SerializeToHexStr(), + nodeconfig.GetVersion(), + string(cfg.GetNetworkType()), + } +}