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
+10
-1
@@ -2038,7 +2038,9 @@ func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
||||
// populate the edge info with the public keys of each
|
||||
// party as this is the only information we have about
|
||||
// it.
|
||||
edge = &models.ChannelEdgeInfo{}
|
||||
edge = &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
}
|
||||
copy(edge.NodeKey1Bytes[:], zombie.NodeKey1)
|
||||
copy(edge.NodeKey2Bytes[:], zombie.NodeKey2)
|
||||
|
||||
@@ -4241,6 +4243,12 @@ func insertChannel(ctx context.Context, db SQLQueries,
|
||||
|
||||
v := lnwire.GossipVersion1
|
||||
|
||||
// For now, we only support V1 channel edges in the SQL store.
|
||||
if edge.Version != v {
|
||||
return fmt.Errorf("only V1 channel edges supported, got V%d",
|
||||
edge.Version)
|
||||
}
|
||||
|
||||
// Make sure that at least a "shell" entry for each node is present in
|
||||
// the nodes table.
|
||||
node1DBID, err := maybeCreateShellNode(
|
||||
@@ -4458,6 +4466,7 @@ func buildEdgeInfoWithBatchData(chain chainhash.Hash,
|
||||
copy(btcKey2[:], dbChan.BitcoinKey2)
|
||||
|
||||
channel := &models.ChannelEdgeInfo{
|
||||
Version: lnwire.GossipVersion1,
|
||||
ChainHash: chain,
|
||||
ChannelID: byteOrder.Uint64(dbChan.Scid),
|
||||
NodeKey1Bytes: node1,
|
||||
|
||||
Reference in new issue
Block a user