lnwire: shift fields in NodeAnnouncment to match recent BOLT-0007 changes
This commit modifies the NodeAnnouncement message to ensure that it matches the current spec ordering. The spec was recently modified to place the feature vector first to allow for future changes to the fields to be forwards compatible.
This commit is contained in:
parent
96696ccd99
commit
29af6e6932
@ -384,14 +384,14 @@ func TestLightningWireProtocol(t *testing.T) {
|
|||||||
|
|
||||||
req := NodeAnnouncement{
|
req := NodeAnnouncement{
|
||||||
Signature: testSig,
|
Signature: testSig,
|
||||||
|
Features: randFeatureVector(r),
|
||||||
Timestamp: uint32(r.Int31()),
|
Timestamp: uint32(r.Int31()),
|
||||||
Alias: newAlias(a[:]),
|
Alias: a,
|
||||||
RGBColor: RGB{
|
RGBColor: RGB{
|
||||||
red: uint8(r.Int31()),
|
red: uint8(r.Int31()),
|
||||||
green: uint8(r.Int31()),
|
green: uint8(r.Int31()),
|
||||||
blue: uint8(r.Int31()),
|
blue: uint8(r.Int31()),
|
||||||
},
|
},
|
||||||
Features: randFeatureVector(r),
|
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
}
|
}
|
||||||
req.Features.featuresMap = nil
|
req.Features.featuresMap = nil
|
||||||
|
@ -58,26 +58,25 @@ type NodeAnnouncement struct {
|
|||||||
// Signature is used to prove the ownership of node id.
|
// Signature is used to prove the ownership of node id.
|
||||||
Signature *btcec.Signature
|
Signature *btcec.Signature
|
||||||
|
|
||||||
// Timestamp allows ordering in the case of multiple
|
// Features is the list of protocol features this node supports.
|
||||||
// announcements.
|
Features *FeatureVector
|
||||||
|
|
||||||
|
// Timestamp allows ordering in the case of multiple announcements.
|
||||||
Timestamp uint32
|
Timestamp uint32
|
||||||
|
|
||||||
// NodeID is a public key which is used as node identification.
|
// NodeID is a public key which is used as node identification.
|
||||||
NodeID *btcec.PublicKey
|
NodeID *btcec.PublicKey
|
||||||
|
|
||||||
// RGBColor is used to customize their node's appearance in
|
// RGBColor is used to customize their node's appearance in maps and
|
||||||
// maps and graphs
|
// graphs
|
||||||
RGBColor RGB
|
RGBColor RGB
|
||||||
|
|
||||||
|
|
||||||
// Features is the list of protocol features this node supports.
|
|
||||||
Features *FeatureVector
|
|
||||||
// Alias is used to customize their node's appearance in maps and
|
// Alias is used to customize their node's appearance in maps and
|
||||||
// graphs
|
// graphs
|
||||||
Alias NodeAlias
|
Alias NodeAlias
|
||||||
|
|
||||||
// Address includes two specification fields: 'ipv6' and 'port' on which
|
// Address includes two specification fields: 'ipv6' and 'port' on
|
||||||
// the node is accepting incoming connections.
|
// which the node is accepting incoming connections.
|
||||||
Addresses []net.Addr
|
Addresses []net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,11 +91,11 @@ var _ Message = (*NodeAnnouncement)(nil)
|
|||||||
func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&a.Signature,
|
&a.Signature,
|
||||||
|
&a.Features,
|
||||||
&a.Timestamp,
|
&a.Timestamp,
|
||||||
&a.NodeID,
|
&a.NodeID,
|
||||||
&a.RGBColor,
|
&a.RGBColor,
|
||||||
&a.Alias,
|
a.Alias[:],
|
||||||
&a.Features,
|
|
||||||
&a.Addresses,
|
&a.Addresses,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -107,11 +106,11 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
|||||||
func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
a.Signature,
|
a.Signature,
|
||||||
|
a.Features,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.NodeID,
|
a.NodeID,
|
||||||
a.RGBColor,
|
a.RGBColor,
|
||||||
a.Alias,
|
a.Alias[:],
|
||||||
a.Features,
|
|
||||||
a.Addresses,
|
a.Addresses,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -138,16 +137,18 @@ func (a *NodeAnnouncement) DataToSign() ([]byte, error) {
|
|||||||
// We should not include the signatures itself.
|
// We should not include the signatures itself.
|
||||||
var w bytes.Buffer
|
var w bytes.Buffer
|
||||||
err := writeElements(&w,
|
err := writeElements(&w,
|
||||||
|
a.Features,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.NodeID,
|
a.NodeID,
|
||||||
a.RGBColor,
|
a.RGBColor,
|
||||||
a.Alias,
|
a.Alias[:],
|
||||||
a.Features,
|
|
||||||
a.Addresses,
|
a.Addresses,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(roasbeef): also capture the excess bytes in msg padded out?
|
||||||
|
|
||||||
return w.Bytes(), nil
|
return w.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user