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

lightningnetwork / lnd / 11393106485

17 Oct 2024 09:10PM UTC coverage: 57.848% (-1.0%) from 58.81%
11393106485

Pull #9148

github

ProofOfKeags
lnwire: convert DynPropose and DynCommit to use typed tlv records
Pull Request #9148: DynComms [2/n]: lnwire: add authenticated wire messages for Dyn*

142 of 177 new or added lines in 4 files covered. (80.23%)

18983 existing lines in 242 files now uncovered.

99003 of 171143 relevant lines covered (57.85%)

36968.25 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:lll
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