• 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

23.26
/build/version.go
1
// Copyright (c) 2013-2017 The btcsuite developers
2
// Copyright (c) 2015-2016 The Decred developers
3
// Heavily inspired by https://github.com/btcsuite/btcd/blob/master/version.go
4
// Copyright (C) 2015-2022 The Lightning Network Developers
5

6
package build
7

8
import (
9
        "context"
10
        "encoding/hex"
11
        "fmt"
12
        "runtime/debug"
13
        "strings"
14

15
        "github.com/btcsuite/btclog/v2"
16
)
17

18
var (
19
        // Commit stores the current commit of this build, which includes the
20
        // most recent tag, the number of commits since that tag (if non-zero),
21
        // the commit hash, and a dirty marker. This should be set using the
22
        // -ldflags during compilation.
23
        Commit string
24

25
        // CommitHash stores the current commit hash of this build.
26
        CommitHash string
27

28
        // RawTags contains the raw set of build tags, separated by commas.
29
        RawTags string
30

31
        // GoVersion stores the go version that the executable was compiled
32
        // with.
33
        GoVersion string
34
)
35

36
// semanticAlphabet is the set of characters that are permitted for use in an
37
// AppPreRelease.
38
const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-."
39

40
// These constants define the application version and follow the semantic
41
// versioning 2.0.0 spec (http://semver.org/).
42
const (
43
        // AppMajor defines the major version of this binary.
44
        AppMajor uint = 0
45

46
        // AppMinor defines the minor version of this binary.
47
        AppMinor uint = 18
48

49
        // AppPatch defines the application patch for this binary.
50
        AppPatch uint = 99
51

52
        // AppPreRelease MUST only contain characters from semanticAlphabet per
53
        // the semantic versioning spec.
54
        AppPreRelease = "beta"
55
)
56

57
func init() {
74✔
58
        // Assert that AppPreRelease is valid according to the semantic
74✔
59
        // versioning guidelines for pre-release version and build metadata
74✔
60
        // strings. In particular it MUST only contain characters in
74✔
61
        // semanticAlphabet.
74✔
62
        for _, r := range AppPreRelease {
370✔
63
                if !strings.ContainsRune(semanticAlphabet, r) {
296✔
64
                        panic(fmt.Errorf("rune: %v is not in the semantic "+
×
65
                                "alphabet", r))
×
66
                }
67
        }
68

69
        // Get build information from the runtime.
70
        if info, ok := debug.ReadBuildInfo(); ok {
148✔
71
                GoVersion = info.GoVersion
74✔
72
                for _, setting := range info.Settings {
74✔
UNCOV
73
                        switch setting.Key {
×
UNCOV
74
                        case "vcs.revision":
×
UNCOV
75
                                CommitHash = setting.Value
×
76

UNCOV
77
                        case "-tags":
×
UNCOV
78
                                RawTags = setting.Value
×
79
                        }
80
                }
81
        }
82
}
83

84
// Version returns the application version as a properly formed string per the
85
// semantic versioning 2.0.0 spec (http://semver.org/).
UNCOV
86
func Version() string {
×
UNCOV
87
        // Start with the major, minor, and patch versions.
×
UNCOV
88
        version := fmt.Sprintf("%d.%d.%d", AppMajor, AppMinor, AppPatch)
×
UNCOV
89

×
UNCOV
90
        // Append pre-release version if there is one. The hyphen called for by
×
UNCOV
91
        // the semantic versioning spec is automatically appended and should not
×
UNCOV
92
        // be contained in the pre-release string.
×
UNCOV
93
        if AppPreRelease != "" {
×
UNCOV
94
                version = fmt.Sprintf("%s-%s", version, AppPreRelease)
×
UNCOV
95
        }
×
96

UNCOV
97
        return version
×
98
}
99

100
// Tags returns the list of build tags that were compiled into the executable.
UNCOV
101
func Tags() []string {
×
UNCOV
102
        if len(RawTags) == 0 {
×
103
                return nil
×
104
        }
×
105

UNCOV
106
        return strings.Split(RawTags, ",")
×
107
}
108

109
// WithBuildInfo derives a child context with the build information attached as
110
// attributes. At the moment, this only includes the current build's commit
111
// hash.
112
func WithBuildInfo(ctx context.Context, cfg *LogConfig) (context.Context,
UNCOV
113
        error) {
×
UNCOV
114

×
UNCOV
115
        if cfg.NoCommitHash {
×
UNCOV
116
                return ctx, nil
×
UNCOV
117
        }
×
118

119
        // Convert the commit hash to a byte slice.
120
        commitHash, err := hex.DecodeString(CommitHash)
×
121
        if err != nil {
×
122
                return nil, fmt.Errorf("unable to decode commit hash: %w", err)
×
123
        }
×
124

125
        return btclog.WithCtx(ctx, btclog.Hex3("rev", commitHash)), nil
×
126
}
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