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

lightningnetwork / lnd / 13236757158

10 Feb 2025 08:39AM UTC coverage: 57.649% (-1.2%) from 58.815%
13236757158

Pull #9493

github

ziggie1984
lncli: for some cmds we don't replace the data of the response.

For some cmds it is not very practical to replace the json output
because we might pipe it into other commands. For example when
creating the route we want to pipe it into sendtoRoute.
Pull Request #9493: For some lncli cmds we should not replace the content with other data

0 of 9 new or added lines in 2 files covered. (0.0%)

19535 existing lines in 252 files now uncovered.

103517 of 179563 relevant lines covered (57.65%)

24878.49 hits per line

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

52.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 {
437✔
28
        switch a {
437✔
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:
348✔
42
                return "partial payment accepted"
348✔
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 {
29✔
131
        return f.FailureString()
29✔
132
}
29✔
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 {
29✔
138
        switch f {
29✔
139
        case resultInvalidFailure:
×
140
                return "invalid failure result"
×
141

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

145
        case ResultInvoiceAlreadyCanceled:
4✔
146
                return "invoice already canceled"
4✔
147

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

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

154
        case ResultExpiryTooSoon:
7✔
155
                return "expiry too soon"
7✔
156

UNCOV
157
        case ResultCanceled:
×
UNCOV
158
                return "canceled"
×
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

UNCOV
178
        case ResultInvoiceNotFound:
×
UNCOV
179
                return "invoice not found"
×
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

193
        case ResultAmpReconstruction:
6✔
194
                return "amp reconstruction failed"
6✔
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 {
29✔
207
        switch f {
29✔
208
        case
209
                ResultAmpReconstruction,
210
                ResultHtlcSetTotalTooLow,
211
                ResultHtlcSetTotalMismatch,
212
                ResultHtlcSetOverpayment,
213
                ExternalValidationFailed:
9✔
214

9✔
215
                return true
9✔
216

217
        default:
20✔
218
                return false
20✔
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 {
473✔
243
        switch s {
473✔
244
        case resultInvalidSettle:
×
245
                return "invalid settle result"
×
246

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

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

253
        case ResultDuplicateToSettled:
3✔
254
                return "accepting duplicate payment to settled invoice"
3✔
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