• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 12199391122

06 Dec 2024 01:10PM UTC coverage: 49.807% (-9.1%) from 58.933%
12199391122

push

github

web-flow
Merge pull request #9337 from Guayaba221/patch-1

chore: fix typo in ruby.md

100137 of 201051 relevant lines covered (49.81%)

2.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.0
/graph/ann_validation.go
1
package graph
2

3
import (
4
        "bytes"
5

6
        "github.com/btcsuite/btcd/btcec/v2"
7
        "github.com/btcsuite/btcd/chaincfg/chainhash"
8
        "github.com/go-errors/errors"
9
        "github.com/lightningnetwork/lnd/lnwire"
10
)
11

12
// ValidateNodeAnn validates the node announcement by ensuring that the
13
// attached signature is needed a signature of the node announcement under the
14
// specified node public key.
15
func ValidateNodeAnn(a *lnwire.NodeAnnouncement) error {
4✔
16
        // Reconstruct the data of announcement which should be covered by the
4✔
17
        // signature so we can verify the signature shortly below
4✔
18
        data, err := a.DataToSign()
4✔
19
        if err != nil {
4✔
20
                return err
×
21
        }
×
22

23
        nodeSig, err := a.Signature.ToSignature()
4✔
24
        if err != nil {
4✔
25
                return err
×
26
        }
×
27
        nodeKey, err := btcec.ParsePubKey(a.NodeID[:])
4✔
28
        if err != nil {
4✔
29
                return err
×
30
        }
×
31

32
        // Finally ensure that the passed signature is valid, if not we'll
33
        // return an error so this node announcement can be rejected.
34
        dataHash := chainhash.DoubleHashB(data)
4✔
35
        if !nodeSig.Verify(dataHash, nodeKey) {
4✔
36
                var msgBuf bytes.Buffer
×
37
                if _, err := lnwire.WriteMessage(&msgBuf, a, 0); err != nil {
×
38
                        return err
×
39
                }
×
40

41
                return errors.Errorf("signature on NodeAnnouncement(%x) is "+
×
42
                        "invalid: %x", nodeKey.SerializeCompressed(),
×
43
                        msgBuf.Bytes())
×
44
        }
45

46
        return nil
4✔
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc