diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index b6e3b103..183cc017 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -164,6 +164,7 @@ type GetPeerInfoResult struct { Addr string `json:"addr"` AddrLocal string `json:"addrlocal,omitempty"` Services string `json:"services"` + RelayTxes bool `json:"relaytxes"` LastSend int64 `json:"lastsend"` LastRecv int64 `json:"lastrecv"` BytesSent uint64 `json:"bytessent"` diff --git a/peer/peer.go b/peer/peer.go index 50ff1020..fbb011cc 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -683,6 +683,17 @@ func (p *Peer) LastRecv() time.Time { return time.Unix(atomic.LoadInt64(&p.lastRecv), 0) } +// LocalAddr returns the local address of the connection. +// +// This function is safe fo concurrent access. +func (p *Peer) LocalAddr() net.Addr { + var localAddr net.Addr + if p.Connected() { + localAddr = p.conn.LocalAddr() + } + return localAddr +} + // BytesSent returns the total number of bytes sent by the peer. // // This function is safe for concurrent access. diff --git a/rpcserver.go b/rpcserver.go index c1b20e50..44ab3170 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2203,7 +2203,9 @@ func handleGetPeerInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) info := &btcjson.GetPeerInfoResult{ ID: statsSnap.ID, Addr: statsSnap.Addr, + AddrLocal: p.LocalAddr().String(), Services: fmt.Sprintf("%08d", uint64(statsSnap.Services)), + RelayTxes: !p.disableRelayTx, LastSend: statsSnap.LastSend.Unix(), LastRecv: statsSnap.LastRecv.Unix(), BytesSent: statsSnap.BytesSent, diff --git a/rpcserverhelp.go b/rpcserverhelp.go index ad430eb7..727bc0e5 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -376,6 +376,7 @@ var helpDescsEnUS = map[string]string{ "getpeerinforesult-addr": "The ip address and port of the peer", "getpeerinforesult-addrlocal": "Local address", "getpeerinforesult-services": "Services bitmask which represents the services supported by the peer", + "getpeerinforesult-relaytxes": "Peer has requested transactions be relayed to it", "getpeerinforesult-lastsend": "Time the last message was received in seconds since 1 Jan 1970 GMT", "getpeerinforesult-lastrecv": "Time the last message was sent in seconds since 1 Jan 1970 GMT", "getpeerinforesult-bytessent": "Total bytes sent",