OSDN Git Service

add xpub (#272)
authorChengcheng Zhang <943420582@qq.com>
Fri, 12 Jul 2019 10:30:47 +0000 (18:30 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 12 Jul 2019 10:30:47 +0000 (18:30 +0800)
* update

* update

* update

api/nodeinfo.go

index b00c8fd..591f7af 100644 (file)
@@ -4,6 +4,7 @@ import (
        "context"
        "net"
 
+       cfg "github.com/vapor/config"
        "github.com/vapor/errors"
        "github.com/vapor/netsync/peers"
        "github.com/vapor/p2p"
@@ -21,6 +22,7 @@ type NetInfo struct {
        Listening    bool         `json:"listening"`
        Syncing      bool         `json:"syncing"`
        Mining       bool         `json:"mining"`
+       NodeXPub     string       `json:"node_xpub"`
        PeerCount    int          `json:"peer_count"`
        CurrentBlock uint64       `json:"current_block"`
        HighestBlock uint64       `json:"highest_block"`
@@ -30,10 +32,12 @@ type NetInfo struct {
 
 // GetNodeInfo return net information
 func (a *API) GetNodeInfo() *NetInfo {
+       nodeXPub := cfg.CommonConfig.PrivateKey().XPub()
        info := &NetInfo{
                Listening:    a.sync.IsListening(),
                Syncing:      !a.sync.IsCaughtUp(),
                Mining:       a.blockProposer.IsProposing(),
+               NodeXPub:     nodeXPub.String(),
                PeerCount:    a.sync.PeerCount(),
                CurrentBlock: a.chain.BestBlockHeight(),
                NetWorkID:    a.sync.GetNetwork(),