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

lightningnetwork / lnd / 12115442155

02 Dec 2024 08:28AM UTC coverage: 48.662% (-10.3%) from 58.948%
12115442155

Pull #9175

github

ellemouton
netann: update ChanAnn2 validation to work for P2WSH channels

This commit expands the ChannelAnnouncement2 validation for the case
where it is announcing a P2WSH channel.
Pull Request #9175: lnwire+netann: update structure of g175 messages to be pure TLV

6 of 314 new or added lines in 9 files covered. (1.91%)

27532 existing lines in 434 files now uncovered.

97890 of 201164 relevant lines covered (48.66%)

0.52 hits per line

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

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

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

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

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

41
        case resultPartialAccepted:
1✔
42
                return "partial payment accepted"
1✔
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 {
1✔
127
        return f.FailureString()
1✔
128
}
1✔
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 {
1✔
134
        switch f {
1✔
135
        case resultInvalidFailure:
×
136
                return "invalid failure result"
×
137

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

UNCOV
141
        case ResultInvoiceAlreadyCanceled:
×
UNCOV
142
                return "invoice already canceled"
×
143

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

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

UNCOV
150
        case ResultExpiryTooSoon:
×
UNCOV
151
                return "expiry too soon"
×
152

153
        case ResultCanceled:
1✔
154
                return "canceled"
1✔
155

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

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

UNCOV
162
        case ResultAddressMismatch:
×
UNCOV
163
                return "payment address mismatch"
×
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

174
        case ResultInvoiceNotFound:
1✔
175
                return "invoice not found"
1✔
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

UNCOV
189
        case ResultAmpReconstruction:
×
UNCOV
190
                return "amp reconstruction failed"
×
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 {
1✔
200
        switch f {
1✔
201
        case
202
                ResultAmpReconstruction,
203
                ResultHtlcSetTotalTooLow,
204
                ResultHtlcSetTotalMismatch,
UNCOV
205
                ResultHtlcSetOverpayment:
×
UNCOV
206

×
UNCOV
207
                return true
×
208

209
        default:
1✔
210
                return false
1✔
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 {
1✔
235
        switch s {
1✔
236
        case resultInvalidSettle:
×
237
                return "invalid settle result"
×
238

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

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

UNCOV
245
        case ResultDuplicateToSettled:
×
UNCOV
246
                return "accepting duplicate payment to settled invoice"
×
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