Merge pull request #9815 from mohamedawnallah/preventCurrentNodeAnnMutation
server.go: prevent partial mutation of `currentNodeAnn` in `server.genNodeAnnouncement` on `netann.SignNodeAnnouncement` failures
This commit is contained in:
2 files changed
+17
-2
No files matched your search
@@ -20,6 +20,12 @@
|
|||||||
|
|
||||||
# Bug Fixes
|
# 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
|
# New Features
|
||||||
|
|
||||||
## Functional Enhancements
|
## Functional Enhancements
|
||||||
@@ -119,4 +125,5 @@ circuit. The indices are only available for forwarding events saved after v0.20.
|
|||||||
* Abdulkbk
|
* Abdulkbk
|
||||||
* Elle Mouton
|
* Elle Mouton
|
||||||
* Funyug
|
* Funyug
|
||||||
|
* Mohamed Awnallah
|
||||||
* Pins
|
* Pins
|
||||||
@@ -3432,6 +3432,11 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
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
|
// First, try to update our feature manager with the updated set of
|
||||||
// features.
|
// features.
|
||||||
if features != nil {
|
if features != nil {
|
||||||
@@ -3457,17 +3462,20 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
|
|||||||
|
|
||||||
// Apply the requested changes to the node announcement.
|
// Apply the requested changes to the node announcement.
|
||||||
for _, modifier := range modifiers {
|
for _, modifier := range modifiers {
|
||||||
modifier(s.currentNodeAnn)
|
modifier(&newNodeAnn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign a new update after applying all of the passed modifiers.
|
// Sign a new update after applying all of the passed modifiers.
|
||||||
err := netann.SignNodeAnnouncement(
|
err := netann.SignNodeAnnouncement(
|
||||||
s.nodeSigner, s.identityKeyLoc, s.currentNodeAnn,
|
s.nodeSigner, s.identityKeyLoc, &newNodeAnn,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return lnwire.NodeAnnouncement{}, err
|
return lnwire.NodeAnnouncement{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If signing succeeds, update the current announcement.
|
||||||
|
*s.currentNodeAnn = newNodeAnn
|
||||||
|
|
||||||
return *s.currentNodeAnn, nil
|
return *s.currentNodeAnn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user