From 1124b4556f61c9ee3199e885319a6e775f14e44d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 12 May 2017 14:30:10 -0700 Subject: [PATCH] lnwire: fix serialization order of features+addresses in NodeAnnouncement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a deviant in the way we serialize and deserialize the node announcement message from that which is currently in the spec. Before this commit we reversed the order of features and addresses. Instead, on the wire, features should come _before_ the addresses. We also add a new temporary feature bit to ensure nodes that don’t directly connect to each other if they don’t have this new update. However, this will also partition any current tests nets when new nodes join them as the digest signed has changed, therefore invalidating any older messages. Fixes #207. --- features.go | 4 ++++ lnwire/node_announcement.go | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/features.go b/features.go index b0a4e7d2..0cfbfd37 100644 --- a/features.go +++ b/features.go @@ -13,4 +13,8 @@ var localFeatures = lnwire.NewFeatureVector([]lnwire.Feature{ Name: "new-ping-and-funding", Flag: lnwire.RequiredFlag, }, + { + Name: "node-ann-feature-addr-swap", + Flag: lnwire.RequiredFlag, + }, }) diff --git a/lnwire/node_announcement.go b/lnwire/node_announcement.go index 47a8c35b..d010db66 100644 --- a/lnwire/node_announcement.go +++ b/lnwire/node_announcement.go @@ -120,8 +120,8 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error { &a.NodeID, &a.RGBColor, &a.Alias, - &a.Addresses, &a.Features, + &a.Addresses, ) } @@ -135,8 +135,8 @@ func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error { a.NodeID, a.RGBColor, a.Alias, - a.Addresses, a.Features, + a.Addresses, ) } @@ -166,8 +166,8 @@ func (a *NodeAnnouncement) DataToSign() ([]byte, error) { a.NodeID, a.RGBColor, a.Alias, - a.Addresses, a.Features, + a.Addresses, ) if err != nil { return nil, err