• 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

50.0
/lncfg/wtclient.go
1
package lncfg
2

3
import (
4
        "fmt"
5

6
        "github.com/lightningnetwork/lnd/watchtower/wtclient"
7
        "github.com/lightningnetwork/lnd/watchtower/wtpolicy"
8
)
9

10
// WtClient holds the configuration options for the daemon's watchtower client.
11
//
12
//nolint:ll
13
type WtClient struct {
14
        // Active determines whether a watchtower client should be created to
15
        // back up channel states with registered watchtowers.
16
        Active bool `long:"active" description:"Whether the daemon should use private watchtowers to back up revoked channel states."`
17

18
        // SweepFeeRate specifies the fee rate in sat/byte to be used when
19
        // constructing justice transactions sent to the tower.
20
        SweepFeeRate uint64 `long:"sweep-fee-rate" description:"Specifies the fee rate in sat/byte to be used when constructing justice transactions sent to the watchtower."`
21

22
        // SessionCloseRange is the range over which to choose a random number
23
        // of blocks to wait after the last channel of a session is closed
24
        // before sending the DeleteSession message to the tower server.
25
        SessionCloseRange uint32 `long:"session-close-range" description:"The range over which to choose a random number of blocks to wait after the last channel of a session is closed before sending the DeleteSession message to the tower server. Set to 1 for no delay."`
26

27
        // MaxTasksInMemQueue is the maximum number of back-up tasks that should
28
        // be queued in memory before overflowing to disk.
29
        MaxTasksInMemQueue uint64 `long:"max-tasks-in-mem-queue" description:"The maximum number of updates that should be queued in memory before overflowing to disk."`
30

31
        // MaxUpdates is the maximum number of updates to be backed up in a
32
        // single tower sessions.
33
        MaxUpdates uint16 `long:"max-updates" description:"The maximum number of updates to be backed up in a single session."`
34
}
35

36
// DefaultWtClientCfg returns the WtClient config struct with some default
37
// values populated.
38
func DefaultWtClientCfg() *WtClient {
1✔
39
        // The sweep fee rate used internally by the tower client is in sats/kw
1✔
40
        // but the config exposed to the user is in sats/byte, so we convert the
1✔
41
        // default here before exposing it to the user.
1✔
42
        sweepSatsPerVB := wtpolicy.DefaultSweepFeeRate.FeePerVByte()
1✔
43
        sweepFeeRate := uint64(sweepSatsPerVB)
1✔
44

1✔
45
        return &WtClient{
1✔
46
                SweepFeeRate:       sweepFeeRate,
1✔
47
                SessionCloseRange:  wtclient.DefaultSessionCloseRange,
1✔
48
                MaxTasksInMemQueue: wtclient.DefaultMaxTasksInMemQueue,
1✔
49
                MaxUpdates:         wtpolicy.DefaultMaxUpdates,
1✔
50
        }
1✔
51
}
1✔
52

53
// Validate ensures the user has provided a valid configuration.
54
//
55
// NOTE: Part of the Validator interface.
UNCOV
56
func (c *WtClient) Validate() error {
×
UNCOV
57
        if c.SweepFeeRate == 0 {
×
58
                return fmt.Errorf("sweep-fee-rate must be non-zero")
×
59
        }
×
60

UNCOV
61
        if c.MaxUpdates == 0 {
×
62
                return fmt.Errorf("max-updates must be non-zero")
×
63
        }
×
64

UNCOV
65
        if c.MaxTasksInMemQueue == 0 {
×
66
                return fmt.Errorf("max-tasks-in-mem-queue must be non-zero")
×
67
        }
×
68

UNCOV
69
        if c.SessionCloseRange == 0 {
×
70
                return fmt.Errorf("session-close-range must be non-zero")
×
71
        }
×
72

UNCOV
73
        return nil
×
74
}
75

76
// Compile-time constraint to ensure WtClient implements the Validator
77
// interface.
78
var _ Validator = (*WtClient)(nil)
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