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

lightningnetwork / lnd / 11170835610

03 Oct 2024 10:41PM UTC coverage: 49.188% (-9.6%) from 58.738%
11170835610

push

github

web-flow
Merge pull request #9154 from ziggie1984/master

multi: bump btcd version.

3 of 6 new or added lines in 6 files covered. (50.0%)

26110 existing lines in 428 files now uncovered.

97359 of 197934 relevant lines covered (49.19%)

1.04 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 {
2✔
16
        // Reconstruct the data of announcement which should be covered by the
2✔
17
        // signature so we can verify the signature shortly below
2✔
18
        data, err := a.DataToSign()
2✔
19
        if err != nil {
2✔
UNCOV
20
                return err
×
UNCOV
21
        }
×
22

23
        nodeSig, err := a.Signature.ToSignature()
2✔
24
        if err != nil {
2✔
25
                return err
×
26
        }
×
27
        nodeKey, err := btcec.ParsePubKey(a.NodeID[:])
2✔
28
        if err != nil {
2✔
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)
2✔
35
        if !nodeSig.Verify(dataHash, nodeKey) {
2✔
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
2✔
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