lnwire: define GossipVersion and GossipMessage
What changed, and why it matters
This commit only adds new type definitions and an interface for future use. It does not change any existing behavior, fix a bug, or alter how messages are processed. There is no security issue here.
No action needed; this is a benign foundational refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces a GossipVersion uint8 enum with constants V1 and V2, a String() method, and a GossipMessage interface requiring a GossipVersion() method. It is purely additive in lnwire/interfaces.go and does not implement or modify any message handling logic.
Changed components
lnwire/interfaces.goInspect captured patch +34 / −1
diff --git a/lnwire/interfaces.go b/lnwire/interfaces.go
index 975cd6c..64d87f7 100644
--- a/lnwire/interfaces.go
+++ b/lnwire/interfaces.go
@@ -1,6 +1,39 @@
package lnwire
-import "github.com/btcsuite/btcd/chaincfg/chainhash"
+import (
+ "fmt"
+
+ "github.com/btcsuite/btcd/chaincfg/chainhash"
+)
+
+// GossipVersion is a version number that describes the version of the
+// gossip protocol that a gossip message was gossiped on.
+type GossipVersion uint8
+
+const (
+ // GossipVersion1 is the initial version of the gossip protocol as
+ // defined in BOLT 7. This version of the protocol can only gossip P2WSH
+ // channels and makes use of ECDSA signatures.
+ GossipVersion1 GossipVersion = 1
+
+ // GossipVersion2 is the newest version of the gossip protocol. This
+ // version adds support for P2TR channels and makes use of Schnorr
+ // signatures. The BOLT number is TBD.
+ GossipVersion2 GossipVersion = 2
+)
+
+// String returns a string representation of the protocol version.
+func (v GossipVersion) String() string {
+ return fmt.Sprintf("V%d", v)
+}
+
+// GossipMessage is an interface that must be satisfied by all messages that are
+// part of the gossip protocol.
+type GossipMessage interface {
+ // GossipVersion returns the version of the gossip protocol that a
+ // message is part of.
+ GossipVersion() GossipVersion
+}
// AnnounceSignatures is an interface that represents a message used to
// exchange signatures of a ChannelAnnouncment message during the funding flow.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.