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

lightningnetwork / lnd / 12293715361

12 Dec 2024 09:38AM UTC coverage: 57.483% (+7.9%) from 49.538%
12293715361

Pull #9348

github

ziggie1984
github: update goveralls tool

The goverall tool had a bug regarding the module versioning of
golang packages see also
https://github.com/mattn/goveralls/pull/222 for more background.
Goveralls is wrapped by another library to make it available for
github actions. So the relevant PR which is referenced here in
LND is:
https://github.com/shogo82148/actions-goveralls/pull/521.
Pull Request #9348: github: update goveralls tool

101897 of 177264 relevant lines covered (57.48%)

24982.4 hits per line

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

56.76
/contractcourt/htlc_lease_resolver.go
1
package contractcourt
2

3
import (
4
        "math"
5

6
        "github.com/btcsuite/btcd/wire"
7
        "github.com/lightningnetwork/lnd/chainntnfs"
8
        "github.com/lightningnetwork/lnd/channeldb"
9
        "github.com/lightningnetwork/lnd/fn/v2"
10
        "github.com/lightningnetwork/lnd/input"
11
        "github.com/lightningnetwork/lnd/tlv"
12
)
13

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

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

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

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

4✔
43
        waitHeight := uint32(commitSpend.SpendingHeight) + csvDelay - 1
4✔
44
        if h.hasCLTV() {
4✔
45
                waitHeight = uint32(math.Max(
×
46
                        float64(waitHeight), float64(h.leaseExpiry),
×
47
                ))
×
48
        }
×
49

50
        return waitHeight
4✔
51
}
52

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

4✔
60
        if h.hasCLTV() {
4✔
61
                log.Infof("%T(%x): CSV and CLTV locks expired, offering "+
×
62
                        "second-layer output to sweeper: %v", h, payHash, op)
×
63

×
64
                return input.NewCsvInputWithCltv(
×
65
                        op, cltvWtype, signDesc,
×
66
                        broadcastHeight, csvDelay,
×
67
                        h.leaseExpiry,
×
68
                        input.WithResolutionBlob(resBlob),
×
69
                )
×
70
        }
×
71

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

4✔
75
        return input.NewCsvInput(
4✔
76
                op, wType, signDesc, broadcastHeight, csvDelay,
4✔
77
                input.WithResolutionBlob(resBlob),
4✔
78
        )
4✔
79
}
80

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