lnwire: add Outpoint to ChannelAnnouncement2
What changed, and why it matters
This commit updates LND's implementation of a Lightning network protocol message called channel_announcement2 to include the funding transaction outpoint, matching a recent specification change. It is a straightforward protocol-compliance change with no apparent security vulnerability or fix.
No security action required. Review as normal protocol-compliance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds an Outpoint field (TLV type 18) to the ChannelAnnouncement2 wire message, updates encoding/decoding logic, and adds corresponding test vectors and random test message generation. The change is additive and aligns with the latest BOLT/spec version. There is no evidence of a security bug, bounds issue, cryptographic flaw, or behavior change beyond message serialization.
Changed components
lnwire/channel_announcement_2.golnwire/channel_announcement_2_test.golnwire/test_message.goInspect captured patch +21 / −0
diff --git a/lnwire/channel_announcement_2.go b/lnwire/channel_announcement_2.go
index 0066dad..a82624a 100644
--- a/lnwire/channel_announcement_2.go
+++ b/lnwire/channel_announcement_2.go
@@ -56,6 +56,9 @@ type ChannelAnnouncement2 struct {
// the funding output is a pure 2-of-2 MuSig aggregate public key.
MerkleRootHash tlv.OptionalRecordT[tlv.TlvType16, [32]byte]
+ // Outpoint is the outpoint of the funding transaction.
+ Outpoint tlv.RecordT[tlv.TlvType18, OutPoint]
+
// Signature is a Schnorr signature over serialised signed-range TLV
// stream of the message.
Signature tlv.RecordT[tlv.TlvType160, Sig]
@@ -121,6 +124,7 @@ func (c *ChannelAnnouncement2) nonSignatureRecordProducers() []tlv.RecordProduce
},
)
+ recordProducers = append(recordProducers, &c.Outpoint)
recordProducers = append(recordProducers, RecordsAsProducers(
tlv.MapToRecords(c.ExtraSignedFields),
)...)
@@ -149,6 +153,7 @@ func (c *ChannelAnnouncement2) Decode(r io.Reader, _ uint32) error {
&btcKey1,
&btcKey2,
&merkleRootHash,
+ &c.Outpoint,
&c.Signature,
)...)
if err != nil {
@@ -202,6 +207,7 @@ func (c *ChannelAnnouncement2) DecodeNonSigTLVRecords(r io.Reader) error {
&btcKey1,
&btcKey2,
&merkleRootHash,
+ &c.Outpoint,
)...)
if err != nil {
return err
diff --git a/lnwire/channel_announcement_2_test.go b/lnwire/channel_announcement_2_test.go
index 40d255b..3a2ce28 100644
--- a/lnwire/channel_announcement_2_test.go
+++ b/lnwire/channel_announcement_2_test.go
@@ -58,6 +58,17 @@ func TestChanAnn2EncodeDecode(t *testing.T) {
0xb3, 0xee, 0x17, 0x2f, 0x7f, 0x16, 0x1, 0xe6, 0x7d, 0x1d, 0xa6,
0xca, 0xd4, 0xb, 0x54, 0xc4, 0x46, 0x8d, 0x48, 0x23, 0x6c, 0x39,
+ // Outpoint record.
+ 0x12, // type (18).
+ 0x22, // length (34 bytes).
+ // Hash (32 bytes).
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
+ // Index (2 bytes).
+ 0x30, 0x39, // value: 12345.
+
// Unknown TLV record.
0x6f, // type.
0x2, // length.
diff --git a/lnwire/test_message.go b/lnwire/test_message.go
index 0c2fe5e..6fb6725 100644
--- a/lnwire/test_message.go
+++ b/lnwire/test_message.go
@@ -291,6 +291,10 @@ func (c *ChannelAnnouncement2) RandTestMessage(t *rapid.T) Message {
)
}
+ msg.Outpoint = tlv.NewRecordT[tlv.TlvType18, OutPoint](
+ OutPoint(RandOutPoint(t)),
+ )
+
return msg
}
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.