graph/db: make some ChannelEdgeInfo fields optional

Since not all will be required for V2 channels.

Wrap BitcoinKey1Bytes and BitcoinKey2Bytes in fn.Option since these
fields are only required for v1 channel announcements. V2 channels may
or may not have bitcoin keys present in their announcement.

NewV1Channel constructor wraps the bitcoin keys with fn.Some().
All access sites updated to unwrap the options, using UnwrapOr for
non-critical paths and UnwrapOrErr where the keys must be present
(e.g., KV serialization, ToChannelAnnouncement).
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:22 +02:00
1 parent 830b9db69c
commit 44f4171415
4 files changed
+72 -26

No files matched your search

+12 -8
View File
@@ -4288,15 +4288,19 @@ func insertChannel(ctx context.Context, db SQLQueries,
}
createParams := sqlc.CreateChannelParams{
Version: int16(v),
Scid: channelIDToBytes(edge.ChannelID),
NodeID1: node1DBID,
NodeID2: node2DBID,
Outpoint: edge.ChannelPoint.String(),
Capacity: capacity,
BitcoinKey1: edge.BitcoinKey1Bytes[:],
BitcoinKey2: edge.BitcoinKey2Bytes[:],
Version: int16(v),
Scid: channelIDToBytes(edge.ChannelID),
NodeID1: node1DBID,
NodeID2: node2DBID,
Outpoint: edge.ChannelPoint.String(),
Capacity: capacity,
}
edge.BitcoinKey1Bytes.WhenSome(func(vertex route.Vertex) {
createParams.BitcoinKey1 = vertex[:]
})
edge.BitcoinKey2Bytes.WhenSome(func(vertex route.Vertex) {
createParams.BitcoinKey2 = vertex[:]
})
if edge.AuthProof != nil {
proof := edge.AuthProof