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

lightningnetwork / lnd / 15736109134

18 Jun 2025 02:46PM UTC coverage: 58.197% (-10.1%) from 68.248%
15736109134

Pull #9752

github

web-flow
Merge d2634a68c into 31c74f20f
Pull Request #9752: routerrpc: reject payment to invoice that don't have payment secret or blinded paths

6 of 13 new or added lines in 2 files covered. (46.15%)

28331 existing lines in 455 files now uncovered.

97860 of 168153 relevant lines covered (58.2%)

1.81 hits per line

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

47.5
/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 {
3✔
28
        switch a {
3✔
29
        case resultInvalidAccept:
×
30
                return "invalid accept result"
×
31

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

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

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

41
        case resultPartialAccepted:
3✔
42
                return "partial payment accepted"
3✔
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
        // ExternalValidationFailed is returned when the external validation
125
        // failed.
126
        ExternalValidationFailed
127
)
128

129
// String returns a string representation of the result.
130
func (f FailResolutionResult) String() string {
3✔
131
        return f.FailureString()
3✔
132
}
3✔
133

134
// FailureString returns a string representation of the result.
135
//
136
// Note: it is part of the FailureDetail interface.
137
func (f FailResolutionResult) FailureString() string {
3✔
138
        switch f {
3✔
139
        case resultInvalidFailure:
×
140
                return "invalid failure result"
×
141

142
        case ResultReplayToCanceled:
3✔
143
                return "replayed htlc to canceled invoice"
3✔
144

UNCOV
145
        case ResultInvoiceAlreadyCanceled:
×
UNCOV
146
                return "invoice already canceled"
×
147

148
        case ResultInvoiceAlreadySettled:
×
149
                return "invoice already settled"
×
150

151
        case ResultAmountTooLow:
3✔
152
                return "amount too low"
3✔
153

UNCOV
154
        case ResultExpiryTooSoon:
×
UNCOV
155
                return "expiry too soon"
×
156

157
        case ResultCanceled:
3✔
158
                return "canceled"
3✔
159

160
        case ResultInvoiceNotOpen:
×
161
                return "invoice no longer open"
×
162

163
        case ResultMppTimeout:
×
164
                return "mpp timeout"
×
165

166
        case ResultAddressMismatch:
3✔
167
                return "payment address mismatch"
3✔
168

169
        case ResultHtlcSetTotalMismatch:
×
170
                return "htlc total amt doesn't match set total"
×
171

172
        case ResultHtlcSetTotalTooLow:
×
173
                return "set total too low for invoice"
×
174

175
        case ResultHtlcSetOverpayment:
×
176
                return "mpp is overpaying set total"
×
177

178
        case ResultInvoiceNotFound:
3✔
179
                return "invoice not found"
3✔
180

181
        case ResultKeySendError:
×
182
                return "invalid keysend parameters"
×
183

184
        case ResultMppInProgress:
×
185
                return "mpp reception in progress"
×
186

187
        case ResultHtlcInvoiceTypeMismatch:
×
188
                return "htlc invoice type mismatch"
×
189

190
        case ResultAmpError:
×
191
                return "invalid amp parameters"
×
192

UNCOV
193
        case ResultAmpReconstruction:
×
UNCOV
194
                return "amp reconstruction failed"
×
195

196
        case ExternalValidationFailed:
3✔
197
                return "external validation failed"
3✔
198

199
        default:
×
200
                return "unknown failure resolution result"
×
201
        }
202
}
203

204
// IsSetFailure returns true if this failure should result in the entire HTLC
205
// set being failed with the same result.
206
func (f FailResolutionResult) IsSetFailure() bool {
3✔
207
        switch f {
3✔
208
        case
209
                ResultAmpReconstruction,
210
                ResultHtlcSetTotalTooLow,
211
                ResultHtlcSetTotalMismatch,
212
                ResultHtlcSetOverpayment,
213
                ExternalValidationFailed:
3✔
214

3✔
215
                return true
3✔
216

217
        default:
3✔
218
                return false
3✔
219
        }
220
}
221

222
// SettleResolutionResult provides metadata which about a htlc that was failed
223
// by the registry. It can be used to take custom actions on resolution of the
224
// htlc.
225
type SettleResolutionResult uint8
226

227
const (
228
        resultInvalidSettle SettleResolutionResult = iota
229

230
        // ResultSettled is returned when we settle an invoice.
231
        ResultSettled
232

233
        // ResultReplayToSettled is returned when we replay a settled invoice.
234
        ResultReplayToSettled
235

236
        // ResultDuplicateToSettled is returned when we settle an invoice which
237
        // has already been settled at least once.
238
        ResultDuplicateToSettled
239
)
240

241
// String returns a string representation of the result.
242
func (s SettleResolutionResult) String() string {
3✔
243
        switch s {
3✔
244
        case resultInvalidSettle:
×
245
                return "invalid settle result"
×
246

247
        case ResultSettled:
3✔
248
                return "settled"
3✔
249

250
        case ResultReplayToSettled:
3✔
251
                return "replayed htlc to settled invoice"
3✔
252

UNCOV
253
        case ResultDuplicateToSettled:
×
UNCOV
254
                return "accepting duplicate payment to settled invoice"
×
255

256
        default:
×
257
                return "unknown settle resolution result"
×
258
        }
259
}
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