Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/release-notes/release-notes-0.20.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

# Bug Fixes

- Fixed potential update inconsistencies in node announcements [by creating
a shallow copy before modifications](
https://github.com/lightningnetwork/lnd/pull/9815). This ensures the original
announcement remains unchanged until the new one is fully signed and
validated.

# New Features

## Functional Enhancements
Expand Down Expand Up @@ -119,4 +125,5 @@ circuit. The indices are only available for forwarding events saved after v0.20.
* Abdulkbk
* Elle Mouton
* Funyug
* Mohamed Awnallah
* Pins
12 changes: 10 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3432,6 +3432,11 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
s.mu.Lock()
defer s.mu.Unlock()

// Create a shallow copy of the current node announcement to work on.
// This ensures the original announcement remains unchanged
// until the new announcement is fully signed and valid.
newNodeAnn := *s.currentNodeAnn

// First, try to update our feature manager with the updated set of
// features.
if features != nil {
Expand All @@ -3457,17 +3462,20 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,

// Apply the requested changes to the node announcement.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider updating the comment to reflect that the node announcement isn’t being modified yet.

for _, modifier := range modifiers {
modifier(s.currentNodeAnn)
modifier(&newNodeAnn)
}

// Sign a new update after applying all of the passed modifiers.
err := netann.SignNodeAnnouncement(
s.nodeSigner, s.identityKeyLoc, s.currentNodeAnn,
s.nodeSigner, s.identityKeyLoc, &newNodeAnn,
)
if err != nil {
return lnwire.NodeAnnouncement{}, err
}

// If signing succeeds, update the current announcement.
*s.currentNodeAnn = newNodeAnn

return *s.currentNodeAnn, nil
}

Expand Down
Loading