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

lightningnetwork / lnd / 13536249039

26 Feb 2025 03:42AM UTC coverage: 57.462% (-1.4%) from 58.835%
13536249039

Pull #8453

github

Roasbeef
peer: update chooseDeliveryScript to gen script if needed

In this commit, we update `chooseDeliveryScript` to generate a new
script if needed. This allows us to fold in a few other lines that
always followed this function into this expanded function.

The tests have been updated accordingly.
Pull Request #8453: [4/4] - multi: integrate new rbf coop close FSM into the existing peer flow

275 of 1318 new or added lines in 22 files covered. (20.86%)

19521 existing lines in 257 files now uncovered.

103858 of 180741 relevant lines covered (57.46%)

24750.23 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