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

lightningnetwork / lnd / 12986279612

27 Jan 2025 09:51AM UTC coverage: 57.652% (-1.1%) from 58.788%
12986279612

Pull #9447

github

yyforyongyu
sweep: rename methods for clarity

We now rename "third party" to "unknown" as the inputs can be spent via
an older sweeping tx, a third party (anchor), or a remote party (pin).
In fee bumper we don't have the info to distinguish the above cases, and
leave them to be further handled by the sweeper as it has more context.
Pull Request #9447: sweep: start tracking input spending status in the fee bumper

83 of 87 new or added lines in 2 files covered. (95.4%)

19578 existing lines in 256 files now uncovered.

103448 of 179434 relevant lines covered (57.65%)

24884.58 hits per line

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

34.69
/htlcswitch/hodl/flags.go
1
package hodl
2

3
import "fmt"
4

5
// MaskNone represents the empty Mask, in which no breakpoints are
6
// active.
7
const MaskNone = Mask(0)
8

9
type (
10
        // Flag represents a single breakpoint where an HTLC should be dropped
11
        // during forwarding. Flags can be composed into a Mask to express more
12
        // complex combinations.
13
        Flag uint32
14

15
        // Mask is a bitvector combining multiple Flags that can be queried to
16
        // see which breakpoints are active.
17
        Mask uint32
18
)
19

20
const (
21
        // ExitSettle drops an incoming ADD for which we are the exit node,
22
        // before processing in the link.
23
        ExitSettle Flag = 1 << iota
24

25
        // AddIncoming drops an incoming ADD before processing if we are not
26
        // the exit node.
27
        AddIncoming
28

29
        // SettleIncoming drops an incoming SETTLE before processing if we
30
        // are not the exit node.
31
        SettleIncoming
32

33
        // FailIncoming drops an incoming FAIL before processing if we are
34
        // not the exit node.
35
        FailIncoming
36

37
        // TODO(conner): add  modes for switch breakpoints
38

39
        // AddOutgoing drops an outgoing ADD before it is added to the
40
        // in-memory commitment state of the link.
41
        AddOutgoing
42

43
        // SettleOutgoing drops an SETTLE before it is added to the
44
        // in-memory commitment state of the link.
45
        SettleOutgoing
46

47
        // FailOutgoing drops an outgoing FAIL before is is added to the
48
        // in-memory commitment state of the link.
49
        FailOutgoing
50

51
        // Commit drops all HTLC after any outgoing circuits have been
52
        // opened, but before the in-memory commitment state is persisted.
53
        Commit
54

55
        // BogusSettle attempts to settle back any incoming HTLC for which we
56
        // are the exit node with a bogus preimage.
57
        BogusSettle
58
)
59

60
// String returns a human-readable identifier for a given Flag.
61
func (f Flag) String() string {
111✔
62
        switch f {
111✔
63
        case ExitSettle:
107✔
64
                return "ExitSettle"
107✔
65
        case AddIncoming:
×
66
                return "AddIncoming"
×
67
        case SettleIncoming:
×
68
                return "SettleIncoming"
×
69
        case FailIncoming:
×
70
                return "FailIncoming"
×
71
        case AddOutgoing:
×
72
                return "AddOutgoing"
×
73
        case SettleOutgoing:
×
74
                return "SettleOutgoing"
×
75
        case FailOutgoing:
×
76
                return "FailOutgoing"
×
77
        case Commit:
4✔
78
                return "Commit"
4✔
UNCOV
79
        case BogusSettle:
×
UNCOV
80
                return "BogusSettle"
×
81
        default:
×
82
                return "UnknownHodlFlag"
×
83
        }
84
}
85

86
// Warning generates a warning message to log if a particular breakpoint is
87
// triggered during execution.
88
func (f Flag) Warning() string {
111✔
89
        var msg string
111✔
90
        switch f {
111✔
91
        case ExitSettle:
107✔
92
                msg = "will not attempt to settle ADD with sender"
107✔
93
        case AddIncoming:
×
94
                msg = "will not attempt to forward ADD to switch"
×
95
        case SettleIncoming:
×
96
                msg = "will not attempt to forward SETTLE to switch"
×
97
        case FailIncoming:
×
98
                msg = "will not attempt to forward FAIL to switch"
×
99
        case AddOutgoing:
×
100
                msg = "will not update channel state with downstream ADD"
×
101
        case SettleOutgoing:
×
102
                msg = "will not update channel state with downstream SETTLE"
×
103
        case FailOutgoing:
×
104
                msg = "will not update channel state with downstream FAIL"
×
105
        case Commit:
4✔
106
                msg = "will not commit pending channel updates"
4✔
UNCOV
107
        case BogusSettle:
×
UNCOV
108
                msg = "will settle HTLC with bogus preimage"
×
109
        default:
×
110
                msg = "incorrect hodl flag usage"
×
111
        }
112

113
        return fmt.Sprintf("%s mode enabled -- %s", f, msg)
111✔
114
}
115

116
// Mask returns the Mask consisting solely of this Flag.
117
func (f Flag) Mask() Mask {
5✔
118
        return Mask(f)
5✔
119
}
5✔
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