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

lightningnetwork / lnd / 12453190405

22 Dec 2024 12:46AM UTC coverage: 58.705% (+0.1%) from 58.598%
12453190405

Pull #8582

github

ziggie1984
docs: update release-docs
Pull Request #8582: set dont forward bit in chanupdate msg for private channels

340 of 432 new or added lines in 10 files covered. (78.7%)

60 existing lines in 11 files now uncovered.

135401 of 230646 relevant lines covered (58.71%)

19113.28 hits per line

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

90.14
/contractcourt/breach_resolver.go
1
package contractcourt
2

3
import (
4
        "encoding/binary"
5
        "io"
6

7
        "github.com/lightningnetwork/lnd/channeldb"
8
)
9

10
// breachResolver is a resolver that will handle breached closes. In the
11
// future, this will likely take over the duties the current BreachArbitrator
12
// has.
13
type breachResolver struct {
14
        // resolved reflects if the contract has been fully resolved or not.
15
        resolved bool
16

17
        // subscribed denotes whether or not the breach resolver has subscribed
18
        // to the BreachArbitrator for breach resolution.
19
        subscribed bool
20

21
        // replyChan is closed when the breach arbiter has completed serving
22
        // justice.
23
        replyChan chan struct{}
24

25
        contractResolverKit
26
}
27

5✔
28
// newBreachResolver instantiates a new breach resolver.
5✔
29
func newBreachResolver(resCfg ResolverConfig) *breachResolver {
5✔
30
        r := &breachResolver{
5✔
31
                contractResolverKit: *newContractResolverKit(resCfg),
5✔
32
                replyChan:           make(chan struct{}),
5✔
33
        }
5✔
34

5✔
35
        r.initLogger(r)
5✔
36

5✔
37
        return r
38
}
39

7✔
40
// ResolverKey returns the unique identifier for this resolver.
7✔
41
func (b *breachResolver) ResolverKey() []byte {
7✔
42
        key := newResolverID(b.ChanPoint)
7✔
43
        return key[:]
44
}
45

46
// Resolve queries the BreachArbitrator to see if the justice transaction has
47
// been broadcast.
48
//
49
// TODO(yy): let sweeper handle the breach inputs.
50
func (b *breachResolver) Resolve(_ bool) (ContractResolver, error) {
5✔
51
        if !b.subscribed {
10✔
52
                complete, err := b.SubscribeBreachComplete(
5✔
53
                        &b.ChanPoint, b.replyChan,
5✔
54
                )
5✔
55
                if err != nil {
5✔
56
                        return nil, err
×
57
                }
×
58

59
                // If the breach resolution process is already complete, then
60
                // we can cleanup and checkpoint the resolved state.
61
                if complete {
5✔
UNCOV
62
                        b.resolved = true
×
UNCOV
63
                        return nil, b.Checkpoint(b)
×
UNCOV
64
                }
×
65

66
                // Prevent duplicate subscriptions.
67
                b.subscribed = true
5✔
68
        }
69

70
        select {
5✔
71
        case <-b.replyChan:
5✔
72
                // The replyChan has been closed, signalling that the breach
5✔
73
                // has been fully resolved. Checkpoint the resolved state and
5✔
74
                // exit.
5✔
75
                b.resolved = true
5✔
76
                return nil, b.Checkpoint(b)
5✔
77
        case <-b.quit:
78
        }
3✔
79

80
        return nil, errResolverShuttingDown
81
}
3✔
82

83
// Stop signals the breachResolver to stop.
84
func (b *breachResolver) Stop() {
85
        close(b.quit)
5✔
86
}
5✔
87

5✔
88
// IsResolved returns true if the breachResolver is fully resolved and cleanup
5✔
89
// can occur.
90
func (b *breachResolver) IsResolved() bool {
91
        return b.resolved
3✔
92
}
3✔
93

94
// SupplementState adds additional state to the breachResolver.
95
func (b *breachResolver) SupplementState(_ *channeldb.OpenChannel) {
3✔
96
}
3✔
97

3✔
98
// Encode encodes the breachResolver to the passed writer.
99
func (b *breachResolver) Encode(w io.Writer) error {
100
        return binary.Write(w, endian, b.resolved)
101
}
102

3✔
103
// newBreachResolverFromReader attempts to decode an encoded breachResolver
3✔
104
// from the passed Reader instance, returning an active breachResolver.
3✔
105
func newBreachResolverFromReader(r io.Reader, resCfg ResolverConfig) (
3✔
106
        *breachResolver, error) {
3✔
107

3✔
108
        b := &breachResolver{
3✔
109
                contractResolverKit: *newContractResolverKit(resCfg),
3✔
110
                replyChan:           make(chan struct{}),
3✔
111
        }
×
112

×
113
        if err := binary.Read(r, endian, &b.resolved); err != nil {
5✔
114
                return nil, err
2✔
115
        }
2✔
116

117
        b.initLogger(b)
3✔
118

3✔
119
        return b, nil
3✔
120
}
121

122
// A compile time assertion to ensure breachResolver meets the ContractResolver
123
// interface.
124
var _ ContractResolver = (*breachResolver)(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