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

lightningnetwork / lnd / 12430766295

20 Dec 2024 11:38AM UTC coverage: 52.607% (-6.1%) from 58.716%
12430766295

Pull #9384

github

ziggie1984
funding: refactor gossip msg code

We almost never need to create all messages at the same time
(ChanUpdate,ChanAnnouncement,Proof) so we split it up into own
functions.
Pull Request #9384: Refactor gossip msg code

224 of 279 new or added lines in 7 files covered. (80.29%)

27070 existing lines in 437 files now uncovered.

53540 of 101773 relevant lines covered (52.61%)

4.11 hits per line

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

80.49
/contractcourt/htlc_incoming_contest_resolver.go
1
package contractcourt
2

3
import (
4
        "bytes"
5
        "encoding/binary"
6
        "errors"
7
        "fmt"
8
        "io"
9

10
        "github.com/btcsuite/btcd/btcutil"
11
        "github.com/btcsuite/btcd/txscript"
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/hop"
16
        "github.com/lightningnetwork/lnd/invoices"
17
        "github.com/lightningnetwork/lnd/lntypes"
18
        "github.com/lightningnetwork/lnd/lnwallet"
19
        "github.com/lightningnetwork/lnd/lnwire"
20
        "github.com/lightningnetwork/lnd/queue"
21
)
22

23
// htlcIncomingContestResolver is a ContractResolver that's able to resolve an
24
// incoming HTLC that is still contested. An HTLC is still contested, if at the
25
// time of commitment broadcast, we don't know of the preimage for it yet, and
26
// it hasn't expired. In this case, we can resolve the HTLC if we learn of the
27
// preimage, otherwise the remote party will sweep it after it expires.
28
//
29
// TODO(roasbeef): just embed the other resolver?
30
type htlcIncomingContestResolver struct {
31
        // htlcExpiry is the absolute expiry of this incoming HTLC. We use this
32
        // value to determine if we can exit early as if the HTLC times out,
33
        // before we learn of the preimage then we can't claim it on chain
34
        // successfully.
35
        htlcExpiry uint32
36

37
        // htlcSuccessResolver is the inner resolver that may be utilized if we
38
        // learn of the preimage.
39
        *htlcSuccessResolver
40
}
41

42
// newIncomingContestResolver instantiates a new incoming htlc contest resolver.
43
func newIncomingContestResolver(
44
        res lnwallet.IncomingHtlcResolution, broadcastHeight uint32,
45
        htlc channeldb.HTLC, resCfg ResolverConfig) *htlcIncomingContestResolver {
4✔
46

4✔
47
        success := newSuccessResolver(
4✔
48
                res, broadcastHeight, htlc, resCfg,
4✔
49
        )
4✔
50

4✔
51
        return &htlcIncomingContestResolver{
4✔
52
                htlcExpiry:          htlc.RefundTimeout,
4✔
53
                htlcSuccessResolver: success,
4✔
54
        }
4✔
55
}
4✔
56

57
func (h *htlcIncomingContestResolver) processFinalHtlcFail() error {
4✔
58
        // Mark the htlc as final failed.
4✔
59
        err := h.ChainArbitratorConfig.PutFinalHtlcOutcome(
4✔
60
                h.ChannelArbitratorConfig.ShortChanID, h.htlc.HtlcIndex, false,
4✔
61
        )
4✔
62
        if err != nil {
4✔
63
                return err
×
64
        }
×
65

66
        // Send notification.
67
        h.ChainArbitratorConfig.HtlcNotifier.NotifyFinalHtlcEvent(
4✔
68
                models.CircuitKey{
4✔
69
                        ChanID: h.ShortChanID,
4✔
70
                        HtlcID: h.htlc.HtlcIndex,
4✔
71
                },
4✔
72
                channeldb.FinalHtlcInfo{
4✔
73
                        Settled:  false,
4✔
74
                        Offchain: false,
4✔
75
                },
4✔
76
        )
4✔
77

4✔
78
        return nil
4✔
79
}
80

81
// Resolve attempts to resolve this contract. As we don't yet know of the
82
// preimage for the contract, we'll wait for one of two things to happen:
83
//
4✔
84
//  1. We learn of the preimage! In this case, we can sweep the HTLC incoming
4✔
85
//     and ensure that if this was a multi-hop HTLC we are made whole. In this
4✔
86
//     case, an additional ContractResolver will be returned to finish the
4✔
UNCOV
87
//     job.
×
UNCOV
88
//
×
UNCOV
89
//  2. The HTLC expires. If this happens, then the contract is fully resolved
×
90
//     as we have no remaining actions left at our disposal.
91
//
4✔
92
// NOTE: Part of the ContractResolver interface.
4✔
93
func (h *htlcIncomingContestResolver) Resolve(
4✔
94
        _ bool) (ContractResolver, error) {
4✔
95

4✔
96
        // If we're already full resolved, then we don't have anything further
×
97
        // to do.
×
98
        if h.resolved {
99
                return nil, nil
100
        }
8✔
101

4✔
102
        // First try to parse the payload. If that fails, we can stop resolution
4✔
103
        // now.
104
        payload, nextHopOnionBlob, err := h.decodePayload()
4✔
105
        if err != nil {
4✔
106
                log.Debugf("ChannelArbitrator(%v): cannot decode payload of "+
4✔
107
                        "htlc %v", h.ChanPoint, h.HtlcPoint())
4✔
108

4✔
109
                // If we've locked in an htlc with an invalid payload on our
4✔
110
                // commitment tx, we don't need to resolve it. The other party
111
                // will time it out and get their funds back. This situation
112
                // can present itself when we crash before processRemoteAdds in
113
                // the link has ran.
114
                h.resolved = true
115

116
                if err := h.processFinalHtlcFail(); err != nil {
117
                        return nil, err
118
                }
119

120
                // We write a report to disk that indicates we could not decode
121
                // the htlc.
122
                resReport := h.report().resolverReport(
123
                        nil, channeldb.ResolverTypeIncomingHtlc,
124
                        channeldb.ResolverOutcomeAbandoned,
4✔
125
                )
4✔
126
                return nil, h.PutResolverReport(nil, resReport)
4✔
127
        }
4✔
128

×
129
        // Register for block epochs. After registration, the current height
×
130
        // will be sent on the channel immediately.
×
131
        blockEpochs, err := h.Notifier.RegisterBlockEpochNtfn(nil)
132
        if err != nil {
133
                return nil, err
134
        }
4✔
135
        defer blockEpochs.Cancel()
4✔
136

×
137
        var currentHeight int32
×
138
        select {
×
139
        case newBlock, ok := <-blockEpochs.Epochs:
×
140
                if !ok {
×
141
                        return nil, errResolverShuttingDown
×
142
                }
×
143
                currentHeight = newBlock.Height
×
144
        case <-h.quit:
×
145
                return nil, errResolverShuttingDown
×
146
        }
×
147

×
148
        log.Debugf("%T(%v): Resolving incoming HTLC(expiry=%v, height=%v)", h,
149
                h.htlcResolution.ClaimOutpoint, h.htlcExpiry, currentHeight)
150

151
        // We'll first check if this HTLC has been timed out, if so, we can
×
152
        // return now and mark ourselves as resolved. If we're past the point of
×
153
        // expiry of the HTLC, then at this point the sender can sweep it, so
×
154
        // we'll end our lifetime. Here we deliberately forego the chance that
×
155
        // the sender doesn't sweep and we already have or will learn the
×
156
        // preimage. Otherwise the resolver could potentially stay active
157
        // indefinitely and the channel will never close properly.
158
        if uint32(currentHeight) >= h.htlcExpiry {
159
                // TODO(roasbeef): should also somehow check if outgoing is
160
                // resolved or not
4✔
161
                //  * may need to hook into the circuit map
4✔
162
                //  * can't timeout before the outgoing has been
×
163

×
164
                log.Infof("%T(%v): HTLC has timed out (expiry=%v, height=%v), "+
4✔
165
                        "abandoning", h, h.htlcResolution.ClaimOutpoint,
4✔
166
                        h.htlcExpiry, currentHeight)
4✔
167
                h.resolved = true
4✔
168

4✔
169
                if err := h.processFinalHtlcFail(); err != nil {
4✔
170
                        return nil, err
×
171
                }
×
172

4✔
173
                // Finally, get our report and checkpoint our resolver with a
×
174
                // timeout outcome report.
×
175
                report := h.report().resolverReport(
176
                        nil, channeldb.ResolverTypeIncomingHtlc,
177
                        channeldb.ResolverOutcomeTimeout,
4✔
178
                )
4✔
179
                return nil, h.Checkpoint(h, report)
4✔
180
        }
4✔
181

4✔
182
        // applyPreimage is a helper function that will populate our internal
4✔
183
        // resolver with the preimage we learn of. This should be called once
4✔
184
        // the preimage is revealed so the inner resolver can properly complete
4✔
185
        // its duties. The error return value indicates whether the preimage
4✔
186
        // was properly applied.
4✔
187
        applyPreimage := func(preimage lntypes.Preimage) error {
8✔
188
                // Sanity check to see if this preimage matches our htlc. At
4✔
189
                // this point it should never happen that it does not match.
4✔
190
                if !preimage.Matches(h.htlc.RHash) {
4✔
191
                        return errors.New("preimage does not match hash")
4✔
192
                }
4✔
193

4✔
194
                // Update htlcResolution with the matching preimage.
4✔
195
                h.htlcResolution.Preimage = preimage
4✔
196

4✔
197
                log.Infof("%T(%v): applied preimage=%v", h,
4✔
198
                        h.htlcResolution.ClaimOutpoint, preimage)
4✔
199

×
200
                isSecondLevel := h.htlcResolution.SignedSuccessTx != nil
×
201

202
                // If we didn't have to go to the second level to claim (this
203
                // is the remote commitment transaction), then we don't need to
204
                // modify our canned witness.
4✔
205
                if !isSecondLevel {
4✔
206
                        return nil
4✔
207
                }
4✔
208

4✔
209
                isTaproot := txscript.IsPayToTaproot(
210
                        h.htlcResolution.SignedSuccessTx.TxOut[0].PkScript,
211
                )
212

213
                // If this is our commitment transaction, then we'll need to
4✔
214
                // populate the witness for the second-level HTLC transaction.
8✔
215
                switch {
4✔
216
                // For taproot channels, the witness for sweeping with success
4✔
217
                // looks like:
4✔
218
                //   - <sender sig> <receiver sig> <preimage> <success_script>
4✔
219
                //     <control_block>
220
                //
221
                // So we'll insert it at the 3rd index of the witness.
4✔
222
                case isTaproot:
4✔
223
                        //nolint:ll
4✔
224
                        h.htlcResolution.SignedSuccessTx.TxIn[0].Witness[2] = preimage[:]
×
225

×
226
                // Within the witness for the success transaction, the
227
                // preimage is the 4th element as it looks like:
4✔
228
                //
229
                //  * <0> <sender sig> <recvr sig> <preimage> <witness script>
230
                //
231
                // We'll populate it within the witness, as since this
4✔
232
                // was a "contest" resolver, we didn't yet know of the
4✔
233
                // preimage.
4✔
234
                case !isTaproot:
4✔
235
                        h.htlcResolution.SignedSuccessTx.TxIn[0].Witness[3] = preimage[:]
4✔
236
                }
4✔
237

4✔
238
                return nil
4✔
239
        }
4✔
240

×
241
        // Define a closure to process htlc resolutions either directly or
×
242
        // triggered by future notifications.
243
        processHtlcResolution := func(e invoices.HtlcResolution) (
244
                ContractResolver, error) {
245

4✔
246
                // Take action based on the type of resolution we have
4✔
247
                // received.
4✔
248
                switch resolution := e.(type) {
4✔
249
                // If the htlc resolution was a settle, apply the
4✔
250
                // preimage and return a success resolver.
251
                case *invoices.HtlcSettleResolution:
252
                        err := applyPreimage(resolution.Preimage)
253
                        if err != nil {
×
254
                                return nil, err
×
255
                        }
×
256

257
                        return h.htlcSuccessResolver, nil
258

259
                // If the htlc was failed, mark the htlc as
4✔
260
                // resolved.
4✔
261
                case *invoices.HtlcFailResolution:
4✔
262
                        log.Infof("%T(%v): Exit hop HTLC canceled "+
4✔
263
                                "(expiry=%v, height=%v), abandoning", h,
8✔
264
                                h.htlcResolution.ClaimOutpoint,
4✔
265
                                h.htlcExpiry, currentHeight)
4✔
266

4✔
267
                        h.resolved = true
4✔
268

4✔
269
                        if err := h.processFinalHtlcFail(); err != nil {
4✔
270
                                return nil, err
4✔
271
                        }
4✔
272

4✔
273
                        // Checkpoint our resolver with an abandoned outcome
4✔
274
                        // because we take no further action on this htlc.
4✔
275
                        report := h.report().resolverReport(
4✔
276
                                nil, channeldb.ResolverTypeIncomingHtlc,
4✔
277
                                channeldb.ResolverOutcomeAbandoned,
4✔
278
                        )
4✔
279
                        return nil, h.Checkpoint(h, report)
4✔
280

4✔
281
                // Error if the resolution type is unknown, we are only
4✔
282
                // expecting settles and fails.
4✔
283
                default:
4✔
284
                        return nil, fmt.Errorf("unknown resolution"+
4✔
285
                                " type: %v", e)
×
286
                }
×
287
        }
288

4✔
289
        var (
4✔
290
                hodlChan       <-chan interface{}
4✔
291
                witnessUpdates <-chan lntypes.Preimage
8✔
292
        )
4✔
293
        if payload.FwdInfo.NextHop == hop.Exit {
4✔
294
                // Create a buffered hodl chan to prevent deadlock.
4✔
295
                hodlQueue := queue.NewConcurrentQueue(10)
4✔
296
                hodlQueue.Start()
297

298
                hodlChan = hodlQueue.ChanOut()
299

300
                // Notify registry that we are potentially resolving as an exit
301
                // hop on-chain. If this HTLC indeed pays to an existing
4✔
302
                // invoice, the invoice registry will tell us what to do with
4✔
303
                // the HTLC. This is identical to HTLC resolution in the link.
4✔
304
                circuitKey := models.CircuitKey{
4✔
305
                        ChanID: h.ShortChanID,
4✔
306
                        HtlcID: h.htlc.HtlcIndex,
4✔
UNCOV
307
                }
×
UNCOV
308

×
309
                resolution, err := h.Registry.NotifyExitHopHtlc(
310
                        h.htlc.RHash, h.htlc.Amt, h.htlcExpiry, currentHeight,
311
                        circuitKey, hodlQueue.ChanIn(), h.htlc.CustomRecords,
4✔
312
                        payload,
4✔
313
                )
314
                if err != nil {
315
                        return nil, err
316
                }
4✔
317

318
                defer func() {
×
319
                        h.Registry.HodlUnsubscribeAll(hodlQueue.ChanIn())
×
320

×
321
                        hodlQueue.Stop()
322
                }()
4✔
323

4✔
324
                // Take action based on the resolution we received. If the htlc
4✔
325
                // was settled, or a htlc for a known invoice failed we can
4✔
326
                // resolve it directly. If the resolution is nil, the htlc was
4✔
327
                // neither accepted nor failed, so we cannot take action yet.
4✔
328
                switch res := resolution.(type) {
4✔
329
                case *invoices.HtlcFailResolution:
4✔
330
                        // In the case where the htlc failed, but the invoice
4✔
331
                        // was known to the registry, we can directly resolve
4✔
332
                        // the htlc.
4✔
333
                        if res.Outcome != invoices.ResultInvoiceNotFound {
4✔
334
                                return processHtlcResolution(resolution)
4✔
335
                        }
4✔
336

×
337
                // If we settled the htlc, we can resolve it.
×
338
                case *invoices.HtlcSettleResolution:
4✔
339
                        return processHtlcResolution(resolution)
4✔
340

4✔
341
                // If the resolution is nil, the htlc was neither settled nor
4✔
342
                // failed so we cannot take action at present.
4✔
343
                case nil:
8✔
344

4✔
345
                default:
4✔
346
                        return nil, fmt.Errorf("unknown htlc resolution type: %T",
4✔
347
                                resolution)
4✔
348
                }
4✔
349
        } else {
4✔
350
                // If the HTLC hasn't expired yet, then we may still be able to
4✔
351
                // claim it if we learn of the pre-image, so we'll subscribe to
×
352
                // the preimage database to see if it turns up, or the HTLC
×
353
                // times out.
354
                //
4✔
355
                // NOTE: This is done BEFORE opportunistically querying the db,
356
                // to ensure the preimage can't be delivered between querying
357
                // and registering for the preimage subscription.
4✔
358
                preimageSubscription, err := h.PreimageDB.SubscribeUpdates(
359
                        h.htlcSuccessResolver.ShortChanID, &h.htlc,
360
                        payload, nextHopOnionBlob,
8✔
361
                )
4✔
362
                if err != nil {
4✔
363
                        return nil, err
4✔
364
                }
4✔
365
                defer preimageSubscription.CancelSubscription()
8✔
366

4✔
367
                // With the epochs and preimage subscriptions initialized, we'll
368
                // query to see if we already know the preimage.
369
                preimage, ok := h.PreimageDB.LookupPreimage(h.htlc.RHash)
4✔
370
                if ok {
4✔
371
                        // If we do, then this means we can claim the HTLC!
4✔
372
                        // However, we don't know how to ourselves, so we'll
4✔
373
                        // return our inner resolver which has the knowledge to
×
374
                        // do so.
×
375
                        if err := applyPreimage(preimage); err != nil {
376
                                return nil, err
377
                        }
378

379
                        return h.htlcSuccessResolver, nil
4✔
380
                }
381

4✔
382
                witnessUpdates = preimageSubscription.WitnessUpdates
4✔
383
        }
4✔
384

385
        for {
4✔
386
                select {
4✔
387
                case preimage := <-witnessUpdates:
×
388
                        // We received a new preimage, but we need to ignore
×
389
                        // all except the preimage we are waiting for.
390
                        if !preimage.Matches(h.htlc.RHash) {
391
                                continue
392
                        }
393

4✔
394
                        if err := applyPreimage(preimage); err != nil {
8✔
395
                                return nil, err
4✔
396
                        }
4✔
397

4✔
398
                        // We've learned of the preimage and this information
4✔
399
                        // has been added to our inner resolver. We return it so
4✔
400
                        // it can continue contract resolution.
4✔
401
                        return h.htlcSuccessResolver, nil
4✔
402

4✔
403
                case hodlItem := <-hodlChan:
×
404
                        htlcResolution := hodlItem.(invoices.HtlcResolution)
×
405
                        return processHtlcResolution(htlcResolution)
406

4✔
407
                case newBlock, ok := <-blockEpochs.Epochs:
4✔
408
                        if !ok {
4✔
409
                                return nil, errResolverShuttingDown
4✔
410
                        }
4✔
411

4✔
412
                        // If this new height expires the HTLC, then this means
413
                        // we never found out the preimage, so we can mark
414
                        // resolved and exit.
4✔
415
                        newHeight := uint32(newBlock.Height)
4✔
416
                        if newHeight >= h.htlcExpiry {
417
                                log.Infof("%T(%v): HTLC has timed out "+
418
                                        "(expiry=%v, height=%v), abandoning", h,
419
                                        h.htlcResolution.ClaimOutpoint,
420
                                        h.htlcExpiry, currentHeight)
421
                                h.resolved = true
422

423
                                if err := h.processFinalHtlcFail(); err != nil {
424
                                        return nil, err
425
                                }
4✔
426

4✔
427
                                report := h.report().resolverReport(
4✔
428
                                        nil,
4✔
429
                                        channeldb.ResolverTypeIncomingHtlc,
4✔
430
                                        channeldb.ResolverOutcomeTimeout,
×
431
                                )
×
432
                                return nil, h.Checkpoint(h, report)
433
                        }
434

435
                case <-h.quit:
8✔
436
                        return nil, errResolverShuttingDown
4✔
437
                }
4✔
438
        }
4✔
439
}
4✔
440

4✔
441
// report returns a report on the resolution state of the contract.
442
func (h *htlcIncomingContestResolver) report() *ContractReport {
443
        // No locking needed as these values are read-only.
4✔
444

4✔
445
        finalAmt := h.htlc.Amt.ToSatoshis()
4✔
446
        if h.htlcResolution.SignedSuccessTx != nil {
4✔
447
                finalAmt = btcutil.Amount(
4✔
448
                        h.htlcResolution.SignedSuccessTx.TxOut[0].Value,
4✔
449
                )
4✔
450
        }
4✔
451

4✔
452
        return &ContractReport{
4✔
453
                Outpoint:       h.htlcResolution.ClaimOutpoint,
8✔
454
                Type:           ReportOutputIncomingHtlc,
4✔
455
                Amount:         finalAmt,
4✔
456
                MaturityHeight: h.htlcExpiry,
457
                LimboBalance:   finalAmt,
4✔
458
                Stage:          1,
4✔
459
        }
4✔
460
}
4✔
461

4✔
462
// Stop signals the resolver to cancel any current resolution processes, and
4✔
463
// suspend.
4✔
464
//
465
// NOTE: Part of the ContractResolver interface.
466
func (h *htlcIncomingContestResolver) Stop() {
467
        close(h.quit)
468
}
469

470
// IsResolved returns true if the stored state in the resolve is fully
4✔
471
// resolved. In this case the target output can be forgotten.
4✔
472
//
4✔
473
// NOTE: Part of the ContractResolver interface.
474
func (h *htlcIncomingContestResolver) IsResolved() bool {
475
        return h.resolved
476
}
477

478
// Encode writes an encoded version of the ContractResolver into the passed
479
// Writer.
480
//
481
// NOTE: Part of the ContractResolver interface.
482
func (h *htlcIncomingContestResolver) Encode(w io.Writer) error {
4✔
483
        // We'll first write out the one field unique to this resolver.
4✔
484
        if err := binary.Write(w, endian, h.htlcExpiry); err != nil {
4✔
485
                return err
486
        }
487

4✔
488
        // Then we'll write out our internal resolver.
489
        return h.htlcSuccessResolver.Encode(w)
490
}
491

4✔
492
// newIncomingContestResolverFromReader attempts to decode an encoded ContractResolver
4✔
493
// from the passed Reader instance, returning an active ContractResolver
4✔
494
// instance.
4✔
495
func newIncomingContestResolverFromReader(r io.Reader, resCfg ResolverConfig) (
8✔
496
        *htlcIncomingContestResolver, error) {
4✔
497

4✔
498
        h := &htlcIncomingContestResolver{}
4✔
499

4✔
500
        // We'll first read the one field unique to this resolver.
501
        if err := binary.Read(r, endian, &h.htlcExpiry); err != nil {
4✔
502
                return nil, err
4✔
503
        }
4✔
504

4✔
505
        // Then we'll decode our internal resolver.
4✔
506
        successResolver, err := newSuccessResolverFromReader(r, resCfg)
4✔
507
        if err != nil {
4✔
508
                return nil, err
4✔
509
        }
510
        h.htlcSuccessResolver = successResolver
511

512
        return h, nil
513
}
514

515
// Supplement adds additional information to the resolver that is required
4✔
516
// before Resolve() is called.
4✔
517
//
4✔
518
// NOTE: Part of the htlcContractResolver interface.
4✔
519
func (h *htlcIncomingContestResolver) Supplement(htlc channeldb.HTLC) {
4✔
520
        h.htlc = htlc
521
}
522

523
// SupplementDeadline does nothing for an incoming htlc resolver.
524
//
525
// NOTE: Part of the htlcContractResolver interface.
4✔
526
func (h *htlcIncomingContestResolver) SupplementDeadline(_ fn.Option[int32]) {
4✔
527
}
4✔
528

×
529
// decodePayload (re)decodes the hop payload of a received htlc.
×
530
func (h *htlcIncomingContestResolver) decodePayload() (*hop.Payload,
531
        []byte, error) {
532

4✔
533
        blindingInfo := hop.ReconstructBlindingInfo{
534
                IncomingAmt:    h.htlc.Amt,
535
                IncomingExpiry: h.htlc.RefundTimeout,
536
                BlindingKey:    h.htlc.BlindingPoint,
537
        }
538

539
        onionReader := bytes.NewReader(h.htlc.OnionBlob[:])
4✔
540
        iterator, err := h.OnionProcessor.ReconstructHopIterator(
4✔
541
                onionReader, h.htlc.RHash[:], blindingInfo,
4✔
542
        )
4✔
543
        if err != nil {
4✔
544
                return nil, nil, err
4✔
545
        }
×
546

×
547
        payload, _, err := iterator.HopPayload()
548
        if err != nil {
549
                return nil, nil, err
4✔
550
        }
4✔
551

×
552
        // Transform onion blob for the next hop.
×
553
        var onionBlob [lnwire.OnionPacketSize]byte
4✔
554
        buf := bytes.NewBuffer(onionBlob[0:0])
4✔
555
        err = iterator.EncodeNextHop(buf)
4✔
556
        if err != nil {
557
                return nil, nil, err
558
        }
559

560
        return payload, onionBlob[:], nil
561
}
562

4✔
563
// A compile time assertion to ensure htlcIncomingContestResolver meets the
4✔
564
// ContractResolver interface.
4✔
565
var _ htlcContractResolver = (*htlcIncomingContestResolver)(nil)
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