multi: add ToChannelAnnouncement helper on ChannelEdgeInfo
So that we have one place that converts from our `models` struct to the `lnwire.ChannelAnnouncement` struct. The commit also refactors netann.CreateChanAnnouncement to only take a ChannelEdgeInfo and get the proof from there instead of needing the proof to be passed in separately. Add ToChannelAnnouncement() method to ChannelEdgeInfo that converts the model struct to a lnwire.ChannelAnnouncement1 message. This: - Centralizes the conversion logic in one place instead of scattered across multiple call sites - Validates that AuthProof is present (can't create announcement without proof) - Currently only supports v1 channels, returning error for v2 Refactor netann.CreateChanAnnouncement to use this helper and remove the separate chanProof parameter since proof is now accessed from within ChannelEdgeInfo. This improves encapsulation and reduces parameter count.
This commit is contained in:
5 files changed
+82
-80
No files matched your search
@@ -133,8 +133,7 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
|
||||
|
||||
//nolint:ll
|
||||
chanAnn, edge1, edge2, err := netann.CreateChanAnnouncement(
|
||||
channel.Info.AuthProof, channel.Info,
|
||||
channel.Policy1, channel.Policy2,
|
||||
channel.Info, channel.Policy1, channel.Policy2,
|
||||
)
|
||||
if err != nil {
|
||||
if !yield(nil, err) {
|
||||
@@ -281,8 +280,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash,
|
||||
}
|
||||
|
||||
chanAnn, edge1, edge2, err := netann.CreateChanAnnouncement(
|
||||
channel.Info.AuthProof, channel.Info, channel.Policy1,
|
||||
channel.Policy2,
|
||||
channel.Info, channel.Policy1, channel.Policy2,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user