• 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

29.17
/lncfg/sweeper.go
1
package lncfg
2

3
import (
4
        "fmt"
5
        "time"
6

7
        "github.com/lightningnetwork/lnd/contractcourt"
8
        "github.com/lightningnetwork/lnd/lnwallet/chainfee"
9
        "github.com/lightningnetwork/lnd/sweep"
10
)
11

12
const (
13
        // MaxFeeRateFloor is the smallest config value allowed for the max fee
14
        // rate in sat/vb.
15
        MaxFeeRateFloor chainfee.SatPerVByte = 100
16

17
        // MaxAllowedFeeRate is the largest fee rate in sat/vb that we allow
18
        // when configuring the MaxFeeRate.
19
        MaxAllowedFeeRate = 10_000
20
)
21

22
//nolint:ll
23
type Sweeper struct {
24
        BatchWindowDuration time.Duration        `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input." hidden:"true"`
25
        MaxFeeRate          chainfee.SatPerVByte `long:"maxfeerate" description:"Maximum fee rate in sat/vb that the sweeper is allowed to use when sweeping funds, the fee rate derived from budgets are capped at this value. Setting this value too low can result in transactions not being confirmed in time, causing HTLCs to expire hence potentially losing funds."`
26

27
        NoDeadlineConfTarget uint32 `long:"nodeadlineconftarget" description:"The conf target to use when sweeping non-time-sensitive outputs. This is useful for sweeping outputs that are not time-sensitive, and can be swept at a lower fee rate."`
28

29
        Budget *contractcourt.BudgetConfig `group:"sweeper.budget" namespace:"budget" long:"budget" description:"An optional config group that's used for the automatic sweep fee estimation. The Budget config gives options to limits ones fee exposure when sweeping unilateral close outputs and the fee rate calculated from budgets is capped at sweeper.maxfeerate. Check the budget config options for more details."`
30
}
31

32
// Validate checks the values configured for the sweeper.
UNCOV
33
func (s *Sweeper) Validate() error {
×
UNCOV
34
        if s.BatchWindowDuration < 0 {
×
35
                return fmt.Errorf("batchwindowduration must be positive")
×
36
        }
×
37

38
        // We require the max fee rate to be at least 100 sat/vbyte.
UNCOV
39
        if s.MaxFeeRate < MaxFeeRateFloor {
×
40
                return fmt.Errorf("maxfeerate must be >= 100 sat/vb")
×
41
        }
×
42

43
        // We require the max fee rate to be no greater than 10_000 sat/vbyte.
UNCOV
44
        if s.MaxFeeRate > MaxAllowedFeeRate {
×
45
                return fmt.Errorf("maxfeerate must be <= 10000 sat/vb")
×
46
        }
×
47

48
        // Make sure the conf target is at least 144 blocks (1 day).
UNCOV
49
        if s.NoDeadlineConfTarget < 144 {
×
50
                return fmt.Errorf("nodeadlineconftarget must be at least 144")
×
51
        }
×
52

53
        // Validate the budget configuration.
UNCOV
54
        if err := s.Budget.Validate(); err != nil {
×
55
                return fmt.Errorf("invalid budget config: %w", err)
×
56
        }
×
57

UNCOV
58
        return nil
×
59
}
60

61
// DefaultSweeperConfig returns the default configuration for the sweeper.
62
func DefaultSweeperConfig() *Sweeper {
1✔
63
        return &Sweeper{
1✔
64
                MaxFeeRate:           sweep.DefaultMaxFeeRate,
1✔
65
                NoDeadlineConfTarget: uint32(sweep.DefaultDeadlineDelta),
1✔
66
                Budget:               contractcourt.DefaultBudgetConfig(),
1✔
67
        }
1✔
68
}
1✔
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