multi: add version to models.ChannelEdgeInfo
And set it to V1 version everywhere. Add a Version field to ChannelEdgeInfo to distinguish between v1 and v2 channel announcements. Set it to GossipVersion1 for all existing channels. Both KV and SQL stores now validate that only v1 channels are currently supported, returning an error for v2 channels. The KV store automatically sets version to v1 when deserializing (since all persisted channels in KV format are v1). This versioning is essential for handling the different field requirements and validation logic between v1 and v2 channels.
This commit is contained in:
18 files changed
+64
-1
No files matched your search
@@ -329,6 +329,7 @@ func (r *Manager) createEdge(channel *channeldb.OpenChannel,
|
||||
}
|
||||
|
||||
info := &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: shortChanID.ToUint64(),
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
|
||||
@@ -212,6 +212,7 @@ func TestManager(t *testing.T) {
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -230,6 +231,7 @@ func TestManager(t *testing.T) {
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -248,6 +250,7 @@ func TestManager(t *testing.T) {
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -270,6 +273,7 @@ func TestManager(t *testing.T) {
|
||||
channelSet: []channel{
|
||||
{
|
||||
edgeInfo: &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
Capacity: chanCap,
|
||||
ChannelPoint: chanPointValid,
|
||||
},
|
||||
@@ -392,6 +396,7 @@ func TestCreateEdgeLower(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
@@ -485,6 +490,7 @@ func TestCreateEdgeHigher(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedInfo := &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: 8,
|
||||
ChainHash: channel.ChainHash,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
|
||||
@@ -346,6 +346,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
// We first insert the existence of the edge between the two
|
||||
// nodes.
|
||||
edgeInfo := models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: edge.ChannelID,
|
||||
AuthProof: &testAuthProof,
|
||||
ChannelPoint: fundingPoint,
|
||||
@@ -678,6 +679,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
// We first insert the existence of the edge between the two
|
||||
// nodes.
|
||||
edgeInfo := models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: channelID,
|
||||
AuthProof: &testAuthProof,
|
||||
ChannelPoint: *fundingPoint,
|
||||
|
||||
@@ -2739,6 +2739,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
require.NoError(t, err, "unable to create channel edge")
|
||||
|
||||
edge := &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: chanID.ToUint64(),
|
||||
NodeKey1Bytes: pub1,
|
||||
NodeKey2Bytes: pub2,
|
||||
@@ -2819,6 +2820,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
require.NoError(t, err, "unable to create channel edge")
|
||||
|
||||
edge = &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChannelID: chanID.ToUint64(),
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
AuthProof: nil,
|
||||
|
||||
Reference in new issue
Block a user