@@ -3432,6 +3432,11 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
3432
3432
s .mu .Lock ()
3433
3433
defer s .mu .Unlock ()
3434
3434
3435
+ // Create a shallow copy of the current node announcement to work on.
3436
+ // This ensures the original announcement remains unchanged
3437
+ // until the new announcement is fully signed and valid.
3438
+ newNodeAnn := * s .currentNodeAnn
3439
+
3435
3440
// First, try to update our feature manager with the updated set of
3436
3441
// features.
3437
3442
if features != nil {
@@ -3457,17 +3462,20 @@ func (s *server) genNodeAnnouncement(features *lnwire.RawFeatureVector,
3457
3462
3458
3463
// Apply the requested changes to the node announcement.
3459
3464
for _ , modifier := range modifiers {
3460
- modifier (s . currentNodeAnn )
3465
+ modifier (& newNodeAnn )
3461
3466
}
3462
3467
3463
3468
// Sign a new update after applying all of the passed modifiers.
3464
3469
err := netann .SignNodeAnnouncement (
3465
- s .nodeSigner , s .identityKeyLoc , s . currentNodeAnn ,
3470
+ s .nodeSigner , s .identityKeyLoc , & newNodeAnn ,
3466
3471
)
3467
3472
if err != nil {
3468
3473
return lnwire.NodeAnnouncement {}, err
3469
3474
}
3470
3475
3476
+ // If signing succeeds, update the current announcement.
3477
+ * s .currentNodeAnn = newNodeAnn
3478
+
3471
3479
return * s .currentNodeAnn , nil
3472
3480
}
3473
3481
0 commit comments