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

lightningnetwork / lnd / 12343072627

15 Dec 2024 11:09PM UTC coverage: 57.504% (-1.1%) from 58.636%
12343072627

Pull #9315

github

yyforyongyu
contractcourt: offer outgoing htlc one block earlier before its expiry

We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
Pull Request #9315: Implement `blockbeat`

1445 of 2007 new or added lines in 26 files covered. (72.0%)

19246 existing lines in 249 files now uncovered.

102342 of 177975 relevant lines covered (57.5%)

24772.24 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