mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 19:13:23 +02:00
multi/refactor: move node ann modification outside of sign method
In preparation for moving feature bit modification inside of the feature manager, separate node modification from signing.
This commit is contained in:
@@ -60,18 +60,11 @@ func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) {
|
|||||||
nodeAnn.Timestamp = newTimestamp
|
nodeAnn.Timestamp = newTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignNodeAnnouncement applies the given modifies to the passed
|
// SignNodeAnnouncement signs the lnwire.NodeAnnouncement provided, which
|
||||||
// lnwire.NodeAnnouncement, then signs the resulting announcement. The provided
|
// should be the most recent, valid update, otherwise the timestamp may not
|
||||||
// update should be the most recent, valid update, otherwise the timestamp may
|
// monotonically increase from the prior.
|
||||||
// not monotonically increase from the prior.
|
|
||||||
func SignNodeAnnouncement(signer lnwallet.MessageSigner,
|
func SignNodeAnnouncement(signer lnwallet.MessageSigner,
|
||||||
keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement,
|
keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement) error {
|
||||||
mods ...NodeAnnModifier) error {
|
|
||||||
|
|
||||||
// Apply the requested changes to the node announcement.
|
|
||||||
for _, modifier := range mods {
|
|
||||||
modifier(nodeAnn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the DER-encoded ECDSA signature over the message digest.
|
// Create the DER-encoded ECDSA signature over the message digest.
|
||||||
sig, err := SignAnnouncement(signer, keyLoc, nodeAnn)
|
sig, err := SignAnnouncement(signer, keyLoc, nodeAnn)
|
||||||
|
@@ -2961,11 +2961,15 @@ func (s *server) genNodeAnnouncement(refresh bool,
|
|||||||
// propagates.
|
// propagates.
|
||||||
modifiers = append(modifiers, netann.NodeAnnSetTimestamp)
|
modifiers = append(modifiers, netann.NodeAnnSetTimestamp)
|
||||||
|
|
||||||
|
// Apply the requested changes to the node announcement.
|
||||||
|
for _, modifier := range modifiers {
|
||||||
|
modifier(s.currentNodeAnn)
|
||||||
|
}
|
||||||
|
|
||||||
// Otherwise, we'll sign a new update after applying all of the passed
|
// Otherwise, we'll sign a new update after applying all of the passed
|
||||||
// modifiers.
|
// modifiers.
|
||||||
err := netann.SignNodeAnnouncement(
|
err := netann.SignNodeAnnouncement(
|
||||||
s.nodeSigner, s.identityKeyLoc, s.currentNodeAnn,
|
s.nodeSigner, s.identityKeyLoc, s.currentNodeAnn,
|
||||||
modifiers...,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return lnwire.NodeAnnouncement{}, err
|
return lnwire.NodeAnnouncement{}, err
|
||||||
|
Reference in New Issue
Block a user