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

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

0 of 9 new or added lines in 2 files covered. (0.0%)

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 hits per line

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

0.0
/lncfg/config.go
1
package lncfg
2

3
import (
4
        "os"
5
        "os/user"
6
        "path/filepath"
7
        "strings"
8
        "time"
9
)
10

11
const (
12
        // DefaultConfigFilename is the default configuration file name lnd
13
        // tries to load.
14
        DefaultConfigFilename = "lnd.conf"
15

16
        // DefaultMaxPendingChannels is the default maximum number of incoming
17
        // pending channels permitted per peer.
18
        DefaultMaxPendingChannels = 1
19

20
        // DefaultIncomingBroadcastDelta defines the number of blocks before the
21
        // expiry of an incoming htlc at which we force close the channel. We
22
        // only go to chain if we also have the preimage to actually pull in the
23
        // htlc. BOLT #2 suggests 7 blocks. We use a few more for extra safety.
24
        // Within this window we need to get our sweep or 2nd level success tx
25
        // confirmed, because after that the remote party is also able to claim
26
        // the htlc using the timeout path.
27
        DefaultIncomingBroadcastDelta = 10
28

29
        // DefaultFinalCltvRejectDelta defines the number of blocks before the
30
        // expiry of an incoming exit hop htlc at which we cancel it back
31
        // immediately. It is an extra safety measure over the final cltv
32
        // requirement as it is defined in the invoice. It ensures that we
33
        // cancel back htlcs that, when held on to, may cause us to force close
34
        // the channel because we enter the incoming broadcast window. Bolt #11
35
        // suggests 9 blocks here. We use a few more for additional safety.
36
        //
37
        // There is still a small gap that remains between receiving the
38
        // RevokeAndAck and canceling back. If a new block arrives within that
39
        // window, we may still force close the channel. There is currently no
40
        // way to reject an UpdateAddHtlc of which we already know that it will
41
        // push us in the broadcast window.
42
        DefaultFinalCltvRejectDelta = DefaultIncomingBroadcastDelta + 3
43

44
        // DefaultCltvInterceptDelta defines the number of blocks before the
45
        // expiry of the htlc where we don't intercept anymore. This value must
46
        // be greater than CltvRejectDelta, because we don't want to offer htlcs
47
        // to the interceptor client for which there is no time left to resolve
48
        // them anymore.
49
        DefaultCltvInterceptDelta = DefaultFinalCltvRejectDelta + 3
50

51
        // DefaultOutgoingBroadcastDelta defines the number of blocks before the
52
        // expiry of an outgoing htlc at which we force close the channel. We
53
        // are not in a hurry to force close, because there is nothing to claim
54
        // for us. We do need to time the htlc out, because there may be an
55
        // incoming htlc that will time out too (albeit later). Bolt #2 suggests
56
        // a value of -1 here, but we allow one block less to prevent potential
57
        // confusion around the negative value. It means we force close the
58
        // channel at exactly the htlc expiry height.
59
        DefaultOutgoingBroadcastDelta = 0
60

61
        // DefaultOutgoingCltvRejectDelta defines the number of blocks before
62
        // the expiry of an outgoing htlc at which we don't want to offer it to
63
        // the next peer anymore. If that happens, we cancel back the incoming
64
        // htlc. This is to prevent the situation where we have an outstanding
65
        // htlc that brings or will soon bring us inside the outgoing broadcast
66
        // window and trigger us to force close the channel. Bolt #2 suggests a
67
        // value of 0. We pad it a bit, to prevent a slow round trip to the next
68
        // peer and a block arriving during that round trip to trigger force
69
        // closure.
70
        DefaultOutgoingCltvRejectDelta = DefaultOutgoingBroadcastDelta + 3
71

72
        // DefaultZombieSweeperInterval is the default time interval at which
73
        // unfinished (zombiestate) open channel flows are purged from memory.
74
        DefaultZombieSweeperInterval = 1 * time.Minute
75
)
76

77
// CleanAndExpandPath expands environment variables and leading ~ in the
78
// passed path, cleans the result, and returns it.
79
// This function is taken from https://github.com/btcsuite/btcd
80
func CleanAndExpandPath(path string) string {
×
81
        if path == "" {
×
82
                return ""
×
83
        }
×
84

85
        // Expand initial ~ to OS specific home directory.
86
        if strings.HasPrefix(path, "~") {
×
87
                var homeDir string
×
88
                u, err := user.Current()
×
89
                if err == nil {
×
90
                        homeDir = u.HomeDir
×
91
                } else {
×
92
                        homeDir = os.Getenv("HOME")
×
93
                }
×
94

95
                path = strings.Replace(path, "~", homeDir, 1)
×
96
        }
97

98
        // NOTE: The os.ExpandEnv doesn't work with Windows-style %VARIABLE%,
99
        // but the variables can still be expanded via POSIX-style $VARIABLE.
100
        return filepath.Clean(os.ExpandEnv(path))
×
101
}
102

103
// NormalizeNetwork returns the common name of a network type used to create
104
// file paths. This allows differently versioned networks to use the same path.
UNCOV
105
func NormalizeNetwork(network string) string {
×
UNCOV
106
        if strings.HasPrefix(network, "testnet") {
×
107
                return "testnet"
×
108
        }
×
109

UNCOV
110
        return network
×
111
}
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