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

lightningnetwork / lnd / 12425886916

20 Dec 2024 05:06AM UTC coverage: 49.675% (-7.9%) from 57.578%
12425886916

Pull #9227

github

yyforyongyu
lntest+itest: export `DeriveFundingShim`
Pull Request #9227: Beat [5/4]: fix itests for `blockbeat`

45 of 49 new or added lines in 8 files covered. (91.84%)

26491 existing lines in 430 files now uncovered.

101120 of 203562 relevant lines covered (49.68%)

2.06 hits per line

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

78.19
/routing/payment_lifecycle.go
1
package routing
2

3
import (
4
        "context"
5
        "errors"
6
        "fmt"
7
        "time"
8

9
        "github.com/btcsuite/btcd/btcec/v2"
10
        "github.com/davecgh/go-spew/spew"
11
        sphinx "github.com/lightningnetwork/lightning-onion"
12
        "github.com/lightningnetwork/lnd/channeldb"
13
        "github.com/lightningnetwork/lnd/fn/v2"
14
        "github.com/lightningnetwork/lnd/graph/db/models"
15
        "github.com/lightningnetwork/lnd/htlcswitch"
16
        "github.com/lightningnetwork/lnd/lntypes"
17
        "github.com/lightningnetwork/lnd/lnwire"
18
        "github.com/lightningnetwork/lnd/routing/route"
19
        "github.com/lightningnetwork/lnd/routing/shards"
20
        "github.com/lightningnetwork/lnd/tlv"
21
)
22

23
// ErrPaymentLifecycleExiting is used when waiting for htlc attempt result, but
24
// the payment lifecycle is exiting .
25
var ErrPaymentLifecycleExiting = errors.New("payment lifecycle exiting")
26

27
// paymentLifecycle holds all information about the current state of a payment
28
// needed to resume if from any point.
29
type paymentLifecycle struct {
30
        router                *ChannelRouter
31
        feeLimit              lnwire.MilliSatoshi
32
        identifier            lntypes.Hash
33
        paySession            PaymentSession
34
        shardTracker          shards.ShardTracker
35
        currentHeight         int32
36
        firstHopCustomRecords lnwire.CustomRecords
37

38
        // quit is closed to signal the sub goroutines of the payment lifecycle
39
        // to stop.
40
        quit chan struct{}
41

42
        // resultCollected is used to signal that the result of an attempt has
43
        // been collected. A nil error means the attempt is either successful
44
        // or failed with temporary error. Otherwise, we should exit the
45
        // lifecycle loop as a terminal error has occurred.
46
        resultCollected chan error
47

48
        // resultCollector is a function that is used to collect the result of
49
        // an HTLC attempt, which is always mounted to `p.collectResultAsync`
50
        // except in unit test, where we use a much simpler resultCollector to
51
        // decouple the test flow for the payment lifecycle.
52
        resultCollector func(attempt *channeldb.HTLCAttempt)
53
}
54

55
// newPaymentLifecycle initiates a new payment lifecycle and returns it.
56
func newPaymentLifecycle(r *ChannelRouter, feeLimit lnwire.MilliSatoshi,
57
        identifier lntypes.Hash, paySession PaymentSession,
58
        shardTracker shards.ShardTracker, currentHeight int32,
59
        firstHopCustomRecords lnwire.CustomRecords) *paymentLifecycle {
4✔
60

4✔
61
        p := &paymentLifecycle{
4✔
62
                router:                r,
4✔
63
                feeLimit:              feeLimit,
4✔
64
                identifier:            identifier,
4✔
65
                paySession:            paySession,
4✔
66
                shardTracker:          shardTracker,
4✔
67
                currentHeight:         currentHeight,
4✔
68
                quit:                  make(chan struct{}),
4✔
69
                resultCollected:       make(chan error, 1),
4✔
70
                firstHopCustomRecords: firstHopCustomRecords,
4✔
71
        }
4✔
72

4✔
73
        // Mount the result collector.
4✔
74
        p.resultCollector = p.collectResultAsync
4✔
75

4✔
76
        return p
4✔
77
}
4✔
78

79
// calcFeeBudget returns the available fee to be used for sending HTLC
80
// attempts.
81
func (p *paymentLifecycle) calcFeeBudget(
82
        feesPaid lnwire.MilliSatoshi) lnwire.MilliSatoshi {
4✔
83

4✔
84
        budget := p.feeLimit
4✔
85

4✔
86
        // We'll subtract the used fee from our fee budget. In case of
4✔
87
        // overflow, we need to check whether feesPaid exceeds our budget
4✔
88
        // already.
4✔
89
        if feesPaid <= budget {
8✔
90
                budget -= feesPaid
4✔
91
        } else {
8✔
92
                budget = 0
4✔
93
        }
4✔
94

95
        return budget
4✔
96
}
97

98
// stateStep defines an action to be taken in our payment lifecycle. We either
99
// quit, continue, or exit the lifecycle, see details below.
100
type stateStep uint8
101

102
const (
103
        // stepSkip is used when we need to skip the current lifecycle and jump
104
        // to the next one.
105
        stepSkip stateStep = iota
106

107
        // stepProceed is used when we can proceed the current lifecycle.
108
        stepProceed
109

110
        // stepExit is used when we need to quit the current lifecycle.
111
        stepExit
112
)
113

114
// decideNextStep is used to determine the next step in the payment lifecycle.
115
func (p *paymentLifecycle) decideNextStep(
116
        payment DBMPPayment) (stateStep, error) {
4✔
117

4✔
118
        // Check whether we could make new HTLC attempts.
4✔
119
        allow, err := payment.AllowMoreAttempts()
4✔
120
        if err != nil {
4✔
UNCOV
121
                return stepExit, err
×
UNCOV
122
        }
×
123

124
        if !allow {
8✔
125
                // Check whether we need to wait for results.
4✔
126
                wait, err := payment.NeedWaitAttempts()
4✔
127
                if err != nil {
4✔
UNCOV
128
                        return stepExit, err
×
UNCOV
129
                }
×
130

131
                // If we are not allowed to make new HTLC attempts and there's
132
                // no need to wait, the lifecycle is done and we can exit.
133
                if !wait {
8✔
134
                        return stepExit, nil
4✔
135
                }
4✔
136

137
                log.Tracef("Waiting for attempt results for payment %v",
4✔
138
                        p.identifier)
4✔
139

4✔
140
                // Otherwise we wait for one HTLC attempt then continue
4✔
141
                // the lifecycle.
4✔
142
                //
4✔
143
                // NOTE: we don't check `p.quit` since `decideNextStep` is
4✔
144
                // running in the same goroutine as `resumePayment`.
4✔
145
                select {
4✔
146
                case err := <-p.resultCollected:
4✔
147
                        // If an error is returned, exit with it.
4✔
148
                        if err != nil {
8✔
149
                                return stepExit, err
4✔
150
                        }
4✔
151

152
                        log.Tracef("Received attempt result for payment %v",
4✔
153
                                p.identifier)
4✔
154

155
                case <-p.router.quit:
2✔
156
                        return stepExit, ErrRouterShuttingDown
2✔
157
                }
158

159
                return stepSkip, nil
4✔
160
        }
161

162
        // Otherwise we need to make more attempts.
163
        return stepProceed, nil
4✔
164
}
165

166
// resumePayment resumes the paymentLifecycle from the current state.
167
func (p *paymentLifecycle) resumePayment(ctx context.Context) ([32]byte,
168
        *route.Route, error) {
4✔
169

4✔
170
        // When the payment lifecycle loop exits, we make sure to signal any
4✔
171
        // sub goroutine of the HTLC attempt to exit, then wait for them to
4✔
172
        // return.
4✔
173
        defer p.stop()
4✔
174

4✔
175
        // If we had any existing attempts outstanding, we'll start by spinning
4✔
176
        // up goroutines that'll collect their results and deliver them to the
4✔
177
        // lifecycle loop below.
4✔
178
        payment, err := p.router.cfg.Control.FetchPayment(p.identifier)
4✔
179
        if err != nil {
4✔
UNCOV
180
                return [32]byte{}, nil, err
×
UNCOV
181
        }
×
182

183
        for _, a := range payment.InFlightHTLCs() {
8✔
184
                a := a
4✔
185

4✔
186
                log.Infof("Resuming HTLC attempt %v for payment %v",
4✔
187
                        a.AttemptID, p.identifier)
4✔
188

4✔
189
                p.resultCollector(&a)
4✔
190
        }
4✔
191

192
        // Get the payment status.
193
        status := payment.GetStatus()
4✔
194

4✔
195
        // exitWithErr is a helper closure that logs and returns an error.
4✔
196
        exitWithErr := func(err error) ([32]byte, *route.Route, error) {
8✔
197
                // Log an error with the latest payment status.
4✔
198
                //
4✔
199
                // NOTE: this `status` variable is reassigned in the loop
4✔
200
                // below. We could also call `payment.GetStatus` here, but in a
4✔
201
                // rare case when the critical log is triggered when using
4✔
202
                // postgres as db backend, the `payment` could be nil, causing
4✔
203
                // the payment fetching to return an error.
4✔
204
                log.Errorf("Payment %v with status=%v failed: %v", p.identifier,
4✔
205
                        status, err)
4✔
206

4✔
207
                return [32]byte{}, nil, err
4✔
208
        }
4✔
209

210
        // We'll continue until either our payment succeeds, or we encounter a
211
        // critical error during path finding.
212
lifecycle:
4✔
213
        for {
8✔
214
                // We update the payment state on every iteration. Since the
4✔
215
                // payment state is affected by multiple goroutines (ie,
4✔
216
                // collectResultAsync), it is NOT guaranteed that we always
4✔
217
                // have the latest state here. This is fine as long as the
4✔
218
                // state is consistent as a whole.
4✔
219
                payment, err = p.router.cfg.Control.FetchPayment(p.identifier)
4✔
220
                if err != nil {
4✔
221
                        return exitWithErr(err)
×
222
                }
×
223

224
                ps := payment.GetState()
4✔
225
                remainingFees := p.calcFeeBudget(ps.FeesPaid)
4✔
226

4✔
227
                status = payment.GetStatus()
4✔
228
                log.Debugf("Payment %v: status=%v, active_shards=%v, "+
4✔
229
                        "rem_value=%v, fee_limit=%v", p.identifier, status,
4✔
230
                        ps.NumAttemptsInFlight, ps.RemainingAmt, remainingFees)
4✔
231

4✔
232
                // We now proceed our lifecycle with the following tasks in
4✔
233
                // order,
4✔
234
                //   1. check context.
4✔
235
                //   2. request route.
4✔
236
                //   3. create HTLC attempt.
4✔
237
                //   4. send HTLC attempt.
4✔
238
                //   5. collect HTLC attempt result.
4✔
239
                //
4✔
240
                // Before we attempt any new shard, we'll check to see if we've
4✔
241
                // gone past the payment attempt timeout, or if the context was
4✔
242
                // cancelled, or the router is exiting. In any of these cases,
4✔
243
                // we'll stop this payment attempt short.
4✔
244
                if err := p.checkContext(ctx); err != nil {
4✔
UNCOV
245
                        return exitWithErr(err)
×
UNCOV
246
                }
×
247

248
                // Now decide the next step of the current lifecycle.
249
                step, err := p.decideNextStep(payment)
4✔
250
                if err != nil {
8✔
251
                        return exitWithErr(err)
4✔
252
                }
4✔
253

254
                switch step {
4✔
255
                // Exit the for loop and return below.
256
                case stepExit:
4✔
257
                        break lifecycle
4✔
258

259
                // Continue the for loop and skip the rest.
260
                case stepSkip:
4✔
261
                        continue lifecycle
4✔
262

263
                // Continue the for loop and proceed the rest.
264
                case stepProceed:
4✔
265

266
                // Unknown step received, exit with an error.
267
                default:
×
268
                        err = fmt.Errorf("unknown step: %v", step)
×
269
                        return exitWithErr(err)
×
270
                }
271

272
                // Now request a route to be used to create our HTLC attempt.
273
                rt, err := p.requestRoute(ps)
4✔
274
                if err != nil {
4✔
UNCOV
275
                        return exitWithErr(err)
×
UNCOV
276
                }
×
277

278
                // We may not be able to find a route for current attempt. In
279
                // that case, we continue the loop and move straight to the
280
                // next iteration in case there are results for inflight HTLCs
281
                // that still need to be collected.
282
                if rt == nil {
8✔
283
                        log.Errorf("No route found for payment %v",
4✔
284
                                p.identifier)
4✔
285

4✔
286
                        continue lifecycle
4✔
287
                }
288

289
                log.Tracef("Found route: %s", spew.Sdump(rt.Hops))
4✔
290

4✔
291
                // Allow the traffic shaper to add custom records to the
4✔
292
                // outgoing HTLC and also adjust the amount if needed.
4✔
293
                err = p.amendFirstHopData(rt)
4✔
294
                if err != nil {
4✔
295
                        return exitWithErr(err)
×
296
                }
×
297

298
                // We found a route to try, create a new HTLC attempt to try.
299
                attempt, err := p.registerAttempt(rt, ps.RemainingAmt)
4✔
300
                if err != nil {
4✔
UNCOV
301
                        return exitWithErr(err)
×
UNCOV
302
                }
×
303

304
                // Once the attempt is created, send it to the htlcswitch.
305
                result, err := p.sendAttempt(attempt)
4✔
306
                if err != nil {
4✔
UNCOV
307
                        return exitWithErr(err)
×
UNCOV
308
                }
×
309

310
                // Now that the shard was successfully sent, launch a go
311
                // routine that will handle its result when its back.
312
                if result.err == nil {
8✔
313
                        p.resultCollector(attempt)
4✔
314
                }
4✔
315
        }
316

317
        // Once we are out the lifecycle loop, it means we've reached a
318
        // terminal condition. We either return the settled preimage or the
319
        // payment's failure reason.
320
        //
321
        // Optionally delete the failed attempts from the database.
322
        err = p.router.cfg.Control.DeleteFailedAttempts(p.identifier)
4✔
323
        if err != nil {
4✔
324
                log.Errorf("Error deleting failed htlc attempts for payment "+
×
325
                        "%v: %v", p.identifier, err)
×
326
        }
×
327

328
        htlc, failure := payment.TerminalInfo()
4✔
329
        if htlc != nil {
8✔
330
                return htlc.Settle.Preimage, &htlc.Route, nil
4✔
331
        }
4✔
332

333
        // Otherwise return the payment failure reason.
334
        return [32]byte{}, nil, *failure
4✔
335
}
336

337
// checkContext checks whether the payment context has been canceled.
338
// Cancellation occurs manually or if the context times out.
339
func (p *paymentLifecycle) checkContext(ctx context.Context) error {
4✔
340
        select {
4✔
341
        case <-ctx.Done():
4✔
342
                // If the context was canceled, we'll mark the payment as
4✔
343
                // failed. There are two cases to distinguish here: Either a
4✔
344
                // user-provided timeout was reached, or the context was
4✔
345
                // canceled, either to a manual cancellation or due to an
4✔
346
                // unknown error.
4✔
347
                var reason channeldb.FailureReason
4✔
348
                if errors.Is(ctx.Err(), context.DeadlineExceeded) {
4✔
UNCOV
349
                        reason = channeldb.FailureReasonTimeout
×
UNCOV
350
                        log.Warnf("Payment attempt not completed before "+
×
UNCOV
351
                                "timeout, id=%s", p.identifier.String())
×
352
                } else {
4✔
353
                        reason = channeldb.FailureReasonCanceled
4✔
354
                        log.Warnf("Payment attempt context canceled, id=%s",
4✔
355
                                p.identifier.String())
4✔
356
                }
4✔
357

358
                // By marking the payment failed, depending on whether it has
359
                // inflight HTLCs or not, its status will now either be
360
                // `StatusInflight` or `StatusFailed`. In either case, no more
361
                // HTLCs will be attempted.
362
                err := p.router.cfg.Control.FailPayment(p.identifier, reason)
4✔
363
                if err != nil {
4✔
UNCOV
364
                        return fmt.Errorf("FailPayment got %w", err)
×
UNCOV
365
                }
×
366

UNCOV
367
        case <-p.router.quit:
×
UNCOV
368
                return fmt.Errorf("check payment timeout got: %w",
×
UNCOV
369
                        ErrRouterShuttingDown)
×
370

371
        // Fall through if we haven't hit our time limit.
372
        default:
4✔
373
        }
374

375
        return nil
4✔
376
}
377

378
// requestRoute is responsible for finding a route to be used to create an HTLC
379
// attempt.
380
func (p *paymentLifecycle) requestRoute(
381
        ps *channeldb.MPPaymentState) (*route.Route, error) {
4✔
382

4✔
383
        remainingFees := p.calcFeeBudget(ps.FeesPaid)
4✔
384

4✔
385
        // Query our payment session to construct a route.
4✔
386
        rt, err := p.paySession.RequestRoute(
4✔
387
                ps.RemainingAmt, remainingFees,
4✔
388
                uint32(ps.NumAttemptsInFlight), uint32(p.currentHeight),
4✔
389
                p.firstHopCustomRecords,
4✔
390
        )
4✔
391

4✔
392
        // Exit early if there's no error.
4✔
393
        if err == nil {
8✔
394
                return rt, nil
4✔
395
        }
4✔
396

397
        // Otherwise we need to handle the error.
398
        log.Warnf("Failed to find route for payment %v: %v", p.identifier, err)
4✔
399

4✔
400
        // If the error belongs to `noRouteError` set, it means a non-critical
4✔
401
        // error has happened during path finding, and we will mark the payment
4✔
402
        // failed with this reason. Otherwise, we'll return the critical error
4✔
403
        // found to abort the lifecycle.
4✔
404
        var routeErr noRouteError
4✔
405
        if !errors.As(err, &routeErr) {
4✔
UNCOV
406
                return nil, fmt.Errorf("requestRoute got: %w", err)
×
UNCOV
407
        }
×
408

409
        // It's the `paymentSession`'s responsibility to find a route for us
410
        // with the best effort. When it cannot find a path, we need to treat it
411
        // as a terminal condition and fail the payment no matter it has
412
        // inflight HTLCs or not.
413
        failureCode := routeErr.FailureReason()
4✔
414
        log.Warnf("Marking payment %v permanently failed with no route: %v",
4✔
415
                p.identifier, failureCode)
4✔
416

4✔
417
        err = p.router.cfg.Control.FailPayment(p.identifier, failureCode)
4✔
418
        if err != nil {
4✔
UNCOV
419
                return nil, fmt.Errorf("FailPayment got: %w", err)
×
UNCOV
420
        }
×
421

422
        // NOTE: we decide to not return the non-critical noRouteError here to
423
        // avoid terminating the payment lifecycle as there might be other
424
        // inflight HTLCs which we must wait for their results.
425
        return nil, nil
4✔
426
}
427

428
// stop signals any active shard goroutine to exit.
429
func (p *paymentLifecycle) stop() {
4✔
430
        close(p.quit)
4✔
431
}
4✔
432

433
// attemptResult holds the HTLC attempt and a possible error returned from
434
// sending it.
435
type attemptResult struct {
436
        // err is non-nil if a non-critical error was encountered when trying
437
        // to send the attempt, and we successfully updated the control tower
438
        // to reflect this error. This can be errors like not enough local
439
        // balance for the given route etc.
440
        err error
441

442
        // attempt is the attempt structure as recorded in the database.
443
        attempt *channeldb.HTLCAttempt
444
}
445

446
// collectResultAsync launches a goroutine that will wait for the result of the
447
// given HTLC attempt to be available then handle its result. Once received, it
448
// will send a nil error to channel `resultCollected` to indicate there's a
449
// result.
450
func (p *paymentLifecycle) collectResultAsync(attempt *channeldb.HTLCAttempt) {
4✔
451
        log.Debugf("Collecting result for attempt %v in payment %v",
4✔
452
                attempt.AttemptID, p.identifier)
4✔
453

4✔
454
        go func() {
8✔
455
                // Block until the result is available.
4✔
456
                _, err := p.collectResult(attempt)
4✔
457
                if err != nil {
8✔
458
                        log.Errorf("Error collecting result for attempt %v "+
4✔
459
                                "in payment %v: %v", attempt.AttemptID,
4✔
460
                                p.identifier, err)
4✔
461
                }
4✔
462

463
                log.Debugf("Result collected for attempt %v in payment %v",
4✔
464
                        attempt.AttemptID, p.identifier)
4✔
465

4✔
466
                // Once the result is collected, we signal it by writing the
4✔
467
                // error to `resultCollected`.
4✔
468
                select {
4✔
469
                // Send the signal or quit.
470
                case p.resultCollected <- err:
4✔
471

472
                case <-p.quit:
1✔
473
                        log.Debugf("Lifecycle exiting while collecting "+
1✔
474
                                "result for payment %v", p.identifier)
1✔
475

476
                case <-p.router.quit:
×
477
                        return
×
478
                }
479
        }()
480
}
481

482
// collectResult waits for the result for the given attempt to be available
483
// from the Switch, then records the attempt outcome with the control tower.
484
// An attemptResult is returned, indicating the final outcome of this HTLC
485
// attempt.
486
func (p *paymentLifecycle) collectResult(attempt *channeldb.HTLCAttempt) (
487
        *attemptResult, error) {
4✔
488

4✔
489
        log.Tracef("Collecting result for attempt %v", spew.Sdump(attempt))
4✔
490

4✔
491
        // We'll retrieve the hash specific to this shard from the
4✔
492
        // shardTracker, since it will be needed to regenerate the circuit
4✔
493
        // below.
4✔
494
        hash, err := p.shardTracker.GetHash(attempt.AttemptID)
4✔
495
        if err != nil {
4✔
496
                return p.failAttempt(attempt.AttemptID, err)
×
497
        }
×
498

499
        // Regenerate the circuit for this attempt.
500
        _, circuit, err := generateSphinxPacket(
4✔
501
                &attempt.Route, hash[:], attempt.SessionKey(),
4✔
502
        )
4✔
503
        // TODO(yy): We generate this circuit to create the error decryptor,
4✔
504
        // which is then used in htlcswitch as the deobfuscator to decode the
4✔
505
        // error from `UpdateFailHTLC`. However, suppose it's an
4✔
506
        // `UpdateFulfillHTLC` message yet for some reason the sphinx packet is
4✔
507
        // failed to be generated, we'd miss settling it. This means we should
4✔
508
        // give it a second chance to try the settlement path in case
4✔
509
        // `GetAttemptResult` gives us back the preimage. And move the circuit
4✔
510
        // creation into htlcswitch so it's only constructed when there's a
4✔
511
        // failure message we need to decode.
4✔
512
        if err != nil {
4✔
513
                log.Debugf("Unable to generate circuit for attempt %v: %v",
×
514
                        attempt.AttemptID, err)
×
515

×
516
                return p.failAttempt(attempt.AttemptID, err)
×
517
        }
×
518

519
        // Using the created circuit, initialize the error decrypter, so we can
520
        // parse+decode any failures incurred by this payment within the
521
        // switch.
522
        errorDecryptor := &htlcswitch.SphinxErrorDecrypter{
4✔
523
                OnionErrorDecrypter: sphinx.NewOnionErrorDecrypter(circuit),
4✔
524
        }
4✔
525

4✔
526
        // Now ask the switch to return the result of the payment when
4✔
527
        // available.
4✔
528
        //
4✔
529
        // TODO(yy): consider using htlcswitch to create the `errorDecryptor`
4✔
530
        // since the htlc is already in db. This will also make the interface
4✔
531
        // `PaymentAttemptDispatcher` deeper and easier to use. Moreover, we'd
4✔
532
        // only create the decryptor when received a failure, further saving us
4✔
533
        // a few CPU cycles.
4✔
534
        resultChan, err := p.router.cfg.Payer.GetAttemptResult(
4✔
535
                attempt.AttemptID, p.identifier, errorDecryptor,
4✔
536
        )
4✔
537
        // Handle the switch error.
4✔
538
        if err != nil {
4✔
UNCOV
539
                log.Errorf("Failed getting result for attemptID %d "+
×
UNCOV
540
                        "from switch: %v", attempt.AttemptID, err)
×
UNCOV
541

×
UNCOV
542
                return p.handleSwitchErr(attempt, err)
×
UNCOV
543
        }
×
544

545
        // The switch knows about this payment, we'll wait for a result to be
546
        // available.
547
        var (
4✔
548
                result *htlcswitch.PaymentResult
4✔
549
                ok     bool
4✔
550
        )
4✔
551

4✔
552
        select {
4✔
553
        case result, ok = <-resultChan:
4✔
554
                if !ok {
8✔
555
                        return nil, htlcswitch.ErrSwitchExiting
4✔
556
                }
4✔
557

UNCOV
558
        case <-p.quit:
×
UNCOV
559
                return nil, ErrPaymentLifecycleExiting
×
560

UNCOV
561
        case <-p.router.quit:
×
UNCOV
562
                return nil, ErrRouterShuttingDown
×
563
        }
564

565
        // In case of a payment failure, fail the attempt with the control
566
        // tower and return.
567
        if result.Error != nil {
8✔
568
                return p.handleSwitchErr(attempt, result.Error)
4✔
569
        }
4✔
570

571
        // We successfully got a payment result back from the switch.
572
        log.Debugf("Payment %v succeeded with pid=%v",
4✔
573
                p.identifier, attempt.AttemptID)
4✔
574

4✔
575
        // Report success to mission control.
4✔
576
        err = p.router.cfg.MissionControl.ReportPaymentSuccess(
4✔
577
                attempt.AttemptID, &attempt.Route,
4✔
578
        )
4✔
579
        if err != nil {
4✔
580
                log.Errorf("Error reporting payment success to mc: %v", err)
×
581
        }
×
582

583
        // In case of success we atomically store settle result to the DB move
584
        // the shard to the settled state.
585
        htlcAttempt, err := p.router.cfg.Control.SettleAttempt(
4✔
586
                p.identifier, attempt.AttemptID,
4✔
587
                &channeldb.HTLCSettleInfo{
4✔
588
                        Preimage:   result.Preimage,
4✔
589
                        SettleTime: p.router.cfg.Clock.Now(),
4✔
590
                },
4✔
591
        )
4✔
592
        if err != nil {
4✔
UNCOV
593
                log.Errorf("Error settling attempt %v for payment %v with "+
×
UNCOV
594
                        "preimage %v: %v", attempt.AttemptID, p.identifier,
×
UNCOV
595
                        result.Preimage, err)
×
UNCOV
596

×
UNCOV
597
                // We won't mark the attempt as failed since we already have
×
UNCOV
598
                // the preimage.
×
UNCOV
599
                return nil, err
×
UNCOV
600
        }
×
601

602
        return &attemptResult{
4✔
603
                attempt: htlcAttempt,
4✔
604
        }, nil
4✔
605
}
606

607
// registerAttempt is responsible for creating and saving an HTLC attempt in db
608
// by using the route info provided. The `remainingAmt` is used to decide
609
// whether this is the last attempt.
610
func (p *paymentLifecycle) registerAttempt(rt *route.Route,
611
        remainingAmt lnwire.MilliSatoshi) (*channeldb.HTLCAttempt, error) {
4✔
612

4✔
613
        // If this route will consume the last remaining amount to send
4✔
614
        // to the receiver, this will be our last shard (for now).
4✔
615
        isLastAttempt := rt.ReceiverAmt() == remainingAmt
4✔
616

4✔
617
        // Using the route received from the payment session, create a new
4✔
618
        // shard to send.
4✔
619
        attempt, err := p.createNewPaymentAttempt(rt, isLastAttempt)
4✔
620
        if err != nil {
4✔
UNCOV
621
                return nil, err
×
UNCOV
622
        }
×
623

624
        // Before sending this HTLC to the switch, we checkpoint the fresh
625
        // paymentID and route to the DB. This lets us know on startup the ID
626
        // of the payment that we attempted to send, such that we can query the
627
        // Switch for its whereabouts. The route is needed to handle the result
628
        // when it eventually comes back.
629
        err = p.router.cfg.Control.RegisterAttempt(
4✔
630
                p.identifier, &attempt.HTLCAttemptInfo,
4✔
631
        )
4✔
632

4✔
633
        return attempt, err
4✔
634
}
635

636
// createNewPaymentAttempt creates a new payment attempt from the given route.
637
func (p *paymentLifecycle) createNewPaymentAttempt(rt *route.Route,
638
        lastShard bool) (*channeldb.HTLCAttempt, error) {
4✔
639

4✔
640
        // Generate a new key to be used for this attempt.
4✔
641
        sessionKey, err := generateNewSessionKey()
4✔
642
        if err != nil {
4✔
643
                return nil, err
×
644
        }
×
645

646
        // We generate a new, unique payment ID that we will use for
647
        // this HTLC.
648
        attemptID, err := p.router.cfg.NextPaymentID()
4✔
649
        if err != nil {
4✔
650
                return nil, err
×
651
        }
×
652

653
        // Request a new shard from the ShardTracker. If this is an AMP
654
        // payment, and this is the last shard, the outstanding shards together
655
        // with this one will be enough for the receiver to derive all HTLC
656
        // preimages. If this a non-AMP payment, the ShardTracker will return a
657
        // simple shard with the payment's static payment hash.
658
        shard, err := p.shardTracker.NewShard(attemptID, lastShard)
4✔
659
        if err != nil {
4✔
UNCOV
660
                return nil, err
×
UNCOV
661
        }
×
662

663
        // If this shard carries MPP or AMP options, add them to the last hop
664
        // on the route.
665
        hop := rt.Hops[len(rt.Hops)-1]
4✔
666
        if shard.MPP() != nil {
8✔
667
                hop.MPP = shard.MPP()
4✔
668
        }
4✔
669

670
        if shard.AMP() != nil {
8✔
671
                hop.AMP = shard.AMP()
4✔
672
        }
4✔
673

674
        hash := shard.Hash()
4✔
675

4✔
676
        // We now have all the information needed to populate the current
4✔
677
        // attempt information.
4✔
678
        attempt := channeldb.NewHtlcAttempt(
4✔
679
                attemptID, sessionKey, *rt, p.router.cfg.Clock.Now(), &hash,
4✔
680
        )
4✔
681

4✔
682
        return attempt, nil
4✔
683
}
684

685
// sendAttempt attempts to send the current attempt to the switch to complete
686
// the payment. If this attempt fails, then we'll continue on to the next
687
// available route.
688
func (p *paymentLifecycle) sendAttempt(
689
        attempt *channeldb.HTLCAttempt) (*attemptResult, error) {
4✔
690

4✔
691
        log.Debugf("Sending HTLC attempt(id=%v, total_amt=%v, first_hop_amt=%d"+
4✔
692
                ") for payment %v", attempt.AttemptID,
4✔
693
                attempt.Route.TotalAmount, attempt.Route.FirstHopAmount.Val,
4✔
694
                p.identifier)
4✔
695

4✔
696
        rt := attempt.Route
4✔
697

4✔
698
        // Construct the first hop.
4✔
699
        firstHop := lnwire.NewShortChanIDFromInt(rt.Hops[0].ChannelID)
4✔
700

4✔
701
        // Craft an HTLC packet to send to the htlcswitch. The metadata within
4✔
702
        // this packet will be used to route the payment through the network,
4✔
703
        // starting with the first-hop.
4✔
704
        htlcAdd := &lnwire.UpdateAddHTLC{
4✔
705
                Amount:        rt.FirstHopAmount.Val.Int(),
4✔
706
                Expiry:        rt.TotalTimeLock,
4✔
707
                PaymentHash:   *attempt.Hash,
4✔
708
                CustomRecords: rt.FirstHopWireCustomRecords,
4✔
709
        }
4✔
710

4✔
711
        // Generate the raw encoded sphinx packet to be included along
4✔
712
        // with the htlcAdd message that we send directly to the
4✔
713
        // switch.
4✔
714
        onionBlob, _, err := generateSphinxPacket(
4✔
715
                &rt, attempt.Hash[:], attempt.SessionKey(),
4✔
716
        )
4✔
717
        if err != nil {
4✔
UNCOV
718
                log.Errorf("Failed to create onion blob: attempt=%d in "+
×
UNCOV
719
                        "payment=%v, err:%v", attempt.AttemptID,
×
UNCOV
720
                        p.identifier, err)
×
UNCOV
721

×
UNCOV
722
                return p.failAttempt(attempt.AttemptID, err)
×
UNCOV
723
        }
×
724

725
        copy(htlcAdd.OnionBlob[:], onionBlob)
4✔
726

4✔
727
        // Send it to the Switch. When this method returns we assume
4✔
728
        // the Switch successfully has persisted the payment attempt,
4✔
729
        // such that we can resume waiting for the result after a
4✔
730
        // restart.
4✔
731
        err = p.router.cfg.Payer.SendHTLC(firstHop, attempt.AttemptID, htlcAdd)
4✔
732
        if err != nil {
8✔
733
                log.Errorf("Failed sending attempt %d for payment %v to "+
4✔
734
                        "switch: %v", attempt.AttemptID, p.identifier, err)
4✔
735

4✔
736
                return p.handleSwitchErr(attempt, err)
4✔
737
        }
4✔
738

739
        log.Debugf("Attempt %v for payment %v successfully sent to switch, "+
4✔
740
                "route: %v", attempt.AttemptID, p.identifier, &attempt.Route)
4✔
741

4✔
742
        return &attemptResult{
4✔
743
                attempt: attempt,
4✔
744
        }, nil
4✔
745
}
746

747
// amendFirstHopData is a function that calls the traffic shaper to allow it to
748
// add custom records to the outgoing HTLC and also adjust the amount if
749
// needed.
750
func (p *paymentLifecycle) amendFirstHopData(rt *route.Route) error {
4✔
751
        // The first hop amount on the route is the full route amount if not
4✔
752
        // overwritten by the traffic shaper. So we set the initial value now
4✔
753
        // and potentially overwrite it later.
4✔
754
        rt.FirstHopAmount = tlv.NewRecordT[tlv.TlvType0](
4✔
755
                tlv.NewBigSizeT(rt.TotalAmount),
4✔
756
        )
4✔
757

4✔
758
        // By default, we set the first hop custom records to the initial
4✔
759
        // value requested by the RPC. The traffic shaper may overwrite this
4✔
760
        // value.
4✔
761
        rt.FirstHopWireCustomRecords = p.firstHopCustomRecords
4✔
762

4✔
763
        // extraDataRequest is a helper struct to pass the custom records and
4✔
764
        // amount back from the traffic shaper.
4✔
765
        type extraDataRequest struct {
4✔
766
                customRecords fn.Option[lnwire.CustomRecords]
4✔
767

4✔
768
                amount fn.Option[lnwire.MilliSatoshi]
4✔
769
        }
4✔
770

4✔
771
        // If a hook exists that may affect our outgoing message, we call it now
4✔
772
        // and apply its side effects to the UpdateAddHTLC message.
4✔
773
        result, err := fn.MapOptionZ(
4✔
774
                p.router.cfg.TrafficShaper,
4✔
775
                //nolint:ll
4✔
776
                func(ts htlcswitch.AuxTrafficShaper) fn.Result[extraDataRequest] {
4✔
UNCOV
777
                        newAmt, newRecords, err := ts.ProduceHtlcExtraData(
×
UNCOV
778
                                rt.TotalAmount, p.firstHopCustomRecords,
×
UNCOV
779
                        )
×
UNCOV
780
                        if err != nil {
×
781
                                return fn.Err[extraDataRequest](err)
×
782
                        }
×
783

784
                        // Make sure we only received valid records.
UNCOV
785
                        if err := newRecords.Validate(); err != nil {
×
786
                                return fn.Err[extraDataRequest](err)
×
787
                        }
×
788

UNCOV
789
                        log.Debugf("Aux traffic shaper returned custom "+
×
UNCOV
790
                                "records %v and amount %d msat for HTLC",
×
UNCOV
791
                                spew.Sdump(newRecords), newAmt)
×
UNCOV
792

×
UNCOV
793
                        return fn.Ok(extraDataRequest{
×
UNCOV
794
                                customRecords: fn.Some(newRecords),
×
UNCOV
795
                                amount:        fn.Some(newAmt),
×
UNCOV
796
                        })
×
797
                },
798
        ).Unpack()
799
        if err != nil {
4✔
800
                return fmt.Errorf("traffic shaper failed to produce extra "+
×
801
                        "data: %w", err)
×
802
        }
×
803

804
        // Apply the side effects to the UpdateAddHTLC message.
805
        result.customRecords.WhenSome(func(records lnwire.CustomRecords) {
4✔
UNCOV
806
                rt.FirstHopWireCustomRecords = records
×
UNCOV
807
        })
×
808
        result.amount.WhenSome(func(amount lnwire.MilliSatoshi) {
4✔
UNCOV
809
                rt.FirstHopAmount = tlv.NewRecordT[tlv.TlvType0](
×
UNCOV
810
                        tlv.NewBigSizeT(amount),
×
UNCOV
811
                )
×
UNCOV
812
        })
×
813

814
        return nil
4✔
815
}
816

817
// failAttemptAndPayment fails both the payment and its attempt via the
818
// router's control tower, which marks the payment as failed in db.
819
func (p *paymentLifecycle) failPaymentAndAttempt(
820
        attemptID uint64, reason *channeldb.FailureReason,
821
        sendErr error) (*attemptResult, error) {
4✔
822

4✔
823
        log.Errorf("Payment %v failed: final_outcome=%v, raw_err=%v",
4✔
824
                p.identifier, *reason, sendErr)
4✔
825

4✔
826
        // Fail the payment via control tower.
4✔
827
        //
4✔
828
        // NOTE: we must fail the payment first before failing the attempt.
4✔
829
        // Otherwise, once the attempt is marked as failed, another goroutine
4✔
830
        // might make another attempt while we are failing the payment.
4✔
831
        err := p.router.cfg.Control.FailPayment(p.identifier, *reason)
4✔
832
        if err != nil {
4✔
833
                log.Errorf("Unable to fail payment: %v", err)
×
834
                return nil, err
×
835
        }
×
836

837
        // Fail the attempt.
838
        return p.failAttempt(attemptID, sendErr)
4✔
839
}
840

841
// handleSwitchErr inspects the given error from the Switch and determines
842
// whether we should make another payment attempt, or if it should be
843
// considered a terminal error. Terminal errors will be recorded with the
844
// control tower. It analyzes the sendErr for the payment attempt received from
845
// the switch and updates mission control and/or channel policies. Depending on
846
// the error type, the error is either the final outcome of the payment or we
847
// need to continue with an alternative route. A final outcome is indicated by
848
// a non-nil reason value.
849
func (p *paymentLifecycle) handleSwitchErr(attempt *channeldb.HTLCAttempt,
850
        sendErr error) (*attemptResult, error) {
4✔
851

4✔
852
        internalErrorReason := channeldb.FailureReasonError
4✔
853
        attemptID := attempt.AttemptID
4✔
854

4✔
855
        // reportAndFail is a helper closure that reports the failure to the
4✔
856
        // mission control, which helps us to decide whether we want to retry
4✔
857
        // the payment or not. If a non nil reason is returned from mission
4✔
858
        // control, it will further fail the payment via control tower.
4✔
859
        reportAndFail := func(srcIdx *int,
4✔
860
                msg lnwire.FailureMessage) (*attemptResult, error) {
8✔
861

4✔
862
                // Report outcome to mission control.
4✔
863
                reason, err := p.router.cfg.MissionControl.ReportPaymentFail(
4✔
864
                        attemptID, &attempt.Route, srcIdx, msg,
4✔
865
                )
4✔
866
                if err != nil {
4✔
867
                        log.Errorf("Error reporting payment result to mc: %v",
×
868
                                err)
×
869

×
870
                        reason = &internalErrorReason
×
871
                }
×
872

873
                // Fail the attempt only if there's no reason.
874
                if reason == nil {
8✔
875
                        // Fail the attempt.
4✔
876
                        return p.failAttempt(attemptID, sendErr)
4✔
877
                }
4✔
878

879
                // Otherwise fail both the payment and the attempt.
880
                return p.failPaymentAndAttempt(attemptID, reason, sendErr)
4✔
881
        }
882

883
        // If this attempt ID is unknown to the Switch, it means it was never
884
        // checkpointed and forwarded by the switch before a restart. In this
885
        // case we can safely send a new payment attempt, and wait for its
886
        // result to be available.
887
        if errors.Is(sendErr, htlcswitch.ErrPaymentIDNotFound) {
4✔
888
                log.Debugf("Attempt ID %v for payment %v not found in the "+
×
889
                        "Switch, retrying.", attempt.AttemptID, p.identifier)
×
890

×
891
                return p.failAttempt(attemptID, sendErr)
×
892
        }
×
893

894
        if errors.Is(sendErr, htlcswitch.ErrUnreadableFailureMessage) {
4✔
UNCOV
895
                log.Warn("Unreadable failure when sending htlc: id=%v, hash=%v",
×
UNCOV
896
                        attempt.AttemptID, attempt.Hash)
×
UNCOV
897

×
UNCOV
898
                // Since this error message cannot be decrypted, we will send a
×
UNCOV
899
                // nil error message to our mission controller and fail the
×
UNCOV
900
                // payment.
×
UNCOV
901
                return reportAndFail(nil, nil)
×
UNCOV
902
        }
×
903

904
        // If the error is a ClearTextError, we have received a valid wire
905
        // failure message, either from our own outgoing link or from a node
906
        // down the route. If the error is not related to the propagation of
907
        // our payment, we can stop trying because an internal error has
908
        // occurred.
909
        var rtErr htlcswitch.ClearTextError
4✔
910
        ok := errors.As(sendErr, &rtErr)
4✔
911
        if !ok {
4✔
UNCOV
912
                return p.failPaymentAndAttempt(
×
UNCOV
913
                        attemptID, &internalErrorReason, sendErr,
×
UNCOV
914
                )
×
UNCOV
915
        }
×
916

917
        // failureSourceIdx is the index of the node that the failure occurred
918
        // at. If the ClearTextError received is not a ForwardingError the
919
        // payment error occurred at our node, so we leave this value as 0
920
        // to indicate that the failure occurred locally. If the error is a
921
        // ForwardingError, it did not originate at our node, so we set
922
        // failureSourceIdx to the index of the node where the failure occurred.
923
        failureSourceIdx := 0
4✔
924
        var source *htlcswitch.ForwardingError
4✔
925
        ok = errors.As(rtErr, &source)
4✔
926
        if ok {
8✔
927
                failureSourceIdx = source.FailureSourceIdx
4✔
928
        }
4✔
929

930
        // Extract the wire failure and apply channel update if it contains one.
931
        // If we received an unknown failure message from a node along the
932
        // route, the failure message will be nil.
933
        failureMessage := rtErr.WireMessage()
4✔
934
        err := p.handleFailureMessage(
4✔
935
                &attempt.Route, failureSourceIdx, failureMessage,
4✔
936
        )
4✔
937
        if err != nil {
4✔
938
                return p.failPaymentAndAttempt(
×
939
                        attemptID, &internalErrorReason, sendErr,
×
940
                )
×
941
        }
×
942

943
        log.Tracef("Node=%v reported failure when sending htlc",
4✔
944
                failureSourceIdx)
4✔
945

4✔
946
        return reportAndFail(&failureSourceIdx, failureMessage)
4✔
947
}
948

949
// handleFailureMessage tries to apply a channel update present in the failure
950
// message if any.
951
func (p *paymentLifecycle) handleFailureMessage(rt *route.Route,
952
        errorSourceIdx int, failure lnwire.FailureMessage) error {
4✔
953

4✔
954
        if failure == nil {
4✔
UNCOV
955
                return nil
×
UNCOV
956
        }
×
957

958
        // It makes no sense to apply our own channel updates.
959
        if errorSourceIdx == 0 {
8✔
960
                log.Errorf("Channel update of ourselves received")
4✔
961

4✔
962
                return nil
4✔
963
        }
4✔
964

965
        // Extract channel update if the error contains one.
966
        update := p.router.extractChannelUpdate(failure)
4✔
967
        if update == nil {
8✔
968
                return nil
4✔
969
        }
4✔
970

971
        // Parse pubkey to allow validation of the channel update. This should
972
        // always succeed, otherwise there is something wrong in our
973
        // implementation. Therefore, return an error.
974
        errVertex := rt.Hops[errorSourceIdx-1].PubKeyBytes
4✔
975
        errSource, err := btcec.ParsePubKey(errVertex[:])
4✔
976
        if err != nil {
4✔
977
                log.Errorf("Cannot parse pubkey: idx=%v, pubkey=%v",
×
978
                        errorSourceIdx, errVertex)
×
979

×
980
                return err
×
981
        }
×
982

983
        var (
4✔
984
                isAdditionalEdge bool
4✔
985
                policy           *models.CachedEdgePolicy
4✔
986
        )
4✔
987

4✔
988
        // Before we apply the channel update, we need to decide whether the
4✔
989
        // update is for additional (ephemeral) edge or normal edge stored in
4✔
990
        // db.
4✔
991
        //
4✔
992
        // Note: the p.paySession might be nil here if it's called inside
4✔
993
        // SendToRoute where there's no payment lifecycle.
4✔
994
        if p.paySession != nil {
8✔
995
                policy = p.paySession.GetAdditionalEdgePolicy(
4✔
996
                        errSource, update.ShortChannelID.ToUint64(),
4✔
997
                )
4✔
998
                if policy != nil {
8✔
999
                        isAdditionalEdge = true
4✔
1000
                }
4✔
1001
        }
1002

1003
        // Apply channel update to additional edge policy.
1004
        if isAdditionalEdge {
8✔
1005
                if !p.paySession.UpdateAdditionalEdge(
4✔
1006
                        update, errSource, policy) {
4✔
1007

×
1008
                        log.Debugf("Invalid channel update received: node=%v",
×
1009
                                errVertex)
×
1010
                }
×
1011
                return nil
4✔
1012
        }
1013

1014
        // Apply channel update to the channel edge policy in our db.
1015
        if !p.router.cfg.ApplyChannelUpdate(update) {
8✔
1016
                log.Debugf("Invalid channel update received: node=%v",
4✔
1017
                        errVertex)
4✔
1018
        }
4✔
1019
        return nil
4✔
1020
}
1021

1022
// failAttempt calls control tower to fail the current payment attempt.
1023
func (p *paymentLifecycle) failAttempt(attemptID uint64,
1024
        sendError error) (*attemptResult, error) {
4✔
1025

4✔
1026
        log.Warnf("Attempt %v for payment %v failed: %v", attemptID,
4✔
1027
                p.identifier, sendError)
4✔
1028

4✔
1029
        failInfo := marshallError(
4✔
1030
                sendError,
4✔
1031
                p.router.cfg.Clock.Now(),
4✔
1032
        )
4✔
1033

4✔
1034
        // Now that we are failing this payment attempt, cancel the shard with
4✔
1035
        // the ShardTracker such that it can derive the correct hash for the
4✔
1036
        // next attempt.
4✔
1037
        if err := p.shardTracker.CancelShard(attemptID); err != nil {
4✔
1038
                return nil, err
×
1039
        }
×
1040

1041
        attempt, err := p.router.cfg.Control.FailAttempt(
4✔
1042
                p.identifier, attemptID, failInfo,
4✔
1043
        )
4✔
1044
        if err != nil {
4✔
UNCOV
1045
                return nil, err
×
UNCOV
1046
        }
×
1047

1048
        return &attemptResult{
4✔
1049
                attempt: attempt,
4✔
1050
                err:     sendError,
4✔
1051
        }, nil
4✔
1052
}
1053

1054
// marshallError marshall an error as received from the switch to a structure
1055
// that is suitable for database storage.
1056
func marshallError(sendError error, time time.Time) *channeldb.HTLCFailInfo {
4✔
1057
        response := &channeldb.HTLCFailInfo{
4✔
1058
                FailTime: time,
4✔
1059
        }
4✔
1060

4✔
1061
        switch {
4✔
1062
        case errors.Is(sendError, htlcswitch.ErrPaymentIDNotFound):
×
1063
                response.Reason = channeldb.HTLCFailInternal
×
1064
                return response
×
1065

UNCOV
1066
        case errors.Is(sendError, htlcswitch.ErrUnreadableFailureMessage):
×
UNCOV
1067
                response.Reason = channeldb.HTLCFailUnreadable
×
UNCOV
1068
                return response
×
1069
        }
1070

1071
        var rtErr htlcswitch.ClearTextError
4✔
1072
        ok := errors.As(sendError, &rtErr)
4✔
1073
        if !ok {
4✔
UNCOV
1074
                response.Reason = channeldb.HTLCFailInternal
×
UNCOV
1075
                return response
×
UNCOV
1076
        }
×
1077

1078
        message := rtErr.WireMessage()
4✔
1079
        if message != nil {
8✔
1080
                response.Reason = channeldb.HTLCFailMessage
4✔
1081
                response.Message = message
4✔
1082
        } else {
4✔
UNCOV
1083
                response.Reason = channeldb.HTLCFailUnknown
×
UNCOV
1084
        }
×
1085

1086
        // If the ClearTextError received is a ForwardingError, the error
1087
        // originated from a node along the route, not locally on our outgoing
1088
        // link. We set failureSourceIdx to the index of the node where the
1089
        // failure occurred. If the error is not a ForwardingError, the failure
1090
        // occurred at our node, so we leave the index as 0 to indicate that
1091
        // we failed locally.
1092
        var fErr *htlcswitch.ForwardingError
4✔
1093
        ok = errors.As(rtErr, &fErr)
4✔
1094
        if ok {
8✔
1095
                response.FailureSourceIndex = uint32(fErr.FailureSourceIdx)
4✔
1096
        }
4✔
1097

1098
        return response
4✔
1099
}
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