Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gossip #95

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
efabd2f
multi: rename AnnounceSignatures to AnnounceSignatures1
ellemouton Oct 26, 2023
a94a23c
multi: rename ChannelAnnouncement to ChannelAnnouncment1
ellemouton Oct 26, 2023
5edb0c9
multi: rename ChannelUpdate to ChannelUpdate1
ellemouton Oct 26, 2023
b86dd40
multi: rename NodeAnnouncement
ellemouton Oct 26, 2023
3156421
lnwire: make MuSig2Nonce TLV type re-usable
ellemouton Sep 29, 2023
8b62443
lnwire: add RawFeatureVectorRecordProducer
ellemouton Sep 29, 2023
1244c8d
lnwire: add Encode and Pack methods for tlv.Records
ellemouton Sep 29, 2023
96907a1
lnwire: use the RawFeatureVector record methods for ChannelType
ellemouton Sep 29, 2023
fc71936
lnwire: make ShortChannelID type re-usable
ellemouton Sep 29, 2023
83da688
lnwire: add btc and node announcement nonces to channel_ready
ellemouton Sep 29, 2023
0e50cf0
lnwire: add FirstBlock and BlockRange to GossipTimestampRange
ellemouton Oct 26, 2023
7bc9dcf
lnwire: add AnnounceSignatures interface
ellemouton Oct 26, 2023
03347bf
lnwire: add a ChannelAnnouncement interface
ellemouton Oct 26, 2023
804f7f8
lnwire: add a ChannelUpdate interface
ellemouton Oct 26, 2023
c45525f
lnwire: add MsgHash helper
ellemouton Oct 26, 2023
9d0c372
lnwire: add AnnounceSignatures2 message
ellemouton Sep 29, 2023
0f129a4
lnwire: add ChannelAnnouncement2 message
ellemouton Sep 29, 2023
695c431
lnwire: introduce the BooleanRecordProducer
ellemouton Sep 29, 2023
8c08665
lnwire: add ChannelUpdate2
ellemouton Sep 29, 2023
e2c260b
lnwire: add NodeAnnouncement2
ellemouton Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lnwire: add NodeAnnouncement2
  • Loading branch information
ellemouton committed Nov 9, 2023
commit e2c260bc3037f9ff5e54b414dfd2f73421ddcb84
73 changes: 73 additions & 0 deletions lnwire/lnwire_test.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package lnwire

import (
"bytes"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
@@ -1229,6 +1230,72 @@ func TestLightningWireProtocol(t *testing.T) {
require.NoError(t, err)
}
},
MsgNodeAnnouncement2: func(v []reflect.Value, r *rand.Rand) {
req := NodeAnnouncement2{
Signature: testSchnorrSig,
BlockHeight: r.Uint32(),
NodeID: randRawKey(t),
ExtraOpaqueData: make([]byte, 0),
}

features := randRawFeatureVector(r)
req.Features = *features

// Sometimes set the colour field.
if r.Int31()%2 == 0 {
req.RGBColor = &color.RGBA{
R: uint8(r.Int31()),
G: uint8(r.Int31()),
B: uint8(r.Int31()),
}
}

n := r.Intn(33)
b := make([]byte, n)
_, err := rand.Read(b)
require.NoError(t, err)

if n > 0 {
req.Alias = []byte(
base64.StdEncoding.EncodeToString(b),
)
if len(req.Alias) > 32 {
req.Alias = req.Alias[:32]
}
}

// Sometimes add some ipv4 addrs.
if r.Int31()%2 == 0 {
ipv4Addr, err := randTCP4Addr(r)
require.NoError(t, err)
req.Addresses = append(req.Addresses, ipv4Addr)
}

// Sometimes add some ipv6 addrs.
if r.Int31()%2 == 0 {
ipv6Addr, err := randTCP6Addr(r)
require.NoError(t, err)
req.Addresses = append(req.Addresses, ipv6Addr)
}

// Sometimes add some torv3 addrs.
if r.Int31()%2 == 0 {
ipv6Addr, err := randV3OnionAddr(r)
require.NoError(t, err)
req.Addresses = append(req.Addresses, ipv6Addr)
}

numExtraBytes := r.Int31n(1000)
if numExtraBytes > 0 {
req.ExtraOpaqueData = make(
[]byte, numExtraBytes,
)
_, err := r.Read(req.ExtraOpaqueData[:])
require.NoError(t, err)
}

v[0] = reflect.ValueOf(req)
},
}

// With the above types defined, we'll now generate a slice of
@@ -1427,6 +1494,12 @@ func TestLightningWireProtocol(t *testing.T) {
return mainScenario(&m)
},
},
{
msgType: MsgNodeAnnouncement2,
scenario: func(m NodeAnnouncement2) bool {
return mainScenario(&m)
},
},
}
for _, test := range tests {
var config *quick.Config
5 changes: 5 additions & 0 deletions lnwire/message.go
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ const (
MsgReplyChannelRange = 264
MsgGossipTimestampRange = 265
MsgChannelAnnouncement2 = 267
MsgNodeAnnouncement2 = 269
MsgChannelUpdate2 = 271
)

@@ -143,6 +144,8 @@ func (t MessageType) String() string {
return "ChannelAnnouncement2"
case MsgChannelUpdate2:
return "ChannelUpdate2"
case MsgNodeAnnouncement2:
return "NodeAnnouncement2"
default:
return "<unknown>"
}
@@ -251,6 +254,8 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
msg = &ChannelAnnouncement2{}
case MsgChannelUpdate2:
msg = &ChannelUpdate2{}
case MsgNodeAnnouncement2:
msg = &NodeAnnouncement2{}
default:
// If the message is not within our custom range and has not
// specifically been overridden, return an unknown message.
Loading