From 5c751ec1dfd210c33db6e39cdc989149fe6787e6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 27 Oct 2016 19:19:16 -0700 Subject: [PATCH] lnwire: add a field to indicate bitcoin net to NetAddress --- lnwire/netaddress.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lnwire/netaddress.go b/lnwire/netaddress.go index 8d49237af..c22f1a1e5 100644 --- a/lnwire/netaddress.go +++ b/lnwire/netaddress.go @@ -1,9 +1,11 @@ package lnwire import ( + "fmt" "net" "github.com/roasbeef/btcd/btcec" + "github.com/roasbeef/btcd/wire" ) // ServiceFlag identifies the services supported by a particular Lightning @@ -30,4 +32,17 @@ type NetAddress struct { // Address is is the IP address and port of the node. Address *net.TCPAddr + + // ChainNet is the Bitcoin network this node is associated with. + // TODO(roasbeef): make a slice in the future for multi-chain + ChainNet wire.BitcoinNet +} + +// String returns a human readable string describing the target NetAddress. The +// current string format is: @host. +func (n *NetAddress) String() string { + // TODO(roasbeef): use base58? + pubkey := n.IdentityKey.SerializeCompressed() + + return fmt.Sprintf("%x@%v", pubkey, n.Address) }