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

lightningnetwork / lnd / 13440912774

20 Feb 2025 05:14PM UTC coverage: 57.697% (-1.1%) from 58.802%
13440912774

Pull #9535

github

guggero
GitHub: remove duplicate caching

Turns out that actions/setup-go starting with @v4 also adds caching.
With that, our cache size on disk has almost doubled, leading to the
GitHub runner running out of space in certain situation.
We fix that by disabling the automated caching since we already have our
own, custom-tailored version.
Pull Request #9535: GitHub: remove duplicate caching

103519 of 179417 relevant lines covered (57.7%)

24825.3 hits per line

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

68.57
/contractcourt/htlc_lease_resolver.go
1
package contractcourt
2

3
import (
4
        "github.com/btcsuite/btcd/wire"
5
        "github.com/lightningnetwork/lnd/chainntnfs"
6
        "github.com/lightningnetwork/lnd/channeldb"
7
        "github.com/lightningnetwork/lnd/fn/v2"
8
        "github.com/lightningnetwork/lnd/input"
9
        "github.com/lightningnetwork/lnd/tlv"
10
)
11

12
// htlcLeaseResolver is a struct that houses the lease specific HTLC resolution
13
// logic. This includes deriving the _true_ waiting height, as well as the
14
// input to offer to the sweeper.
15
type htlcLeaseResolver struct {
16
        // channelInitiator denotes whether the party responsible for resolving
17
        // the contract initiated the channel.
18
        channelInitiator bool
19

20
        // leaseExpiry denotes the additional waiting period the contract must
21
        // hold until it can be resolved. This waiting period is known as the
22
        // expiration of a script-enforced leased channel and only applies to
23
        // the channel initiator.
24
        //
25
        // NOTE: This value should only be set when the contract belongs to a
26
        // leased channel.
27
        leaseExpiry uint32
28
}
29

30
// hasCLTV denotes whether the resolver must wait for an additional CLTV to
31
// expire before resolving the contract.
32
func (h *htlcLeaseResolver) hasCLTV() bool {
12✔
33
        return h.channelInitiator && h.leaseExpiry > 0
12✔
34
}
12✔
35

36
// deriveWaitHeight computes the height the resolver needs to wait until it can
37
// sweep the input.
38
func (h *htlcLeaseResolver) deriveWaitHeight(csvDelay uint32,
39
        commitSpend *chainntnfs.SpendDetail) uint32 {
4✔
40

4✔
41
        waitHeight := uint32(commitSpend.SpendingHeight) + csvDelay - 1
4✔
42
        if h.hasCLTV() {
4✔
43
                waitHeight = max(waitHeight, h.leaseExpiry)
×
44
        }
×
45

46
        return waitHeight
4✔
47
}
48

49
// makeSweepInput constructs the type of input (either just csv or csv+ctlv) to
50
// send to the sweeper so the output can ultimately be swept.
51
func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
52
        wType, cltvWtype input.StandardWitnessType,
53
        signDesc *input.SignDescriptor, csvDelay, broadcastHeight uint32,
54
        payHash [32]byte, resBlob fn.Option[tlv.Blob]) *input.BaseInput {
4✔
55

4✔
56
        log.Infof("%T(%x): offering second-layer output to sweeper: %v", h,
4✔
57
                payHash, op)
4✔
58

4✔
59
        if h.hasCLTV() {
4✔
60
                return input.NewCsvInputWithCltv(
×
61
                        op, cltvWtype, signDesc,
×
62
                        broadcastHeight, csvDelay,
×
63
                        h.leaseExpiry,
×
64
                        input.WithResolutionBlob(resBlob),
×
65
                )
×
66
        }
×
67

68
        log.Infof("%T(%x): CSV lock expired, offering second-layer output to "+
4✔
69
                "sweeper: %v", h, payHash, op)
4✔
70

4✔
71
        return input.NewCsvInput(
4✔
72
                op, wType, signDesc, broadcastHeight, csvDelay,
4✔
73
                input.WithResolutionBlob(resBlob),
4✔
74
        )
4✔
75
}
76

77
// SupplementState allows the user of a ContractResolver to supplement it with
78
// state required for the proper resolution of a contract.
79
//
80
// NOTE: Part of the ContractResolver interface.
81
func (h *htlcLeaseResolver) SupplementState(state *channeldb.OpenChannel) {
2✔
82
        if state.ChanType.HasLeaseExpiration() {
2✔
83
                h.leaseExpiry = state.ThawHeight
×
84
        }
×
85
        h.channelInitiator = state.IsInitiator
2✔
86
}
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