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

lightningnetwork / lnd / 12312390362

13 Dec 2024 08:44AM UTC coverage: 57.458% (+8.5%) from 48.92%
12312390362

Pull #9343

github

ellemouton
fn: rework the ContextGuard and add tests

In this commit, the ContextGuard struct is re-worked such that the
context that its new main WithCtx method provides is cancelled in sync
with a parent context being cancelled or with it's quit channel being
cancelled. Tests are added to assert the behaviour. In order for the
close of the quit channel to be consistent with the cancelling of the
derived context, the quit channel _must_ be contained internal to the
ContextGuard so that callers are only able to close the channel via the
exposed Quit method which will then take care to first cancel any
derived context that depend on the quit channel before returning.
Pull Request #9343: fn: expand the ContextGuard and add tests

101853 of 177264 relevant lines covered (57.46%)

24972.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lncfg/invoices.go
1
package lncfg
2

3
const (
4
        // DefaultHoldInvoiceExpiryDelta defines the number of blocks before the
5
        // expiry height of a hold invoice's htlc that lnd will automatically
6
        // cancel the invoice to prevent the channel from force closing. This
7
        // value *must* be greater than DefaultIncomingBroadcastDelta to prevent
8
        // force closes.
9
        DefaultHoldInvoiceExpiryDelta = DefaultIncomingBroadcastDelta + 2
10

11
        // DefaultMinNumRealBlindedPathHops is the minimum number of _real_
12
        // hops to include in a blinded payment path. This doesn't include our
13
        // node (the destination node), so if the minimum is 1, then the path
14
        // will contain at minimum our node along with an introduction node hop.
15
        DefaultMinNumRealBlindedPathHops = 1
16

17
        // DefaultNumBlindedPathHops is the number of hops to include in a
18
        // blinded payment path. If paths shorter than this number are found,
19
        // then dummy hops are used to pad the path to this length.
20
        DefaultNumBlindedPathHops = 2
21

22
        // DefaultMaxNumBlindedPaths is the maximum number of different blinded
23
        // payment paths to include in an invoice.
24
        DefaultMaxNumBlindedPaths = 3
25

26
        // DefaultBlindedPathPolicyIncreaseMultiplier is the default multiplier
27
        // used to increase certain blinded hop policy values in order to add
28
        // a probing buffer.
29
        DefaultBlindedPathPolicyIncreaseMultiplier = 1.1
30

31
        // DefaultBlindedPathPolicyDecreaseMultiplier is the default multiplier
32
        // used to decrease certain blinded hop policy values in order to add a
33
        // probing buffer.
34
        DefaultBlindedPathPolicyDecreaseMultiplier = 0.9
35
)
36

37
// Invoices holds the configuration options for invoices.
38
//
39
//nolint:ll
40
type Invoices struct {
41
        HoldExpiryDelta uint32 `long:"holdexpirydelta" description:"The number of blocks before a hold invoice's htlc expires that the invoice should be canceled to prevent a force close. Force closes will not be prevented if this value is not greater than DefaultIncomingBroadcastDelta."`
42
}
43

44
// Validate checks that the various invoice config options are sane.
45
//
46
// NOTE: this is part of the Validator interface.
47
func (i *Invoices) Validate() error {
×
48
        // Log a warning if our expiry delta is not greater than our incoming
×
49
        // broadcast delta. We do not fail here because this value may be set
×
50
        // to zero to intentionally keep lnd's behavior unchanged from when we
×
51
        // didn't auto-cancel these invoices.
×
52
        if i.HoldExpiryDelta <= DefaultIncomingBroadcastDelta {
×
53
                log.Warnf("Invoice hold expiry delta: %v <= incoming "+
×
54
                        "delta: %v, accepted hold invoices will force close "+
×
55
                        "channels if they are not canceled manually",
×
56
                        i.HoldExpiryDelta, DefaultIncomingBroadcastDelta)
×
57
        }
×
58

59
        return nil
×
60
}
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