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

lightningnetwork / lnd / 12986279612

27 Jan 2025 09:51AM UTC coverage: 57.652% (-1.1%) from 58.788%
12986279612

Pull #9447

github

yyforyongyu
sweep: rename methods for clarity

We now rename "third party" to "unknown" as the inputs can be spent via
an older sweeping tx, a third party (anchor), or a remote party (pin).
In fee bumper we don't have the info to distinguish the above cases, and
leave them to be further handled by the sweeper as it has more context.
Pull Request #9447: sweep: start tracking input spending status in the fee bumper

83 of 87 new or added lines in 2 files covered. (95.4%)

19578 existing lines in 256 files now uncovered.

103448 of 179434 relevant lines covered (57.65%)

24884.58 hits per line

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

0.0
/netann/node_announcement.go
1
package netann
2

3
import (
4
        "image/color"
5
        "net"
6
        "time"
7

8
        "github.com/lightningnetwork/lnd/keychain"
9
        "github.com/lightningnetwork/lnd/lnwallet"
10
        "github.com/lightningnetwork/lnd/lnwire"
11
)
12

13
// NodeAnnModifier is a closure that makes in-place modifications to an
14
// lnwire.NodeAnnouncement.
15
type NodeAnnModifier func(*lnwire.NodeAnnouncement)
16

17
// NodeAnnSetAlias is a functional option that sets the alias of the
18
// given node announcement.
UNCOV
19
func NodeAnnSetAlias(alias lnwire.NodeAlias) func(*lnwire.NodeAnnouncement) {
×
UNCOV
20
        return func(nodeAnn *lnwire.NodeAnnouncement) {
×
UNCOV
21
                nodeAnn.Alias = alias
×
UNCOV
22
        }
×
23
}
24

25
// NodeAnnSetAddrs is a functional option that allows updating the addresses of
26
// the given node announcement.
UNCOV
27
func NodeAnnSetAddrs(addrs []net.Addr) func(*lnwire.NodeAnnouncement) {
×
UNCOV
28
        return func(nodeAnn *lnwire.NodeAnnouncement) {
×
UNCOV
29
                nodeAnn.Addresses = addrs
×
UNCOV
30
        }
×
31
}
32

33
// NodeAnnSetColor is a functional option that sets the color of the
34
// given node announcement.
UNCOV
35
func NodeAnnSetColor(newColor color.RGBA) func(*lnwire.NodeAnnouncement) {
×
UNCOV
36
        return func(nodeAnn *lnwire.NodeAnnouncement) {
×
UNCOV
37
                nodeAnn.RGBColor = newColor
×
UNCOV
38
        }
×
39
}
40

41
// NodeAnnSetFeatures is a functional option that allows updating the features of
42
// the given node announcement.
UNCOV
43
func NodeAnnSetFeatures(features *lnwire.RawFeatureVector) func(*lnwire.NodeAnnouncement) {
×
UNCOV
44
        return func(nodeAnn *lnwire.NodeAnnouncement) {
×
UNCOV
45
                nodeAnn.Features = features
×
UNCOV
46
        }
×
47
}
48

49
// NodeAnnSetTimestamp is a functional option that sets the timestamp of the
50
// announcement to the current time, or increments it if the timestamp is
51
// already in the future.
UNCOV
52
func NodeAnnSetTimestamp(nodeAnn *lnwire.NodeAnnouncement) {
×
UNCOV
53
        newTimestamp := uint32(time.Now().Unix())
×
UNCOV
54
        if newTimestamp <= nodeAnn.Timestamp {
×
UNCOV
55
                // Increment the prior value to  ensure the timestamp
×
UNCOV
56
                // monotonically increases, otherwise the announcement won't
×
UNCOV
57
                // propagate.
×
UNCOV
58
                newTimestamp = nodeAnn.Timestamp + 1
×
UNCOV
59
        }
×
UNCOV
60
        nodeAnn.Timestamp = newTimestamp
×
61
}
62

63
// SignNodeAnnouncement signs the lnwire.NodeAnnouncement provided, which
64
// should be the most recent, valid update, otherwise the timestamp may not
65
// monotonically increase from the prior.
66
func SignNodeAnnouncement(signer lnwallet.MessageSigner,
UNCOV
67
        keyLoc keychain.KeyLocator, nodeAnn *lnwire.NodeAnnouncement) error {
×
UNCOV
68

×
UNCOV
69
        // Create the DER-encoded ECDSA signature over the message digest.
×
UNCOV
70
        sig, err := SignAnnouncement(signer, keyLoc, nodeAnn)
×
UNCOV
71
        if err != nil {
×
72
                return err
×
73
        }
×
74

75
        // Parse the DER-encoded signature into a fixed-size 64-byte array.
UNCOV
76
        nodeAnn.Signature, err = lnwire.NewSigFromSignature(sig)
×
UNCOV
77
        return err
×
78
}
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