• 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

51.28
/invoices/resolution_result.go
1
package invoices
2

3
// acceptResolutionResult provides metadata which about a htlc that was
4
// accepted by the registry.
5
type acceptResolutionResult uint8
6

7
const (
8
        resultInvalidAccept acceptResolutionResult = iota
9

10
        // resultReplayToAccepted is returned when we replay an accepted
11
        // invoice.
12
        resultReplayToAccepted
13

14
        // resultDuplicateToAccepted is returned when we accept a duplicate
15
        // htlc.
16
        resultDuplicateToAccepted
17

18
        // resultAccepted is returned when we accept a hodl invoice.
19
        resultAccepted
20

21
        // resultPartialAccepted is returned when we have partially received
22
        // payment.
23
        resultPartialAccepted
24
)
25

26
// String returns a string representation of the result.
27
func (a acceptResolutionResult) String() string {
419✔
28
        switch a {
419✔
29
        case resultInvalidAccept:
×
30
                return "invalid accept result"
×
31

32
        case resultReplayToAccepted:
7✔
33
                return "replayed htlc to accepted invoice"
7✔
34

35
        case resultDuplicateToAccepted:
×
36
                return "accepting duplicate payment to accepted invoice"
×
37

38
        case resultAccepted:
82✔
39
                return "accepted"
82✔
40

41
        case resultPartialAccepted:
330✔
42
                return "partial payment accepted"
330✔
43

44
        default:
×
45
                return "unknown accept resolution result"
×
46
        }
47
}
48

49
// FailResolutionResult provides metadata about a htlc that was failed by
50
// the registry. It can be used to take custom actions on resolution of the
51
// htlc.
52
type FailResolutionResult uint8
53

54
const (
55
        resultInvalidFailure FailResolutionResult = iota
56

57
        // ResultReplayToCanceled is returned when we replay a canceled invoice.
58
        ResultReplayToCanceled
59

60
        // ResultInvoiceAlreadyCanceled is returned when trying to pay an
61
        // invoice that is already canceled.
62
        ResultInvoiceAlreadyCanceled
63

64
        // ResultInvoiceAlreadySettled is returned when trying to pay an invoice
65
        // that is already settled.
66
        ResultInvoiceAlreadySettled
67

68
        // ResultAmountTooLow is returned when an invoice is underpaid.
69
        ResultAmountTooLow
70

71
        // ResultExpiryTooSoon is returned when we do not accept an invoice
72
        // payment because it expires too soon.
73
        ResultExpiryTooSoon
74

75
        // ResultCanceled is returned when we cancel an invoice and its
76
        // associated htlcs.
77
        ResultCanceled
78

79
        // ResultInvoiceNotOpen is returned when a mpp invoice is not open.
80
        ResultInvoiceNotOpen
81

82
        // ResultMppTimeout is returned when an invoice paid with multiple
83
        // partial payments times out before it is fully paid.
84
        ResultMppTimeout
85

86
        // ResultAddressMismatch is returned when the payment address for a mpp
87
        // invoice does not match.
88
        ResultAddressMismatch
89

90
        // ResultHtlcSetTotalMismatch is returned when the amount paid by a
91
        // htlc does not match its set total.
92
        ResultHtlcSetTotalMismatch
93

94
        // ResultHtlcSetTotalTooLow is returned when a mpp set total is too low
95
        // for an invoice.
96
        ResultHtlcSetTotalTooLow
97

98
        // ResultHtlcSetOverpayment is returned when a mpp set is overpaid.
99
        ResultHtlcSetOverpayment
100

101
        // ResultInvoiceNotFound is returned when an attempt is made to pay an
102
        // invoice that is unknown to us.
103
        ResultInvoiceNotFound
104

105
        // ResultKeySendError is returned when we receive invalid keysend
106
        // parameters.
107
        ResultKeySendError
108

109
        // ResultMppInProgress is returned when we are busy receiving a mpp
110
        // payment.
111
        ResultMppInProgress
112

113
        // ResultHtlcInvoiceTypeMismatch is returned when an AMP HTLC targets a
114
        // non-AMP invoice and vice versa.
115
        ResultHtlcInvoiceTypeMismatch
116

117
        // ResultAmpError is returned when we receive invalid AMP parameters.
118
        ResultAmpError
119

120
        // ResultAmpReconstruction is returned when the derived child
121
        // hash/preimage pairs were invalid for at least one HTLC in the set.
122
        ResultAmpReconstruction
123
)
124

125
// String returns a string representation of the result.
126
func (f FailResolutionResult) String() string {
26✔
127
        return f.FailureString()
26✔
128
}
26✔
129

130
// FailureString returns a string representation of the result.
131
//
132
// Note: it is part of the FailureDetail interface.
133
func (f FailResolutionResult) FailureString() string {
26✔
134
        switch f {
26✔
135
        case resultInvalidFailure:
×
136
                return "invalid failure result"
×
137

138
        case ResultReplayToCanceled:
3✔
139
                return "replayed htlc to canceled invoice"
3✔
140

141
        case ResultInvoiceAlreadyCanceled:
4✔
142
                return "invoice already canceled"
4✔
143

144
        case ResultInvoiceAlreadySettled:
×
145
                return "invoice already settled"
×
146

147
        case ResultAmountTooLow:
3✔
148
                return "amount too low"
3✔
149

150
        case ResultExpiryTooSoon:
7✔
151
                return "expiry too soon"
7✔
152

UNCOV
153
        case ResultCanceled:
×
UNCOV
154
                return "canceled"
×
155

156
        case ResultInvoiceNotOpen:
×
157
                return "invoice no longer open"
×
158

159
        case ResultMppTimeout:
×
160
                return "mpp timeout"
×
161

162
        case ResultAddressMismatch:
3✔
163
                return "payment address mismatch"
3✔
164

165
        case ResultHtlcSetTotalMismatch:
×
166
                return "htlc total amt doesn't match set total"
×
167

168
        case ResultHtlcSetTotalTooLow:
×
169
                return "set total too low for invoice"
×
170

171
        case ResultHtlcSetOverpayment:
×
172
                return "mpp is overpaying set total"
×
173

UNCOV
174
        case ResultInvoiceNotFound:
×
UNCOV
175
                return "invoice not found"
×
176

177
        case ResultKeySendError:
×
178
                return "invalid keysend parameters"
×
179

180
        case ResultMppInProgress:
×
181
                return "mpp reception in progress"
×
182

183
        case ResultHtlcInvoiceTypeMismatch:
×
184
                return "htlc invoice type mismatch"
×
185

186
        case ResultAmpError:
×
187
                return "invalid amp parameters"
×
188

189
        case ResultAmpReconstruction:
6✔
190
                return "amp reconstruction failed"
6✔
191

192
        default:
×
193
                return "unknown failure resolution result"
×
194
        }
195
}
196

197
// IsSetFailure returns true if this failure should result in the entire HTLC
198
// set being failed with the same result.
199
func (f FailResolutionResult) IsSetFailure() bool {
26✔
200
        switch f {
26✔
201
        case
202
                ResultAmpReconstruction,
203
                ResultHtlcSetTotalTooLow,
204
                ResultHtlcSetTotalMismatch,
205
                ResultHtlcSetOverpayment:
6✔
206

6✔
207
                return true
6✔
208

209
        default:
20✔
210
                return false
20✔
211
        }
212
}
213

214
// SettleResolutionResult provides metadata which about a htlc that was failed
215
// by the registry. It can be used to take custom actions on resolution of the
216
// htlc.
217
type SettleResolutionResult uint8
218

219
const (
220
        resultInvalidSettle SettleResolutionResult = iota
221

222
        // ResultSettled is returned when we settle an invoice.
223
        ResultSettled
224

225
        // ResultReplayToSettled is returned when we replay a settled invoice.
226
        ResultReplayToSettled
227

228
        // ResultDuplicateToSettled is returned when we settle an invoice which
229
        // has already been settled at least once.
230
        ResultDuplicateToSettled
231
)
232

233
// String returns a string representation of the result.
234
func (s SettleResolutionResult) String() string {
473✔
235
        switch s {
473✔
236
        case resultInvalidSettle:
×
237
                return "invalid settle result"
×
238

239
        case ResultSettled:
464✔
240
                return "settled"
464✔
241

242
        case ResultReplayToSettled:
6✔
243
                return "replayed htlc to settled invoice"
6✔
244

245
        case ResultDuplicateToSettled:
3✔
246
                return "accepting duplicate payment to settled invoice"
3✔
247

248
        default:
×
249
                return "unknown settle resolution result"
×
250
        }
251
}
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