diff --git a/discovery/gossiper.go b/discovery/gossiper.go index bebc19760..50dd3a57a 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -244,11 +244,11 @@ type Config struct { // FetchSelfAnnouncement retrieves our current node announcement, for // use when determining whether we should update our peers about our // presence in the network. - FetchSelfAnnouncement func() lnwire.NodeAnnouncement + FetchSelfAnnouncement func() lnwire.NodeAnnouncement1 // UpdateSelfAnnouncement produces a new announcement for our node with // an updated timestamp which can be broadcast to our peers. - UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement, error) + UpdateSelfAnnouncement func() (lnwire.NodeAnnouncement1, error) // ProofMatureDelta the number of confirmations which is needed before // exchange the channel announcement proofs. @@ -1186,7 +1186,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) { // Node announcements are identified by the Vertex field. Use the // NodeID to create the corresponding Vertex. - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: sender := route.NewVertex(message.source) deDupKey := route.Vertex(msg.NodeID) @@ -1195,7 +1195,8 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) { oldTimestamp := uint32(0) mws, ok := d.nodeAnnouncements[deDupKey] if ok { - oldTimestamp = mws.msg.(*lnwire.NodeAnnouncement).Timestamp + ann, _ := mws.msg.(*lnwire.NodeAnnouncement1) + oldTimestamp = ann.Timestamp } // Discard the message if it's old. @@ -1806,7 +1807,7 @@ func (d *AuthenticatedGossiper) retransmitStaleAnns(ctx context.Context, return nil } - // We'll also check that our NodeAnnouncement is not too old. + // We'll also check that our NodeAnnouncement1 is not too old. currentNodeAnn := d.cfg.FetchSelfAnnouncement() timestamp := time.Unix(int64(currentNodeAnn.Timestamp), 0) timeElapsed := now.Sub(timestamp) @@ -2062,7 +2063,7 @@ func (d *AuthenticatedGossiper) fetchPKScript(chanID lnwire.ShortChannelID) ( // addNode processes the given node announcement, and adds it to our channel // graph. func (d *AuthenticatedGossiper) addNode(ctx context.Context, - msg *lnwire.NodeAnnouncement, op ...batch.SchedulerOption) error { + msg *lnwire.NodeAnnouncement1, op ...batch.SchedulerOption) error { if err := netann.ValidateNodeAnn(msg); err != nil { return fmt.Errorf("unable to validate node announcement: %w", @@ -2153,7 +2154,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(ctx context.Context, // A new node announcement has arrived which either presents new // information about a node in one of the channels we know about, or a // updating previously advertised information. - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: return d.handleNodeAnnouncement(ctx, nMsg, msg, schedulerOp) // A new channel announcement has arrived, this indicates the @@ -2248,7 +2249,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context, // announcement fields and returns an error if they are invalid to prevent // forwarding invalid node announcements to our peers. func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context, - pubKey [33]byte) (*lnwire.NodeAnnouncement, error) { + pubKey [33]byte) (*lnwire.NodeAnnouncement1, error) { node, err := d.cfg.Graph.FetchNode(ctx, pubKey) if err != nil { @@ -2478,12 +2479,12 @@ func (d *AuthenticatedGossiper) latestHeight() uint32 { // handleNodeAnnouncement processes a new node announcement. func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context, - nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement, + nMsg *networkMsg, nodeAnn *lnwire.NodeAnnouncement1, ops []batch.SchedulerOption) ([]networkMsg, bool) { timestamp := time.Unix(int64(nodeAnn.Timestamp), 0) - log.Debugf("Processing NodeAnnouncement: peer=%v, timestamp=%v, "+ + log.Debugf("Processing NodeAnnouncement1: peer=%v, timestamp=%v, "+ "node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID, nMsg.source.SerializeCompressed()) @@ -2542,7 +2543,7 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(ctx context.Context, nMsg.err <- nil // TODO(roasbeef): get rid of the above - log.Debugf("Processed NodeAnnouncement: peer=%v, timestamp=%v, "+ + log.Debugf("Processed NodeAnnouncement1: peer=%v, timestamp=%v, "+ "node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID, nMsg.source.SerializeCompressed()) diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 63369f4d6..521e08963 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -493,8 +493,8 @@ func (m *mockNotifier) Stop() error { } type annBatch struct { - nodeAnn1 *lnwire.NodeAnnouncement - nodeAnn2 *lnwire.NodeAnnouncement + nodeAnn1 *lnwire.NodeAnnouncement1 + nodeAnn2 *lnwire.NodeAnnouncement1 chanAnn *lnwire.ChannelAnnouncement1 @@ -577,8 +577,8 @@ func (ctx *testCtx) createAnnouncements(blockHeight uint32, key1, } -func createNodeAnnouncement(priv *btcec.PrivateKey, - timestamp uint32, extraBytes ...[]byte) (*lnwire.NodeAnnouncement, error) { +func createNodeAnnouncement(priv *btcec.PrivateKey, timestamp uint32, + extraBytes ...[]byte) (*lnwire.NodeAnnouncement1, error) { var err error k := hex.EncodeToString(priv.Serialize()) @@ -587,7 +587,7 @@ func createNodeAnnouncement(priv *btcec.PrivateKey, return nil, err } - a := &lnwire.NodeAnnouncement{ + a := &lnwire.NodeAnnouncement1{ Timestamp: timestamp, Addresses: testAddrs, Alias: alias, @@ -966,15 +966,15 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) ( c := make(chan struct{}) return c }, - FetchSelfAnnouncement: func() lnwire.NodeAnnouncement { - return lnwire.NodeAnnouncement{ + FetchSelfAnnouncement: func() lnwire.NodeAnnouncement1 { + return lnwire.NodeAnnouncement1{ Timestamp: testTimestamp, } }, - UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement, + UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement1, error) { - return lnwire.NodeAnnouncement{ + return lnwire.NodeAnnouncement1{ Timestamp: testTimestamp, }, nil }, @@ -2285,7 +2285,7 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) { case <-time.After(2 * trickleDelay): } - // Now, we'll attempt to forward the NodeAnnouncement for the same node + // Now, we'll attempt to forward the NodeAnnouncement1 for the same node // by opening a public channel on the network. We'll create a // ChannelAnnouncement and hand it off to the gossiper in order to // process it. @@ -2312,8 +2312,9 @@ func TestForwardPrivateNodeAnnouncement(t *testing.T) { t.Fatal("gossiper should have broadcast the channel announcement") } - // We'll recreate the NodeAnnouncement with an updated timestamp to - // prevent a stale update. The NodeAnnouncement should now be forwarded. + // We'll recreate the NodeAnnouncement1 with an updated timestamp to + // prevent a stale update. The NodeAnnouncement1 should now be + // forwarded. nodeAnn, err = createNodeAnnouncement(remoteKeyPriv1, timestamp+1) require.NoError(t, err, "unable to create node announcement") @@ -2897,7 +2898,7 @@ func TestExtraDataChannelUpdateValidation(t *testing.T) { } // TestExtraDataNodeAnnouncementValidation tests that we're able to properly -// validate a NodeAnnouncement that includes opaque bytes that we don't +// validate a NodeAnnouncement1 that includes opaque bytes that we don't // currently know of. func TestExtraDataNodeAnnouncementValidation(t *testing.T) { t.Parallel() @@ -3044,7 +3045,7 @@ func TestRetransmit(t *testing.T) { chanAnn++ case *lnwire.ChannelUpdate1: chanUpd++ - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: nodeAnn++ } } diff --git a/discovery/syncer.go b/discovery/syncer.go index b8c51a9a5..1f120b3f8 100644 --- a/discovery/syncer.go +++ b/discovery/syncer.go @@ -1653,7 +1653,7 @@ func (g *GossipSyncer) FilterGossipMsgs(ctx context.Context, // Similarly, we only send node announcements if the update // timestamp ifs between our set gossip filter time range. - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: if passesFilter(msg.Timestamp) { msgsToSend = append(msgsToSend, msg) } diff --git a/discovery/syncer_test.go b/discovery/syncer_test.go index faef40bbe..4420f4aa4 100644 --- a/discovery/syncer_test.go +++ b/discovery/syncer_test.go @@ -249,10 +249,14 @@ func TestGossipSyncerFilterGossipMsgsNoHorizon(t *testing.T) { // through the gossiper to the target peer. msgs := []msgWithSenders{ { - msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())}, + msg: &lnwire.NodeAnnouncement1{ + Timestamp: uint32(time.Now().Unix()), + }, }, { - msg: &lnwire.NodeAnnouncement{Timestamp: uint32(time.Now().Unix())}, + msg: &lnwire.NodeAnnouncement1{ + Timestamp: uint32(time.Now().Unix()), + }, }, } @@ -308,15 +312,21 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) { msgs := []msgWithSenders{ { // Node ann above horizon. - msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)}, + msg: &lnwire.NodeAnnouncement1{ + Timestamp: unixStamp(25001), + }, }, { // Node ann below horizon. - msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(5)}, + msg: &lnwire.NodeAnnouncement1{ + Timestamp: unixStamp(5), + }, }, { // Node ann above horizon. - msg: &lnwire.NodeAnnouncement{Timestamp: unixStamp(999999)}, + msg: &lnwire.NodeAnnouncement1{ + Timestamp: unixStamp(999999), + }, }, { // Ann tuple below horizon. @@ -737,7 +747,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) { ShortChannelID: lnwire.NewShortChanIDFromInt(20), Timestamp: unixStamp(999999), }, - &lnwire.NodeAnnouncement{Timestamp: unixStamp(25001)}, + &lnwire.NodeAnnouncement1{Timestamp: unixStamp(25001)}, } // We'll then craft a reply to the upcoming query for all the matching diff --git a/discovery/validation_barrier.go b/discovery/validation_barrier.go index 7153dd49e..ebd3fccef 100644 --- a/discovery/validation_barrier.go +++ b/discovery/validation_barrier.go @@ -188,7 +188,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) (JobID, populateDependencies(msg.ShortChannelID.String(), childJobID) return childJobID, nil - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: childJobID := JobID(v.idCtr.Add(1)) populateDependencies( route.Vertex(msg.NodeID).String(), childJobID, @@ -242,7 +242,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID, v.Lock() switch msg := job.(type) { - // Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the + // Any ChannelUpdate or NodeAnnouncement1 jobs will need to wait on the // completion of any active ChannelAnnouncement jobs related to them. case *lnwire.ChannelUpdate1: annID = msg.ShortChannelID.String() @@ -258,7 +258,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID, jobDesc = fmt.Sprintf("job=lnwire.ChannelUpdate, scid=%v", msg.ShortChannelID.ToUint64()) - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: annID = route.Vertex(msg.NodeID).String() parentJobIDs, ok = v.jobDependencies[childJobID] @@ -269,7 +269,7 @@ func (v *ValidationBarrier) WaitForParents(childJobID JobID, return nil } - jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement, pub=%s", + jobDesc = fmt.Sprintf("job=lnwire.NodeAnnouncement1, pub=%s", route.Vertex(msg.NodeID)) // Other types of jobs can be executed immediately, so we'll just @@ -446,7 +446,7 @@ func (v *ValidationBarrier) SignalDependents(job interface{}, id JobID) error { return nil - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: // Remove child job info. return removeJob(route.Vertex(msg.NodeID).String(), id, true) diff --git a/discovery/validation_barrier_test.go b/discovery/validation_barrier_test.go index bc58fe9ec..ee4d2e926 100644 --- a/discovery/validation_barrier_test.go +++ b/discovery/validation_barrier_test.go @@ -186,7 +186,7 @@ func TestValidationBarrierQuit(t *testing.T) { } // TestValidationBarrierParentJobsClear tests that creating two parent jobs for -// ChannelUpdate / NodeAnnouncement will pause child jobs until the set of +// ChannelUpdate / NodeAnnouncement1 will pause child jobs until the set of // parent jobs has cleared. func TestValidationBarrierParentJobsClear(t *testing.T) { t.Parallel() @@ -230,14 +230,14 @@ func TestValidationBarrierParentJobsClear(t *testing.T) { parentID3, err := barrier.InitJobDependencies(ann3) require.NoError(t, err) - // Create the ChannelUpdate & NodeAnnouncement messages. + // Create the ChannelUpdate & NodeAnnouncement1 messages. upd1 := &lnwire.ChannelUpdate1{ ShortChannelID: sharedScid, } childID1, err := barrier.InitJobDependencies(upd1) require.NoError(t, err) - node1 := &lnwire.NodeAnnouncement{ + node1 := &lnwire.NodeAnnouncement1{ NodeID: sharedNodeID, } childID2, err := barrier.InitJobDependencies(node1) diff --git a/funding/manager.go b/funding/manager.go index 4bfb7f9d0..8176e6aa2 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -398,7 +398,7 @@ type Config struct { // CurrentNodeAnnouncement should return the latest, fully signed node // announcement from the backing Lightning Network node with a fresh // timestamp. - CurrentNodeAnnouncement func() (lnwire.NodeAnnouncement, error) + CurrentNodeAnnouncement func() (lnwire.NodeAnnouncement1, error) // SendAnnouncement is used by the FundingManager to send announcement // messages to the Gossiper to possibly broadcast to the greater @@ -3757,8 +3757,8 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel, shortChanID *lnwire.ShortChannelID) error { // If this channel is not meant to be announced to the greater network, - // we'll only send our NodeAnnouncement to our counterparty to ensure we - // don't leak any of our information. + // we'll only send our NodeAnnouncement1 to our counterparty to ensure + // we don't leak any of our information. announceChan := completeChan.ChannelFlags&lnwire.FFAnnounceChannel != 0 if !announceChan { log.Debugf("Will not announce private channel %v.", @@ -3779,7 +3779,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel, completeChan.FundingOutpoint, ) pubKey := peer.PubKey() - log.Debugf("Sending our NodeAnnouncement for "+ + log.Debugf("Sending our NodeAnnouncement1 for "+ "ChannelID(%v) to %x", chanID, pubKey) // TODO(halseth): make reliable. If the peer is not online this @@ -4724,7 +4724,7 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey, graph.ErrIgnored) { log.Debugf("Graph rejected "+ - "NodeAnnouncement: %v", err) + "NodeAnnouncement1: %v", err) } else { log.Errorf("Unable to send node "+ "announcement: %v", err) diff --git a/funding/manager_test.go b/funding/manager_test.go index 57d9299d2..45b847ffd 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -485,10 +485,10 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey, } return errChan }, - CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, + CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement1, error) { - return lnwire.NodeAnnouncement{}, nil + return lnwire.NodeAnnouncement1{}, nil }, TempChanIDSeed: chanIDSeed, FindChannel: func(node *btcec.PublicKey, @@ -660,10 +660,10 @@ func recreateAliceFundingManager(t *testing.T, alice *testNode) { } return errChan }, - CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, + CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement1, error) { - return lnwire.NodeAnnouncement{}, nil + return lnwire.NodeAnnouncement1{}, nil }, NotifyWhenOnline: func(peer [33]byte, connectedChan chan<- lnpeer.Peer) { @@ -1328,9 +1328,9 @@ func assertAnnouncementSignatures(t *testing.T, alice, bob *testNode) { // by having the nodes exchange announcement signatures. // Two distinct messages will be sent: // 1) AnnouncementSignatures - // 2) NodeAnnouncement + // 2) NodeAnnouncement1 // These may arrive in no particular order. - // Note that sending the NodeAnnouncement at this point is an + // Note that sending the NodeAnnouncement1 at this point is an // implementation detail, and not something required by the LN spec. for j, node := range []*testNode{alice, bob} { announcements := make([]lnwire.Message, 2) @@ -1348,7 +1348,7 @@ func assertAnnouncementSignatures(t *testing.T, alice, bob *testNode) { switch msg.(type) { case *lnwire.AnnounceSignatures1: gotAnnounceSignatures = true - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: gotNodeAnnouncement = true } } @@ -1358,7 +1358,8 @@ func assertAnnouncementSignatures(t *testing.T, alice, bob *testNode) { j) } if !gotNodeAnnouncement { - t.Fatalf("did not get NodeAnnouncement from node %d", j) + t.Fatalf("did not get NodeAnnouncement1 from node %d", + j) } } } @@ -1378,7 +1379,7 @@ func assertNodeAnnSent(t *testing.T, alice, bob *testNode) { node.msgChan, time.Second*5, ) require.NoError(t, err) - assertType[*lnwire.NodeAnnouncement](t, *nodeAnn) + assertType[*lnwire.NodeAnnouncement1](t, *nodeAnn) } } @@ -2959,7 +2960,7 @@ func TestFundingManagerPrivateChannel(t *testing.T) { // We should however receive each side's node announcement. select { case msg := <-alice.msgChan: - if _, ok := msg.(*lnwire.NodeAnnouncement); !ok { + if _, ok := msg.(*lnwire.NodeAnnouncement1); !ok { t.Fatalf("expected to receive node announcement") } case <-time.After(time.Second): @@ -2968,7 +2969,7 @@ func TestFundingManagerPrivateChannel(t *testing.T) { select { case msg := <-bob.msgChan: - if _, ok := msg.(*lnwire.NodeAnnouncement); !ok { + if _, ok := msg.(*lnwire.NodeAnnouncement1); !ok { t.Fatalf("expected to receive node announcement") } case <-time.After(time.Second): @@ -3085,7 +3086,7 @@ func TestFundingManagerPrivateRestart(t *testing.T) { // We should however receive each side's node announcement. select { case msg := <-alice.msgChan: - if _, ok := msg.(*lnwire.NodeAnnouncement); !ok { + if _, ok := msg.(*lnwire.NodeAnnouncement1); !ok { t.Fatalf("expected to receive node announcement") } case <-time.After(time.Second): @@ -3094,7 +3095,7 @@ func TestFundingManagerPrivateRestart(t *testing.T) { select { case msg := <-bob.msgChan: - if _, ok := msg.(*lnwire.NodeAnnouncement); !ok { + if _, ok := msg.(*lnwire.NodeAnnouncement1); !ok { t.Fatalf("expected to receive node announcement") } case <-time.After(time.Second): diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 774492786..482c1aa18 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -4754,10 +4754,10 @@ func TestLightningNodePersistence(t *testing.T) { require.NoError(t, err) // Use the raw serialized node announcement message create an - // lnwire.NodeAnnouncement instance. + // lnwire.NodeAnnouncement1 instance. msg, err := lnwire.ReadMessage(bytes.NewBuffer(nodeAnnBytes), 0) require.NoError(t, err) - na, ok := msg.(*lnwire.NodeAnnouncement) + na, ok := msg.(*lnwire.NodeAnnouncement1) require.True(t, ok) // Convert the wire message to our internal node representation. diff --git a/graph/db/models/node.go b/graph/db/models/node.go index ba4437c0a..23d6a4268 100644 --- a/graph/db/models/node.go +++ b/graph/db/models/node.go @@ -96,7 +96,7 @@ func (l *Node) AddPubKey(key *btcec.PublicKey) { } // NodeAnnouncement retrieves the latest node announcement of the node. -func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, +func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement1, error) { if !l.HaveNodeAnnouncement { @@ -108,7 +108,7 @@ func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, return nil, err } - nodeAnn := &lnwire.NodeAnnouncement{ + nodeAnn := &lnwire.NodeAnnouncement1{ Features: l.Features.RawFeatureVector, NodeID: l.PubKeyBytes, RGBColor: l.Color, @@ -133,8 +133,8 @@ func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement, } // NodeFromWireAnnouncement creates a Node instance from an -// lnwire.NodeAnnouncement message. -func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *Node { +// lnwire.NodeAnnouncement1 message. +func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement1) *Node { timestamp := time.Unix(int64(msg.Timestamp), 0) features := lnwire.NewFeatureVector(msg.Features, lnwire.Features) diff --git a/lnrpc/peersrpc/config_active.go b/lnrpc/peersrpc/config_active.go index 6b9ef6d26..fec8affda 100644 --- a/lnrpc/peersrpc/config_active.go +++ b/lnrpc/peersrpc/config_active.go @@ -19,7 +19,7 @@ import ( type Config struct { // GetNodeAnnouncement is used to send our retrieve the current // node announcement information. - GetNodeAnnouncement func() lnwire.NodeAnnouncement + GetNodeAnnouncement func() lnwire.NodeAnnouncement1 // ParseAddr parses an address from its string format to a net.Addr. ParseAddr func(addr string) (net.Addr, error) diff --git a/lnwire/fuzz_test.go b/lnwire/fuzz_test.go index 054af585c..c3cd8198e 100644 --- a/lnwire/fuzz_test.go +++ b/lnwire/fuzz_test.go @@ -220,10 +220,10 @@ func FuzzNodeAnnouncement(f *testing.F) { // can be represented by different underlying bytes. Instead, we // compare the normalized string representation of each address. assertEq := func(t *testing.T, x, y any) { - require.IsType(t, &NodeAnnouncement{}, x) - first, _ := x.(*NodeAnnouncement) - require.IsType(t, &NodeAnnouncement{}, y) - second, _ := y.(*NodeAnnouncement) + require.IsType(t, &NodeAnnouncement1{}, x) + first, _ := x.(*NodeAnnouncement1) + require.IsType(t, &NodeAnnouncement1{}, y) + second, _ := y.(*NodeAnnouncement1) require.Equal( t, len(first.Addresses), len(second.Addresses), diff --git a/lnwire/message.go b/lnwire/message.go index a36359f0b..9584bfc44 100644 --- a/lnwire/message.go +++ b/lnwire/message.go @@ -166,7 +166,7 @@ func (t MessageType) String() string { case MsgChannelUpdate: return "ChannelUpdate" case MsgNodeAnnouncement: - return "NodeAnnouncement" + return "NodeAnnouncement1" case MsgPing: return "Ping" case MsgAnnounceSignatures: @@ -330,7 +330,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) { case MsgChannelUpdate: msg = &ChannelUpdate1{} case MsgNodeAnnouncement: - msg = &NodeAnnouncement{} + msg = &NodeAnnouncement1{} case MsgPing: msg = &Ping{} case MsgAnnounceSignatures: diff --git a/lnwire/message_test.go b/lnwire/message_test.go index 4f95cb0ef..f1232e85f 100644 --- a/lnwire/message_test.go +++ b/lnwire/message_test.go @@ -670,11 +670,11 @@ func newMsgChannelAnnouncement(t testing.TB, } func newMsgNodeAnnouncement(t testing.TB, - r *rand.Rand) *lnwire.NodeAnnouncement { + r *rand.Rand) *lnwire.NodeAnnouncement1 { t.Helper() - msg := &lnwire.NodeAnnouncement{ + msg := &lnwire.NodeAnnouncement1{ Features: rawFeatureVector(), Timestamp: uint32(r.Int31()), Alias: randAlias(r), diff --git a/lnwire/node_announcement.go b/lnwire/node_announcement.go index d3502a7d9..0a7c60542 100644 --- a/lnwire/node_announcement.go +++ b/lnwire/node_announcement.go @@ -62,11 +62,11 @@ func (n NodeAlias) String() string { return string(bytes.Trim(n[:], "\x00")) } -// NodeAnnouncement message is used to announce the presence of a Lightning +// NodeAnnouncement1 message is used to announce the presence of a Lightning // node and also to signal that the node is accepting incoming connections. -// Each NodeAnnouncement authenticating the advertised information within the +// Each NodeAnnouncement1 authenticating the advertised information within the // announcement via a signature using the advertised node pubkey. -type NodeAnnouncement struct { +type NodeAnnouncement1 struct { // Signature is used to prove the ownership of node id. Signature Sig @@ -100,19 +100,19 @@ type NodeAnnouncement struct { ExtraOpaqueData ExtraOpaqueData } -// A compile time check to ensure NodeAnnouncement implements the +// A compile time check to ensure NodeAnnouncement1 implements the // lnwire.Message interface. -var _ Message = (*NodeAnnouncement)(nil) +var _ Message = (*NodeAnnouncement1)(nil) -// A compile time check to ensure NodeAnnouncement implements the +// A compile time check to ensure NodeAnnouncement1 implements the // lnwire.SizeableMessage interface. -var _ SizeableMessage = (*NodeAnnouncement)(nil) +var _ SizeableMessage = (*NodeAnnouncement1)(nil) -// Decode deserializes a serialized NodeAnnouncement stored in the passed +// Decode deserializes a serialized NodeAnnouncement1 stored in the passed // io.Reader observing the specified protocol version. // // This is part of the lnwire.Message interface. -func (a *NodeAnnouncement) Decode(r io.Reader, _ uint32) error { +func (a *NodeAnnouncement1) Decode(r io.Reader, _ uint32) error { err := ReadElements(r, &a.Signature, &a.Features, @@ -130,11 +130,11 @@ func (a *NodeAnnouncement) Decode(r io.Reader, _ uint32) error { return a.ExtraOpaqueData.ValidateTLV() } -// Encode serializes the target NodeAnnouncement into the passed io.Writer +// Encode serializes the target NodeAnnouncement1 into the passed io.Writer // observing the protocol version specified. // // This is part of the lnwire.Message interface. -func (a *NodeAnnouncement) Encode(w *bytes.Buffer, pver uint32) error { +func (a *NodeAnnouncement1) Encode(w *bytes.Buffer, pver uint32) error { if err := WriteSig(w, a.Signature); err != nil { return err } @@ -170,13 +170,12 @@ func (a *NodeAnnouncement) Encode(w *bytes.Buffer, pver uint32) error { // wire. // // This is part of the lnwire.Message interface. -func (a *NodeAnnouncement) MsgType() MessageType { +func (a *NodeAnnouncement1) MsgType() MessageType { return MsgNodeAnnouncement } // DataToSign returns the part of the message that should be signed. -func (a *NodeAnnouncement) DataToSign() ([]byte, error) { - +func (a *NodeAnnouncement1) DataToSign() ([]byte, error) { // We should not include the signatures itself. buffer := make([]byte, 0, MaxMsgBody) buf := bytes.NewBuffer(buffer) @@ -215,6 +214,6 @@ func (a *NodeAnnouncement) DataToSign() ([]byte, error) { // SerializedSize returns the serialized size of the message in bytes. // // This is part of the lnwire.SizeableMessage interface. -func (a *NodeAnnouncement) SerializedSize() (uint32, error) { +func (a *NodeAnnouncement1) SerializedSize() (uint32, error) { return MessageSerializedSize(a) } diff --git a/lnwire/test_message.go b/lnwire/test_message.go index 6fb6725a0..dc55ef5c1 100644 --- a/lnwire/test_message.go +++ b/lnwire/test_message.go @@ -1215,15 +1215,15 @@ func (ks *KickoffSig) RandTestMessage(t *rapid.T) Message { } } -// A compile time check to ensure NodeAnnouncement implements the +// A compile time check to ensure NodeAnnouncement1 implements the // lnwire.TestMessage interface. -var _ TestMessage = (*NodeAnnouncement)(nil) +var _ TestMessage = (*NodeAnnouncement1)(nil) // RandTestMessage populates the message with random data suitable for testing. // It uses the rapid testing framework to generate random values. // // This is part of the TestMessage interface. -func (a *NodeAnnouncement) RandTestMessage(t *rapid.T) Message { +func (a *NodeAnnouncement1) RandTestMessage(t *rapid.T) Message { // Generate random compressed public key for node ID pubKey := RandPubKey(t) var nodeID [33]byte @@ -1236,7 +1236,7 @@ func (a *NodeAnnouncement) RandTestMessage(t *rapid.T) Message { B: uint8(rapid.IntRange(0, 255).Draw(t, "rgbB")), } - return &NodeAnnouncement{ + return &NodeAnnouncement1{ Signature: RandSignature(t), Features: RandFeatureVector(t), Timestamp: uint32(rapid.IntRange(0, 0x7FFFFFFF).Draw( diff --git a/netann/host_ann.go b/netann/host_ann.go index 95ba277b5..9612f1ccb 100644 --- a/netann/host_ann.go +++ b/netann/host_ann.go @@ -22,8 +22,8 @@ type HostAnnouncerConfig struct { LookupHost func(string) (net.Addr, error) // AdvertisedIPs is the set of IPs that we've already announced with - // our current NodeAnnouncement. This set will be constructed to avoid - // unnecessary node NodeAnnouncement updates. + // our current NodeAnnouncement1. This set will be constructed to avoid + // unnecessary node NodeAnnouncement1 updates. AdvertisedIPs map[string]struct{} // AnnounceNewIPs announces a new set of IP addresses for the backing @@ -36,7 +36,7 @@ type HostAnnouncerConfig struct { // HostAnnouncer is a sub-system that allows a user to specify a set of hosts // for lnd that will be continually resolved to notice any IP address changes. // If the target IP address for a host changes, then we'll generate a new -// NodeAnnouncement that includes these new IPs. +// NodeAnnouncement1 that includes these new IPs. type HostAnnouncer struct { cfg HostAnnouncerConfig @@ -171,7 +171,7 @@ func (h *HostAnnouncer) hostWatcher() { // announcement on disk. It returns the updated node announcement given a set // of updates to be applied to the current node announcement. type NodeAnnUpdater func(modifier ...NodeAnnModifier, -) (lnwire.NodeAnnouncement, error) +) (lnwire.NodeAnnouncement1, error) // IPAnnouncer is a factory function that generates a new function that uses // the passed annUpdater function to to announce new IP changes for a given @@ -181,7 +181,7 @@ func IPAnnouncer(annUpdater NodeAnnUpdater) func([]net.Addr, return func(newAddrs []net.Addr, oldAddrs map[string]struct{}) error { _, err := annUpdater(func( - currentNodeAnn *lnwire.NodeAnnouncement) { + currentNodeAnn *lnwire.NodeAnnouncement1) { // To ensure we don't duplicate any addresses, we'll // filter out the same of addresses we should no longer // advertise. diff --git a/netann/node_announcement.go b/netann/node_announcement.go index 893e9fc4a..b2d288bf7 100644 --- a/netann/node_announcement.go +++ b/netann/node_announcement.go @@ -16,37 +16,39 @@ import ( ) // NodeAnnModifier is a closure that makes in-place modifications to an -// lnwire.NodeAnnouncement. -type NodeAnnModifier func(*lnwire.NodeAnnouncement) +// lnwire.NodeAnnouncement1. +type NodeAnnModifier func(*lnwire.NodeAnnouncement1) // NodeAnnSetAlias is a functional option that sets the alias of the // given node announcement. -func NodeAnnSetAlias(alias lnwire.NodeAlias) func(*lnwire.NodeAnnouncement) { - return func(nodeAnn *lnwire.NodeAnnouncement) { +func NodeAnnSetAlias(alias lnwire.NodeAlias) func(*lnwire.NodeAnnouncement1) { + return func(nodeAnn *lnwire.NodeAnnouncement1) { nodeAnn.Alias = alias } } // NodeAnnSetAddrs is a functional option that allows updating the addresses of // the given node announcement. -func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement) { - return func(nodeAnn *lnwire.NodeAnnouncement) { +func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement1) { + return func(nodeAnn *lnwire.NodeAnnouncement1) { nodeAnn.Addresses = addrs } } // NodeAnnSetColor is a functional option that sets the color of the // given node announcement. -func NodeAnnSetColor(newColor color.RGBA) func(*lnwire.NodeAnnouncement) { - return func(nodeAnn *lnwire.NodeAnnouncement) { +func NodeAnnSetColor(newColor color.RGBA) func(*lnwire.NodeAnnouncement1) { + return func(nodeAnn *lnwire.NodeAnnouncement1) { nodeAnn.RGBColor = newColor } } // NodeAnnSetFeatures is a functional option that allows updating the features of // the given node announcement. -func NodeAnnSetFeatures(features *lnwire.RawFeatureVector) func(*lnwire.NodeAnnouncement) { - return func(nodeAnn *lnwire.NodeAnnouncement) { +func NodeAnnSetFeatures( + features *lnwire.RawFeatureVector) func(*lnwire.NodeAnnouncement1) { + + return func(nodeAnn *lnwire.NodeAnnouncement1) { nodeAnn.Features = features } } @@ -54,7 +56,7 @@ func NodeAnnSetFeatures(features *lnwire.RawFeatureVector) func(*lnwire.NodeAnno // NodeAnnSetTimestamp is a functional option that sets the timestamp of the // announcement to the current time, or increments it if the timestamp is // already in the future. -func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) { +func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement1) { newTimestamp := uint32(time.Now().Unix()) if newTimestamp <= nodeAnn.Timestamp { // Increment the prior value to ensure the timestamp @@ -65,11 +67,11 @@ func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) { nodeAnn.Timestamp = newTimestamp } -// SignNodeAnnouncement signs the lnwire.NodeAnnouncement provided, which +// SignNodeAnnouncement signs the lnwire.NodeAnnouncement1 provided, which // should be the most recent, valid update, otherwise the timestamp may not // monotonically increase from the prior. func SignNodeAnnouncement(signer lnwallet.MessageSigner, - keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement) error { + keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement1) error { // Create the DER-encoded ECDSA signature over the message digest. sig, err := SignAnnouncement(signer, keyLoc, nodeAnn) @@ -83,7 +85,7 @@ func SignNodeAnnouncement(signer lnwallet.MessageSigner, } // ValidateNodeAnn validates the fields and signature of a node announcement. -func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error { +func ValidateNodeAnn(a *lnwire.NodeAnnouncement1) error { err := ValidateNodeAnnFields(a) if err != nil { return fmt.Errorf("invalid node announcement fields: %w", err) @@ -93,7 +95,7 @@ func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error { } // ValidateNodeAnnFields validates the fields of a node announcement. -func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement) error { +func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement1) error { // Check that it only has at most one DNS address. hasDNSAddr := false for _, addr := range a.Addresses { @@ -120,7 +122,7 @@ func ValidateNodeAnnFields(a *lnwire.NodeAnnouncement) error { // ValidateNodeAnnSignature validates the node announcement by ensuring that the // attached signature is needed a signature of the node announcement under the // specified node public key. -func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement) error { +func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement1) error { // Reconstruct the data of announcement which should be covered by the // signature so we can verify the signature shortly below data, err := a.DataToSign() @@ -146,7 +148,7 @@ func ValidateNodeAnnSignature(a *lnwire.NodeAnnouncement) error { return err } - return fmt.Errorf("signature on NodeAnnouncement(%x) is "+ + return fmt.Errorf("signature on NodeAnnouncement1(%x) is "+ "invalid: %x", nodeKey.SerializeCompressed(), msgBuf.Bytes()) } diff --git a/netann/sign.go b/netann/sign.go index 0c7612eac..6d92c123a 100644 --- a/netann/sign.go +++ b/netann/sign.go @@ -24,7 +24,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator, data, err = m.DataToSign() case *lnwire.ChannelUpdate1: data, err = m.DataToSign() - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: data, err = m.DataToSign() default: return nil, fmt.Errorf("can't sign %T message", m) diff --git a/peer/brontide.go b/peer/brontide.go index d1f9ef111..9191cbb2e 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -329,7 +329,7 @@ type Config struct { // GenNodeAnnouncement is used to send our node announcement to the remote // on startup. GenNodeAnnouncement func(...netann.NodeAnnModifier) ( - lnwire.NodeAnnouncement, error) + lnwire.NodeAnnouncement1, error) // PrunePersistentPeerConnection is used to remove all internal state // related to this peer in the server. @@ -2092,7 +2092,7 @@ out: idleTimer.Reset(idleTimeout) continue - // If the NodeAnnouncement has an invalid alias, then + // If the NodeAnnouncement1 has an invalid alias, then // we'll log that error above and continue so we can // continue to read messages from the peer. We do not // store this error because it is of little debugging @@ -2213,7 +2213,7 @@ out: case *lnwire.ChannelUpdate1, *lnwire.ChannelAnnouncement1, - *lnwire.NodeAnnouncement, + *lnwire.NodeAnnouncement1, *lnwire.AnnounceSignatures1, *lnwire.GossipTimestampRange, *lnwire.QueryShortChanIDs, @@ -2494,7 +2494,7 @@ func messageSummary(msg lnwire.Message) string { msg.ShortChannelID.ToUint64(), msg.MessageFlags, msg.ChannelFlags, time.Unix(int64(msg.Timestamp), 0)) - case *lnwire.NodeAnnouncement: + case *lnwire.NodeAnnouncement1: return fmt.Sprintf("node=%x, update_time=%v", msg.NodeID, time.Unix(int64(msg.Timestamp), 0)) diff --git a/server.go b/server.go index a48405e5c..a2d36eb86 100644 --- a/server.go +++ b/server.go @@ -400,7 +400,7 @@ type server struct { // currentNodeAnn is the node announcement that has been broadcast to // the network upon startup, if the attributes of the node (us) has // changed since last start. - currentNodeAnn *lnwire.NodeAnnouncement + currentNodeAnn *lnwire.NodeAnnouncement1 // chansToRestore is the set of channels that upon starting, the server // should attempt to restore/recover. @@ -1069,7 +1069,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr, NotifyWhenOnline: s.NotifyWhenOnline, NotifyWhenOffline: s.NotifyWhenOffline, FetchSelfAnnouncement: s.getNodeAnnouncement, - UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement, + UpdateSelfAnnouncement: func() (lnwire.NodeAnnouncement1, error) { return s.genNodeAnnouncement(nil) @@ -1466,7 +1466,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr, ChannelDB: s.chanStateDB, FeeEstimator: cc.FeeEstimator, SignMessage: cc.MsgSigner.SignMessage, - CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, + CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement1, error) { return s.genNodeAnnouncement(nil) @@ -1796,7 +1796,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr, AdvertisedIPs: advertisedIPs, AnnounceNewIPs: netann.IPAnnouncer( func(modifier ...netann.NodeAnnModifier) ( - lnwire.NodeAnnouncement, error) { + lnwire.NodeAnnouncement1, error) { return s.genNodeAnnouncement( nil, modifier..., @@ -3306,7 +3306,7 @@ func (s *server) createNewHiddenService(ctx context.Context) error { // Now that the onion service has been created, we'll add the onion // address it can be reached at to our list of advertised addresses. newNodeAnn, err := s.genNodeAnnouncement( - nil, func(currentAnn *lnwire.NodeAnnouncement) { + nil, func(currentAnn *lnwire.NodeAnnouncement1) { currentAnn.Addresses = append(currentAnn.Addresses, addr) }, ) @@ -3357,7 +3357,7 @@ func (s *server) findChannel(node *btcec.PublicKey, chanID lnwire.ChannelID) ( } // getNodeAnnouncement fetches the current, fully signed node announcement. -func (s *server) getNodeAnnouncement() lnwire.NodeAnnouncement { +func (s *server) getNodeAnnouncement() lnwire.NodeAnnouncement1 { s.mu.Lock() defer s.mu.Unlock() @@ -3368,7 +3368,7 @@ func (s *server) getNodeAnnouncement() lnwire.NodeAnnouncement { // announcement. The time stamp of the announcement will be updated in order // to ensure it propagates through the network. func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector, - modifiers ...netann.NodeAnnModifier) (lnwire.NodeAnnouncement, error) { + modifiers ...netann.NodeAnnModifier) (lnwire.NodeAnnouncement1, error) { s.mu.Lock() defer s.mu.Unlock() @@ -3386,7 +3386,7 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector, } err := s.featureMgr.UpdateFeatureSets(proposedFeatures) if err != nil { - return lnwire.NodeAnnouncement{}, err + return lnwire.NodeAnnouncement1{}, err } // If we could successfully update our feature manager, add @@ -3411,7 +3411,7 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector, s.nodeSigner, s.identityKeyLoc, &newNodeAnn, ) if err != nil { - return lnwire.NodeAnnouncement{}, err + return lnwire.NodeAnnouncement1{}, err } // If signing succeeds, update the current announcement. @@ -3501,7 +3501,7 @@ func (s *server) establishPersistentConnections(ctx context.Context) error { // After checking our previous connections for addresses to connect to, // iterate through the nodes in our channel graph to find addresses - // that have been added via NodeAnnouncement messages. + // that have been added via NodeAnnouncement1 messages. // TODO(roasbeef): instead iterate over link nodes and query graph for // each of the nodes. graphAddrs := make(map[string]*nodeAddresses) @@ -4394,7 +4394,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq, TowerClient: towerClient, DisconnectPeer: s.DisconnectPeer, GenNodeAnnouncement: func(...netann.NodeAnnModifier) ( - lnwire.NodeAnnouncement, error) { + lnwire.NodeAnnouncement1, error) { return s.genNodeAnnouncement(nil) }, diff --git a/subrpcserver_config.go b/subrpcserver_config.go index 5034fcc40..d55d5a492 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -122,7 +122,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, tcpResolver lncfg.TCPResolver, genInvoiceFeatures func() *lnwire.FeatureVector, genAmpInvoiceFeatures func() *lnwire.FeatureVector, - getNodeAnnouncement func() lnwire.NodeAnnouncement, + getNodeAnnouncement func() lnwire.NodeAnnouncement1, updateNodeAnnouncement func(ctx context.Context, features *lnwire.RawFeatureVector, modifiers ...netann.NodeAnnModifier) error,