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

lightningnetwork / lnd / 10207481183

01 Aug 2024 11:52PM UTC coverage: 58.679% (+0.09%) from 58.591%
10207481183

push

github

web-flow
Merge pull request #8836 from hieblmi/payment-failure-reason-cancel

routing: add payment failure reason `FailureReasonCancel`

7 of 30 new or added lines in 5 files covered. (23.33%)

1662 existing lines in 21 files now uncovered.

125454 of 213798 relevant lines covered (58.68%)

28679.1 hits per line

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

81.5
/chainntnfs/bitcoindnotify/bitcoind.go
1
package bitcoindnotify
2

3
import (
4
        "errors"
5
        "fmt"
6
        "sync"
7
        "sync/atomic"
8

9
        "github.com/btcsuite/btcd/btcjson"
10
        "github.com/btcsuite/btcd/btcutil"
11
        "github.com/btcsuite/btcd/chaincfg"
12
        "github.com/btcsuite/btcd/chaincfg/chainhash"
13
        "github.com/btcsuite/btcd/txscript"
14
        "github.com/btcsuite/btcd/wire"
15
        "github.com/btcsuite/btcwallet/chain"
16
        "github.com/lightningnetwork/lnd/blockcache"
17
        "github.com/lightningnetwork/lnd/chainntnfs"
18
        "github.com/lightningnetwork/lnd/fn"
19
        "github.com/lightningnetwork/lnd/queue"
20
)
21

22
const (
23
        // notifierType uniquely identifies a concrete implementation of the
24
        // ChainNotifier interface that makes use of the bitcoind ZMQ interface.
25
        notifierTypeZMQ = "bitcoind"
26

27
        // notifierTypeRPCPolling uniquely identifies a concrete implementation
28
        // of the ChainNotifier interface that makes use of the bitcoind RPC
29
        // interface.
30
        notifierTypeRPCPolling = "bitcoind-rpc-polling"
31
)
32

33
// TODO(roasbeef): generalize struct below:
34
//  * move chans to config
35
//  * extract common code
36
//  * allow outside callers to handle send conditions
37

38
// BitcoindNotifier implements the ChainNotifier interface using a bitcoind
39
// chain client. Multiple concurrent clients are supported. All notifications
40
// are achieved via non-blocking sends on client channels.
41
type BitcoindNotifier struct {
42
        epochClientCounter uint64 // To be used atomically.
43

44
        start   sync.Once
45
        active  int32 // To be used atomically.
46
        stopped int32 // To be used atomically.
47

48
        chainConn   *chain.BitcoindClient
49
        chainParams *chaincfg.Params
50

51
        notificationCancels  chan interface{}
52
        notificationRegistry chan interface{}
53

54
        txNotifier *chainntnfs.TxNotifier
55

56
        blockEpochClients map[uint64]*blockEpochRegistration
57

58
        bestBlock chainntnfs.BlockEpoch
59

60
        // blockCache is a LRU block cache.
61
        blockCache *blockcache.BlockCache
62

63
        // spendHintCache is a cache used to query and update the latest height
64
        // hints for an outpoint. Each height hint represents the earliest
65
        // height at which the outpoint could have been spent within the chain.
66
        spendHintCache chainntnfs.SpendHintCache
67

68
        // confirmHintCache is a cache used to query the latest height hints for
69
        // a transaction. Each height hint represents the earliest height at
70
        // which the transaction could have confirmed within the chain.
71
        confirmHintCache chainntnfs.ConfirmHintCache
72

73
        // memNotifier notifies clients of events related to the mempool.
74
        memNotifier *chainntnfs.MempoolNotifier
75

76
        wg   sync.WaitGroup
77
        quit chan struct{}
78
}
79

80
// Ensure BitcoindNotifier implements the ChainNotifier interface at compile
81
// time.
82
var _ chainntnfs.ChainNotifier = (*BitcoindNotifier)(nil)
83

84
// Ensure BitcoindNotifier implements the MempoolWatcher interface at compile
85
// time.
86
var _ chainntnfs.MempoolWatcher = (*BitcoindNotifier)(nil)
87

88
// New returns a new BitcoindNotifier instance. This function assumes the
89
// bitcoind node detailed in the passed configuration is already running, and
90
// willing to accept RPC requests and new zmq clients.
91
func New(chainConn *chain.BitcoindConn, chainParams *chaincfg.Params,
92
        spendHintCache chainntnfs.SpendHintCache,
93
        confirmHintCache chainntnfs.ConfirmHintCache,
94
        blockCache *blockcache.BlockCache) *BitcoindNotifier {
14✔
95

14✔
96
        notifier := &BitcoindNotifier{
14✔
97
                chainParams: chainParams,
14✔
98

14✔
99
                notificationCancels:  make(chan interface{}),
14✔
100
                notificationRegistry: make(chan interface{}),
14✔
101

14✔
102
                blockEpochClients: make(map[uint64]*blockEpochRegistration),
14✔
103

14✔
104
                spendHintCache:   spendHintCache,
14✔
105
                confirmHintCache: confirmHintCache,
14✔
106

14✔
107
                blockCache:  blockCache,
14✔
108
                memNotifier: chainntnfs.NewMempoolNotifier(),
14✔
109

14✔
110
                quit: make(chan struct{}),
14✔
111
        }
14✔
112

14✔
113
        notifier.chainConn = chainConn.NewBitcoindClient()
14✔
114

14✔
115
        return notifier
14✔
116
}
14✔
117

118
// Start connects to the running bitcoind node over websockets, registers for
119
// block notifications, and finally launches all related helper goroutines.
120
func (b *BitcoindNotifier) Start() error {
8✔
121
        var startErr error
8✔
122
        b.start.Do(func() {
16✔
123
                startErr = b.startNotifier()
8✔
124
        })
8✔
125

126
        return startErr
8✔
127
}
128

129
// Stop shutsdown the BitcoindNotifier.
130
func (b *BitcoindNotifier) Stop() error {
14✔
131
        // Already shutting down?
14✔
132
        if atomic.AddInt32(&b.stopped, 1) != 1 {
14✔
133
                return nil
×
134
        }
×
135

136
        chainntnfs.Log.Info("bitcoind notifier shutting down...")
14✔
137
        defer chainntnfs.Log.Debug("bitcoind notifier shutdown complete")
14✔
138

14✔
139
        // Shutdown the rpc client, this gracefully disconnects from bitcoind,
14✔
140
        // and cleans up all related resources.
14✔
141
        b.chainConn.Stop()
14✔
142

14✔
143
        close(b.quit)
14✔
144
        b.wg.Wait()
14✔
145

14✔
146
        // Notify all pending clients of our shutdown by closing the related
14✔
147
        // notification channels.
14✔
148
        for _, epochClient := range b.blockEpochClients {
62✔
149
                close(epochClient.cancelChan)
48✔
150
                epochClient.wg.Wait()
48✔
151

48✔
152
                close(epochClient.epochChan)
48✔
153
        }
48✔
154

155
        // The txNotifier is only initialized in the start method therefore we
156
        // need to make sure we don't access a nil pointer here.
157
        if b.txNotifier != nil {
28✔
158
                b.txNotifier.TearDown()
14✔
159
        }
14✔
160

161
        // Stop the mempool notifier.
162
        b.memNotifier.TearDown()
14✔
163

14✔
164
        return nil
14✔
165
}
166

167
// Started returns true if this instance has been started, and false otherwise.
168
func (b *BitcoindNotifier) Started() bool {
2✔
169
        return atomic.LoadInt32(&b.active) != 0
2✔
170
}
2✔
171

172
func (b *BitcoindNotifier) startNotifier() error {
8✔
173
        // Connect to bitcoind, and register for notifications on connected,
8✔
174
        // and disconnected blocks.
8✔
175
        if err := b.chainConn.Start(); err != nil {
8✔
UNCOV
176
                return err
×
UNCOV
177
        }
×
178
        if err := b.chainConn.NotifyBlocks(); err != nil {
8✔
179
                return err
×
180
        }
×
181

182
        currentHash, currentHeight, err := b.chainConn.GetBestBlock()
8✔
183
        if err != nil {
8✔
184
                return err
×
UNCOV
185
        }
×
186
        blockHeader, err := b.chainConn.GetBlockHeader(currentHash)
8✔
187
        if err != nil {
8✔
UNCOV
188
                return err
×
UNCOV
189
        }
×
190

191
        b.txNotifier = chainntnfs.NewTxNotifier(
8✔
192
                uint32(currentHeight), chainntnfs.ReorgSafetyLimit,
8✔
193
                b.confirmHintCache, b.spendHintCache,
8✔
194
        )
8✔
195

8✔
196
        b.bestBlock = chainntnfs.BlockEpoch{
8✔
197
                Height:      currentHeight,
8✔
198
                Hash:        currentHash,
8✔
199
                BlockHeader: blockHeader,
8✔
200
        }
8✔
201

8✔
202
        b.wg.Add(1)
8✔
203
        go b.notificationDispatcher()
8✔
204

8✔
205
        // Set the active flag now that we've completed the full
8✔
206
        // startup.
8✔
207
        atomic.StoreInt32(&b.active, 1)
8✔
208

8✔
209
        return nil
8✔
210
}
211

212
// notificationDispatcher is the primary goroutine which handles client
213
// notification registrations, as well as notification dispatches.
214
func (b *BitcoindNotifier) notificationDispatcher() {
14✔
215
        defer b.wg.Done()
14✔
216

14✔
217
out:
14✔
218
        for {
856✔
219
                select {
842✔
220
                case cancelMsg := <-b.notificationCancels:
4✔
221
                        switch msg := cancelMsg.(type) {
4✔
222
                        case *epochCancel:
4✔
223
                                chainntnfs.Log.Infof("Cancelling epoch "+
4✔
224
                                        "notification, epoch_id=%v", msg.epochID)
4✔
225

4✔
226
                                // First, we'll lookup the original
4✔
227
                                // registration in order to stop the active
4✔
228
                                // queue goroutine.
4✔
229
                                reg := b.blockEpochClients[msg.epochID]
4✔
230
                                reg.epochQueue.Stop()
4✔
231

4✔
232
                                // Next, close the cancel channel for this
4✔
233
                                // specific client, and wait for the client to
4✔
234
                                // exit.
4✔
235
                                close(b.blockEpochClients[msg.epochID].cancelChan)
4✔
236
                                b.blockEpochClients[msg.epochID].wg.Wait()
4✔
237

4✔
238
                                // Once the client has exited, we can then
4✔
239
                                // safely close the channel used to send epoch
4✔
240
                                // notifications, in order to notify any
4✔
241
                                // listeners that the intent has been
4✔
242
                                // canceled.
4✔
243
                                close(b.blockEpochClients[msg.epochID].epochChan)
4✔
244
                                delete(b.blockEpochClients, msg.epochID)
4✔
245

246
                        }
247
                case registerMsg := <-b.notificationRegistry:
119✔
248
                        switch msg := registerMsg.(type) {
119✔
249
                        case *chainntnfs.HistoricalConfDispatch:
67✔
250
                                // Look up whether the transaction is already
67✔
251
                                // included in the active chain. We'll do this
67✔
252
                                // in a goroutine to prevent blocking
67✔
253
                                // potentially long rescans.
67✔
254
                                //
67✔
255
                                // TODO(wilmer): add retry logic if rescan fails?
67✔
256
                                b.wg.Add(1)
67✔
257

67✔
258
                                //nolint:lll
67✔
259
                                go func(msg *chainntnfs.HistoricalConfDispatch) {
134✔
260
                                        defer b.wg.Done()
67✔
261

67✔
262
                                        confDetails, _, err := b.historicalConfDetails(
67✔
263
                                                msg.ConfRequest,
67✔
264
                                                msg.StartHeight, msg.EndHeight,
67✔
265
                                        )
67✔
266
                                        if err != nil {
67✔
267
                                                chainntnfs.Log.Errorf("Rescan to "+
×
268
                                                        "determine the conf "+
×
269
                                                        "details of %v within "+
×
270
                                                        "range %d-%d failed: %v",
×
UNCOV
271
                                                        msg.ConfRequest,
×
UNCOV
272
                                                        msg.StartHeight,
×
UNCOV
273
                                                        msg.EndHeight, err)
×
UNCOV
274
                                                return
×
UNCOV
275
                                        }
×
276

277
                                        // If the historical dispatch finished
278
                                        // without error, we will invoke
279
                                        // UpdateConfDetails even if none were
280
                                        // found. This allows the notifier to
281
                                        // begin safely updating the height hint
282
                                        // cache at tip, since any pending
283
                                        // rescans have now completed.
284
                                        err = b.txNotifier.UpdateConfDetails(
67✔
285
                                                msg.ConfRequest, confDetails,
67✔
286
                                        )
67✔
287
                                        if err != nil {
67✔
UNCOV
288
                                                chainntnfs.Log.Errorf("Unable "+
×
UNCOV
289
                                                        "to update conf "+
×
UNCOV
290
                                                        "details of %v: %v",
×
UNCOV
291
                                                        msg.ConfRequest, err)
×
UNCOV
292
                                        }
×
293
                                }(msg)
294

295
                        case *chainntnfs.HistoricalSpendDispatch:
6✔
296
                                // In order to ensure we don't block the caller
6✔
297
                                // on what may be a long rescan, we'll launch a
6✔
298
                                // goroutine to do so in the background.
6✔
299
                                //
6✔
300
                                // TODO(wilmer): add retry logic if rescan fails?
6✔
301
                                b.wg.Add(1)
6✔
302

6✔
303
                                //nolint:lll
6✔
304
                                go func(msg *chainntnfs.HistoricalSpendDispatch) {
12✔
305
                                        defer b.wg.Done()
6✔
306

6✔
307
                                        spendDetails, err := b.historicalSpendDetails(
6✔
308
                                                msg.SpendRequest,
6✔
309
                                                msg.StartHeight, msg.EndHeight,
6✔
310
                                        )
6✔
311
                                        if err != nil {
6✔
312
                                                chainntnfs.Log.Errorf("Rescan to "+
×
313
                                                        "determine the spend "+
×
314
                                                        "details of %v within "+
×
315
                                                        "range %d-%d failed: %v",
×
UNCOV
316
                                                        msg.SpendRequest,
×
UNCOV
317
                                                        msg.StartHeight,
×
UNCOV
318
                                                        msg.EndHeight, err)
×
UNCOV
319
                                                return
×
UNCOV
320
                                        }
×
321

322
                                        chainntnfs.Log.Infof("Historical "+
6✔
323
                                                "spend dispatch finished "+
6✔
324
                                                "for request %v (start=%v "+
6✔
325
                                                "end=%v) with details: %v",
6✔
326
                                                msg.SpendRequest,
6✔
327
                                                msg.StartHeight, msg.EndHeight,
6✔
328
                                                spendDetails)
6✔
329

6✔
330
                                        // If the historical dispatch finished
6✔
331
                                        // without error, we will invoke
6✔
332
                                        // UpdateSpendDetails even if none were
6✔
333
                                        // found. This allows the notifier to
6✔
334
                                        // begin safely updating the height hint
6✔
335
                                        // cache at tip, since any pending
6✔
336
                                        // rescans have now completed.
6✔
337
                                        err = b.txNotifier.UpdateSpendDetails(
6✔
338
                                                msg.SpendRequest, spendDetails,
6✔
339
                                        )
6✔
340
                                        if err != nil {
6✔
UNCOV
341
                                                chainntnfs.Log.Errorf("Unable "+
×
UNCOV
342
                                                        "to update spend "+
×
UNCOV
343
                                                        "details of %v: %v",
×
UNCOV
344
                                                        msg.SpendRequest, err)
×
UNCOV
345
                                        }
×
346
                                }(msg)
347

348
                        case *blockEpochRegistration:
50✔
349
                                chainntnfs.Log.Infof("New block epoch subscription")
50✔
350

50✔
351
                                b.blockEpochClients[msg.epochID] = msg
50✔
352

50✔
353
                                // If the client did not provide their best
50✔
354
                                // known block, then we'll immediately dispatch
50✔
355
                                // a notification for the current tip.
50✔
356
                                if msg.bestBlock == nil {
90✔
357
                                        b.notifyBlockEpochClient(
40✔
358
                                                msg, b.bestBlock.Height,
40✔
359
                                                b.bestBlock.Hash,
40✔
360
                                                b.bestBlock.BlockHeader,
40✔
361
                                        )
40✔
362

40✔
363
                                        msg.errorChan <- nil
40✔
364
                                        continue
40✔
365
                                }
366

367
                                // Otherwise, we'll attempt to deliver the
368
                                // backlog of notifications from their best
369
                                // known block.
370
                                missedBlocks, err := chainntnfs.GetClientMissedBlocks(
12✔
371
                                        b.chainConn, msg.bestBlock,
12✔
372
                                        b.bestBlock.Height, true,
12✔
373
                                )
12✔
374
                                if err != nil {
13✔
375
                                        msg.errorChan <- err
1✔
376
                                        continue
1✔
377
                                }
378

379
                                for _, block := range missedBlocks {
114✔
380
                                        b.notifyBlockEpochClient(
102✔
381
                                                msg, block.Height, block.Hash,
102✔
382
                                                block.BlockHeader,
102✔
383
                                        )
102✔
384
                                }
102✔
385

386
                                msg.errorChan <- nil
12✔
387
                        }
388

389
                case ntfn := <-b.chainConn.Notifications():
711✔
390
                        switch item := ntfn.(type) {
711✔
391
                        case chain.BlockConnected:
318✔
392
                                blockHeader, err :=
318✔
393
                                        b.chainConn.GetBlockHeader(&item.Hash)
318✔
394
                                if err != nil {
318✔
UNCOV
395
                                        chainntnfs.Log.Errorf("Unable to fetch "+
×
UNCOV
396
                                                "block header: %v", err)
×
UNCOV
397
                                        continue
×
398
                                }
399

400
                                if blockHeader.PrevBlock != *b.bestBlock.Hash {
323✔
401
                                        // Handle the case where the notifier
5✔
402
                                        // missed some blocks from its chain
5✔
403
                                        // backend.
5✔
404
                                        chainntnfs.Log.Infof("Missed blocks, " +
5✔
405
                                                "attempting to catch up")
5✔
406
                                        newBestBlock, missedBlocks, err :=
5✔
407
                                                chainntnfs.HandleMissedBlocks(
5✔
408
                                                        b.chainConn,
5✔
409
                                                        b.txNotifier,
5✔
410
                                                        b.bestBlock, item.Height,
5✔
411
                                                        true,
5✔
412
                                                )
5✔
413

5✔
414
                                        if err != nil {
6✔
415
                                                // Set the bestBlock here in case
1✔
416
                                                // a catch up partially completed.
1✔
417
                                                b.bestBlock = newBestBlock
1✔
418
                                                chainntnfs.Log.Error(err)
1✔
419
                                                continue
1✔
420
                                        }
421

422
                                        for _, block := range missedBlocks {
46✔
423
                                                err := b.handleBlockConnected(block)
42✔
424
                                                if err != nil {
42✔
UNCOV
425
                                                        chainntnfs.Log.Error(err)
×
UNCOV
426
                                                        continue out
×
427
                                                }
428
                                        }
429
                                }
430

431
                                newBlock := chainntnfs.BlockEpoch{
318✔
432
                                        Height:      item.Height,
318✔
433
                                        Hash:        &item.Hash,
318✔
434
                                        BlockHeader: blockHeader,
318✔
435
                                }
318✔
436
                                if err := b.handleBlockConnected(newBlock); err != nil {
318✔
UNCOV
437
                                        chainntnfs.Log.Error(err)
×
UNCOV
438
                                }
×
439

440
                                continue
318✔
441

442
                        case chain.BlockDisconnected:
10✔
443
                                if item.Height != b.bestBlock.Height {
10✔
UNCOV
444
                                        chainntnfs.Log.Infof("Missed disconnected" +
×
UNCOV
445
                                                "blocks, attempting to catch up")
×
UNCOV
446
                                }
×
447

448
                                newBestBlock, err := chainntnfs.RewindChain(
10✔
449
                                        b.chainConn, b.txNotifier,
10✔
450
                                        b.bestBlock, item.Height-1,
10✔
451
                                )
10✔
452
                                if err != nil {
10✔
UNCOV
453
                                        chainntnfs.Log.Errorf("Unable to rewind chain "+
×
UNCOV
454
                                                "from height %d to height %d: %v",
×
UNCOV
455
                                                b.bestBlock.Height, item.Height-1, err)
×
UNCOV
456
                                }
×
457

458
                                // Set the bestBlock here in case a chain
459
                                // rewind partially completed.
460
                                b.bestBlock = newBestBlock
10✔
461

462
                        case chain.RelevantTx:
63✔
463
                                tx := btcutil.NewTx(&item.TxRecord.MsgTx)
63✔
464

63✔
465
                                // Init values.
63✔
466
                                isMempool := false
63✔
467
                                height := uint32(0)
63✔
468

63✔
469
                                // Unwrap values.
63✔
470
                                if item.Block == nil {
100✔
471
                                        isMempool = true
37✔
472
                                } else {
65✔
473
                                        height = uint32(item.Block.Height)
28✔
474
                                }
28✔
475

476
                                // Handle the transaction.
477
                                b.handleRelevantTx(tx, isMempool, height)
63✔
478
                        }
479

480
                case <-b.quit:
14✔
481
                        break out
14✔
482
                }
483
        }
484
}
485

486
// handleRelevantTx handles a new transaction that has been seen either in a
487
// block or in the mempool. If in mempool, it will ask the mempool notifier to
488
// handle it. If in a block, it will ask the txNotifier to handle it, and
489
// cancel any relevant subscriptions made in the mempool.
490
func (b *BitcoindNotifier) handleRelevantTx(tx *btcutil.Tx,
491
        mempool bool, height uint32) {
63✔
492

63✔
493
        // If this is a mempool spend, we'll ask the mempool notifier to hanlde
63✔
494
        // it.
63✔
495
        if mempool {
100✔
496
                err := b.memNotifier.ProcessRelevantSpendTx(tx)
37✔
497
                if err != nil {
37✔
UNCOV
498
                        chainntnfs.Log.Errorf("Unable to process transaction "+
×
UNCOV
499
                                "%v: %v", tx.Hash(), err)
×
UNCOV
500
                }
×
501

502
                return
37✔
503
        }
504

505
        // Otherwise this is a confirmed spend, and we'll ask the tx notifier
506
        // to handle it.
507
        err := b.txNotifier.ProcessRelevantSpendTx(tx, height)
28✔
508
        if err != nil {
28✔
UNCOV
509
                chainntnfs.Log.Errorf("Unable to process transaction %v: %v",
×
UNCOV
510
                        tx.Hash(), err)
×
UNCOV
511

×
UNCOV
512
                return
×
UNCOV
513
        }
×
514

515
        // Once the tx is processed, we will ask the memNotifier to unsubscribe
516
        // the input.
517
        //
518
        // NOTE(yy): we could build it into txNotifier.ProcessRelevantSpendTx,
519
        // but choose to implement it here so we can easily decouple the two
520
        // notifiers in the future.
521
        b.memNotifier.UnsubsribeConfirmedSpentTx(tx)
28✔
522
}
523

524
// historicalConfDetails looks up whether a confirmation request (txid/output
525
// script) has already been included in a block in the active chain and, if so,
526
// returns details about said block.
527
func (b *BitcoindNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequest,
528
        startHeight, endHeight uint32) (*chainntnfs.TxConfirmation,
529
        chainntnfs.TxConfStatus, error) {
77✔
530

77✔
531
        // If a txid was not provided, then we should dispatch upon seeing the
77✔
532
        // script on-chain, so we'll short-circuit straight to scanning manually
77✔
533
        // as there doesn't exist a script index to query.
77✔
534
        if confRequest.TxID == chainntnfs.ZeroHash {
107✔
535
                return b.confDetailsManually(
30✔
536
                        confRequest, startHeight, endHeight,
30✔
537
                )
30✔
538
        }
30✔
539

540
        // Otherwise, we'll dispatch upon seeing a transaction on-chain with the
541
        // given hash.
542
        //
543
        // We'll first attempt to retrieve the transaction using the node's
544
        // txindex.
545
        txNotFoundErr := "No such mempool or blockchain transaction"
47✔
546
        txConf, txStatus, err := chainntnfs.ConfDetailsFromTxIndex(
47✔
547
                b.chainConn, confRequest, txNotFoundErr,
47✔
548
        )
47✔
549

47✔
550
        // We'll then check the status of the transaction lookup returned to
47✔
551
        // determine whether we should proceed with any fallback methods.
47✔
552
        switch {
47✔
553

554
        // We failed querying the index for the transaction, fall back to
555
        // scanning manually.
556
        case err != nil:
8✔
557
                chainntnfs.Log.Debugf("Failed getting conf details from "+
8✔
558
                        "index (%v), scanning manually", err)
8✔
559
                return b.confDetailsManually(confRequest, startHeight, endHeight)
8✔
560

561
        // The transaction was found within the node's mempool.
562
        case txStatus == chainntnfs.TxFoundMempool:
17✔
563

564
        // The transaction was found within the node's txindex.
565
        case txStatus == chainntnfs.TxFoundIndex:
10✔
566

567
        // The transaction was not found within the node's mempool or txindex.
568
        case txStatus == chainntnfs.TxNotFoundIndex:
16✔
569

570
        // Unexpected txStatus returned.
UNCOV
571
        default:
×
UNCOV
572
                return nil, txStatus,
×
UNCOV
573
                        fmt.Errorf("Got unexpected txConfStatus: %v", txStatus)
×
574
        }
575

576
        return txConf, txStatus, nil
39✔
577
}
578

579
// confDetailsManually looks up whether a transaction/output script has already
580
// been included in a block in the active chain by scanning the chain's blocks
581
// within the given range. If the transaction/output script is found, its
582
// confirmation details are returned. Otherwise, nil is returned.
583
func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest,
584
        heightHint, currentHeight uint32) (*chainntnfs.TxConfirmation,
585
        chainntnfs.TxConfStatus, error) {
38✔
586

38✔
587
        // Begin scanning blocks at every height to determine where the
38✔
588
        // transaction was included in.
38✔
589
        for height := currentHeight; height >= heightHint && height > 0; height-- {
100✔
590
                // Ensure we haven't been requested to shut down before
62✔
591
                // processing the next height.
62✔
592
                select {
62✔
UNCOV
593
                case <-b.quit:
×
UNCOV
594
                        return nil, chainntnfs.TxNotFoundManually,
×
UNCOV
595
                                chainntnfs.ErrChainNotifierShuttingDown
×
596
                default:
62✔
597
                }
598

599
                blockHash, err := b.chainConn.GetBlockHash(int64(height))
62✔
600
                if err != nil {
62✔
UNCOV
601
                        return nil, chainntnfs.TxNotFoundManually,
×
UNCOV
602
                                fmt.Errorf("unable to get hash from block "+
×
603
                                        "with height %d", height)
×
604
                }
×
605

606
                block, err := b.GetBlock(blockHash)
62✔
607
                if err != nil {
62✔
UNCOV
608
                        return nil, chainntnfs.TxNotFoundManually,
×
UNCOV
609
                                fmt.Errorf("unable to get block with hash "+
×
UNCOV
610
                                        "%v: %v", blockHash, err)
×
UNCOV
611
                }
×
612

613
                // For every transaction in the block, check which one matches
614
                // our request. If we find one that does, we can dispatch its
615
                // confirmation details.
616
                for txIndex, tx := range block.Transactions {
160✔
617
                        if !confRequest.MatchesTx(tx) {
190✔
618
                                continue
92✔
619
                        }
620

621
                        return &chainntnfs.TxConfirmation{
6✔
622
                                Tx:          tx.Copy(),
6✔
623
                                BlockHash:   blockHash,
6✔
624
                                BlockHeight: height,
6✔
625
                                TxIndex:     uint32(txIndex),
6✔
626
                                Block:       block,
6✔
627
                        }, chainntnfs.TxFoundManually, nil
6✔
628
                }
629
        }
630

631
        // If we reach here, then we were not able to find the transaction
632
        // within a block, so we avoid returning an error.
633
        return nil, chainntnfs.TxNotFoundManually, nil
32✔
634
}
635

636
// handleBlockConnected applies a chain update for a new block. Any watched
637
// transactions included this block will processed to either send notifications
638
// now or after numConfirmations confs.
639
func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) error {
360✔
640
        // First, we'll fetch the raw block as we'll need to gather all the
360✔
641
        // transactions to determine whether any are relevant to our registered
360✔
642
        // clients.
360✔
643
        rawBlock, err := b.GetBlock(block.Hash)
360✔
644
        if err != nil {
360✔
UNCOV
645
                return fmt.Errorf("unable to get block: %w", err)
×
UNCOV
646
        }
×
647
        utilBlock := btcutil.NewBlock(rawBlock)
360✔
648

360✔
649
        // We'll then extend the txNotifier's height with the information of
360✔
650
        // this new block, which will handle all of the notification logic for
360✔
651
        // us.
360✔
652
        err = b.txNotifier.ConnectTip(utilBlock, uint32(block.Height))
360✔
653
        if err != nil {
360✔
UNCOV
654
                return fmt.Errorf("unable to connect tip: %w", err)
×
UNCOV
655
        }
×
656

657
        chainntnfs.Log.Infof("New block: height=%v, sha=%v", block.Height,
360✔
658
                block.Hash)
360✔
659

360✔
660
        // Now that we've guaranteed the new block extends the txNotifier's
360✔
661
        // current tip, we'll proceed to dispatch notifications to all of our
360✔
662
        // registered clients whom have had notifications fulfilled. Before
360✔
663
        // doing so, we'll make sure update our in memory state in order to
360✔
664
        // satisfy any client requests based upon the new block.
360✔
665
        b.bestBlock = block
360✔
666

360✔
667
        b.notifyBlockEpochs(block.Height, block.Hash, block.BlockHeader)
360✔
668
        return b.txNotifier.NotifyHeight(uint32(block.Height))
360✔
669
}
670

671
// notifyBlockEpochs notifies all registered block epoch clients of the newly
672
// connected block to the main chain.
673
func (b *BitcoindNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash.Hash,
674
        blockHeader *wire.BlockHeader) {
360✔
675

360✔
676
        for _, client := range b.blockEpochClients {
904✔
677
                b.notifyBlockEpochClient(client, newHeight, newSha, blockHeader)
544✔
678
        }
544✔
679
}
680

681
// notifyBlockEpochClient sends a registered block epoch client a notification
682
// about a specific block.
683
func (b *BitcoindNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistration,
684
        height int32, sha *chainhash.Hash, header *wire.BlockHeader) {
682✔
685

682✔
686
        epoch := &chainntnfs.BlockEpoch{
682✔
687
                Height:      height,
682✔
688
                Hash:        sha,
682✔
689
                BlockHeader: header,
682✔
690
        }
682✔
691

682✔
692
        select {
682✔
693
        case epochClient.epochQueue.ChanIn() <- epoch:
682✔
UNCOV
694
        case <-epochClient.cancelChan:
×
UNCOV
695
        case <-b.quit:
×
696
        }
697
}
698

699
// RegisterSpendNtfn registers an intent to be notified once the target
700
// outpoint/output script has been spent by a transaction on-chain. When
701
// intending to be notified of the spend of an output script, a nil outpoint
702
// must be used. The heightHint should represent the earliest height in the
703
// chain of the transaction that spent the outpoint/output script.
704
//
705
// Once a spend of has been detected, the details of the spending event will be
706
// sent across the 'Spend' channel.
707
func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
708
        pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error) {
54✔
709

54✔
710
        // Register the conf notification with the TxNotifier. A non-nil value
54✔
711
        // for `dispatch` will be returned if we are required to perform a
54✔
712
        // manual scan for the confirmation. Otherwise the notifier will begin
54✔
713
        // watching at tip for the transaction to confirm.
54✔
714
        ntfn, err := b.txNotifier.RegisterSpend(outpoint, pkScript, heightHint)
54✔
715
        if err != nil {
56✔
716
                return nil, err
2✔
717
        }
2✔
718

719
        // We'll then request the backend to notify us when it has detected the
720
        // outpoint/output script as spent.
721
        //
722
        // TODO(wilmer): use LoadFilter API instead.
723
        if outpoint == nil || *outpoint == chainntnfs.ZeroOutPoint {
80✔
724
                _, addrs, _, err := txscript.ExtractPkScriptAddrs(
26✔
725
                        pkScript, b.chainParams,
26✔
726
                )
26✔
727
                if err != nil {
26✔
728
                        return nil, fmt.Errorf("unable to parse script: %w",
×
UNCOV
729
                                err)
×
UNCOV
730
                }
×
731
                if err := b.chainConn.NotifyReceived(addrs); err != nil {
26✔
732
                        return nil, err
×
733
                }
×
734
        } else {
28✔
735
                ops := []*wire.OutPoint{outpoint}
28✔
736
                if err := b.chainConn.NotifySpent(ops); err != nil {
28✔
UNCOV
737
                        return nil, err
×
UNCOV
738
                }
×
739
        }
740

741
        // If the txNotifier didn't return any details to perform a historical
742
        // scan of the chain, then we can return early as there's nothing left
743
        // for us to do.
744
        if ntfn.HistoricalDispatch == nil {
104✔
745
                return ntfn.Event, nil
50✔
746
        }
50✔
747

748
        // Otherwise, we'll need to dispatch a historical rescan to determine if
749
        // the outpoint was already spent at a previous height.
750
        //
751
        // We'll short-circuit the path when dispatching the spend of a script,
752
        // rather than an outpoint, as there aren't any additional checks we can
753
        // make for scripts.
754
        if ntfn.HistoricalDispatch.OutPoint == chainntnfs.ZeroOutPoint {
8✔
755
                select {
2✔
756
                case b.notificationRegistry <- ntfn.HistoricalDispatch:
2✔
UNCOV
757
                case <-b.quit:
×
UNCOV
758
                        return nil, chainntnfs.ErrChainNotifierShuttingDown
×
759
                }
760

761
                return ntfn.Event, nil
2✔
762
        }
763

764
        // When dispatching spends of outpoints, there are a number of checks we
765
        // can make to start our rescan from a better height or completely avoid
766
        // it.
767
        //
768
        // We'll start by checking the backend's UTXO set to determine whether
769
        // the outpoint has been spent. If it hasn't, we can return to the
770
        // caller as well.
771
        txOut, err := b.chainConn.GetTxOut(&outpoint.Hash, outpoint.Index, true)
4✔
772
        if err != nil {
4✔
UNCOV
773
                return nil, err
×
UNCOV
774
        }
×
775
        if txOut != nil {
6✔
776
                // We'll let the txNotifier know the outpoint is still unspent
2✔
777
                // in order to begin updating its spend hint.
2✔
778
                err := b.txNotifier.UpdateSpendDetails(
2✔
779
                        ntfn.HistoricalDispatch.SpendRequest, nil,
2✔
780
                )
2✔
781
                if err != nil {
2✔
UNCOV
782
                        return nil, err
×
UNCOV
783
                }
×
784

785
                return ntfn.Event, nil
2✔
786
        }
787

788
        // Since the outpoint was spent, as it no longer exists within the UTXO
789
        // set, we'll determine when it happened by scanning the chain.
790
        //
791
        // As a minimal optimization, we'll query the backend's transaction
792
        // index (if enabled) to determine if we have a better rescan starting
793
        // height. We can do this as the GetRawTransaction call will return the
794
        // hash of the block it was included in within the chain.
795
        tx, err := b.chainConn.GetRawTransactionVerbose(&outpoint.Hash)
4✔
796
        if err != nil {
6✔
797
                // Avoid returning an error if the transaction was not found to
2✔
798
                // proceed with fallback methods.
2✔
799
                jsonErr, ok := err.(*btcjson.RPCError)
2✔
800
                if !ok || jsonErr.Code != btcjson.ErrRPCNoTxInfo {
2✔
UNCOV
801
                        return nil, fmt.Errorf("unable to query for txid "+
×
UNCOV
802
                                "%v: %w", outpoint.Hash, err)
×
UNCOV
803
                }
×
804
        }
805

806
        // If the transaction index was enabled, we'll use the block's hash to
807
        // retrieve its height and check whether it provides a better starting
808
        // point for our rescan.
809
        if tx != nil {
8✔
810
                // If the transaction containing the outpoint hasn't confirmed
4✔
811
                // on-chain, then there's no need to perform a rescan.
4✔
812
                if tx.BlockHash == "" {
6✔
813
                        return ntfn.Event, nil
2✔
814
                }
2✔
815

816
                blockHash, err := chainhash.NewHashFromStr(tx.BlockHash)
4✔
817
                if err != nil {
4✔
818
                        return nil, err
×
UNCOV
819
                }
×
820
                blockHeight, err := b.chainConn.GetBlockHeight(blockHash)
4✔
821
                if err != nil {
4✔
UNCOV
822
                        return nil, err
×
UNCOV
823
                }
×
824

825
                if uint32(blockHeight) > ntfn.HistoricalDispatch.StartHeight {
6✔
826
                        ntfn.HistoricalDispatch.StartHeight = uint32(blockHeight)
2✔
827
                }
2✔
828
        }
829

830
        // Now that we've determined the starting point of our rescan, we can
831
        // dispatch it and return.
832
        select {
4✔
833
        case b.notificationRegistry <- ntfn.HistoricalDispatch:
4✔
UNCOV
834
        case <-b.quit:
×
UNCOV
835
                return nil, chainntnfs.ErrChainNotifierShuttingDown
×
836
        }
837

838
        return ntfn.Event, nil
4✔
839
}
840

841
// historicalSpendDetails attempts to manually scan the chain within the given
842
// height range for a transaction that spends the given outpoint/output script.
843
// If one is found, the spend details are assembled and returned to the caller.
844
// If the spend is not found, a nil spend detail will be returned.
845
func (b *BitcoindNotifier) historicalSpendDetails(
846
        spendRequest chainntnfs.SpendRequest, startHeight, endHeight uint32) (
847
        *chainntnfs.SpendDetail, error) {
6✔
848

6✔
849
        // Begin scanning blocks at every height to determine if the outpoint
6✔
850
        // was spent.
6✔
851
        for height := endHeight; height >= startHeight && height > 0; height-- {
12✔
852
                // Ensure we haven't been requested to shut down before
6✔
853
                // processing the next height.
6✔
854
                select {
6✔
UNCOV
855
                case <-b.quit:
×
UNCOV
856
                        return nil, chainntnfs.ErrChainNotifierShuttingDown
×
857
                default:
6✔
858
                }
859

860
                // First, we'll fetch the block for the current height.
861
                blockHash, err := b.chainConn.GetBlockHash(int64(height))
6✔
862
                if err != nil {
6✔
863
                        return nil, fmt.Errorf("unable to retrieve hash for "+
×
864
                                "block with height %d: %v", height, err)
×
865
                }
×
866
                block, err := b.GetBlock(blockHash)
6✔
867
                if err != nil {
6✔
UNCOV
868
                        return nil, fmt.Errorf("unable to retrieve block "+
×
UNCOV
869
                                "with hash %v: %v", blockHash, err)
×
UNCOV
870
                }
×
871

872
                // Then, we'll manually go over every input in every transaction
873
                // in it and determine whether it spends the request in
874
                // question. If we find one, we'll dispatch the spend details.
875
                for _, tx := range block.Transactions {
16✔
876
                        matches, inputIdx, err := spendRequest.MatchesTx(tx)
10✔
877
                        if err != nil {
10✔
UNCOV
878
                                return nil, err
×
UNCOV
879
                        }
×
880
                        if !matches {
20✔
881
                                continue
10✔
882
                        }
883

884
                        txCopy := tx.Copy()
2✔
885
                        txHash := txCopy.TxHash()
2✔
886
                        spendOutPoint := &txCopy.TxIn[inputIdx].PreviousOutPoint
2✔
887
                        return &chainntnfs.SpendDetail{
2✔
888
                                SpentOutPoint:     spendOutPoint,
2✔
889
                                SpenderTxHash:     &txHash,
2✔
890
                                SpendingTx:        txCopy,
2✔
891
                                SpenderInputIndex: inputIdx,
2✔
892
                                SpendingHeight:    int32(height),
2✔
893
                        }, nil
2✔
894
                }
895
        }
896

897
        return nil, nil
6✔
898
}
899

900
// RegisterConfirmationsNtfn registers an intent to be notified once the target
901
// txid/output script has reached numConfs confirmations on-chain. When
902
// intending to be notified of the confirmation of an output script, a nil txid
903
// must be used. The heightHint should represent the earliest height at which
904
// the txid/output script could have been included in the chain.
905
//
906
// Progress on the number of confirmations left can be read from the 'Updates'
907
// channel. Once it has reached all of its confirmations, a notification will be
908
// sent across the 'Confirmed' channel.
909
func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
910
        pkScript []byte, numConfs, heightHint uint32,
911
        opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
98✔
912

98✔
913
        // Register the conf notification with the TxNotifier. A non-nil value
98✔
914
        // for `dispatch` will be returned if we are required to perform a
98✔
915
        // manual scan for the confirmation. Otherwise the notifier will begin
98✔
916
        // watching at tip for the transaction to confirm.
98✔
917
        ntfn, err := b.txNotifier.RegisterConf(
98✔
918
                txid, pkScript, numConfs, heightHint, opts...,
98✔
919
        )
98✔
920
        if err != nil {
98✔
UNCOV
921
                return nil, err
×
UNCOV
922
        }
×
923

924
        if ntfn.HistoricalDispatch == nil {
131✔
925
                return ntfn.Event, nil
33✔
926
        }
33✔
927

928
        select {
67✔
929
        case b.notificationRegistry <- ntfn.HistoricalDispatch:
67✔
930
                return ntfn.Event, nil
67✔
UNCOV
931
        case <-b.quit:
×
UNCOV
932
                return nil, chainntnfs.ErrChainNotifierShuttingDown
×
933
        }
934
}
935

936
// blockEpochRegistration represents a client's intent to receive a
937
// notification with each newly connected block.
938
type blockEpochRegistration struct {
939
        epochID uint64
940

941
        epochChan chan *chainntnfs.BlockEpoch
942

943
        epochQueue *queue.ConcurrentQueue
944

945
        bestBlock *chainntnfs.BlockEpoch
946

947
        errorChan chan error
948

949
        cancelChan chan struct{}
950

951
        wg sync.WaitGroup
952
}
953

954
// epochCancel is a message sent to the BitcoindNotifier when a client wishes
955
// to cancel an outstanding epoch notification that has yet to be dispatched.
956
type epochCancel struct {
957
        epochID uint64
958
}
959

960
// RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the
961
// caller to receive notifications, of each new block connected to the main
962
// chain. Clients have the option of passing in their best known block, which
963
// the notifier uses to check if they are behind on blocks and catch them up. If
964
// they do not provide one, then a notification will be dispatched immediately
965
// for the current tip of the chain upon a successful registration.
966
func (b *BitcoindNotifier) RegisterBlockEpochNtfn(
967
        bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
50✔
968

50✔
969
        reg := &blockEpochRegistration{
50✔
970
                epochQueue: queue.NewConcurrentQueue(20),
50✔
971
                epochChan:  make(chan *chainntnfs.BlockEpoch, 20),
50✔
972
                cancelChan: make(chan struct{}),
50✔
973
                epochID:    atomic.AddUint64(&b.epochClientCounter, 1),
50✔
974
                bestBlock:  bestBlock,
50✔
975
                errorChan:  make(chan error, 1),
50✔
976
        }
50✔
977
        reg.epochQueue.Start()
50✔
978

50✔
979
        // Before we send the request to the main goroutine, we'll launch a new
50✔
980
        // goroutine to proxy items added to our queue to the client itself.
50✔
981
        // This ensures that all notifications are received *in order*.
50✔
982
        reg.wg.Add(1)
50✔
983
        go func() {
100✔
984
                defer reg.wg.Done()
50✔
985

50✔
986
                for {
688✔
987
                        select {
638✔
988
                        case ntfn := <-reg.epochQueue.ChanOut():
594✔
989
                                blockNtfn := ntfn.(*chainntnfs.BlockEpoch)
594✔
990
                                select {
594✔
991
                                case reg.epochChan <- blockNtfn:
590✔
992

993
                                case <-reg.cancelChan:
2✔
994
                                        return
2✔
995

996
                                case <-b.quit:
4✔
997
                                        return
4✔
998
                                }
999

1000
                        case <-reg.cancelChan:
4✔
1001
                                return
4✔
1002

1003
                        case <-b.quit:
44✔
1004
                                return
44✔
1005
                        }
1006
                }
1007
        }()
1008

1009
        select {
50✔
1010
        case <-b.quit:
×
1011
                // As we're exiting before the registration could be sent,
×
UNCOV
1012
                // we'll stop the queue now ourselves.
×
UNCOV
1013
                reg.epochQueue.Stop()
×
UNCOV
1014

×
UNCOV
1015
                return nil, errors.New("chainntnfs: system interrupt while " +
×
UNCOV
1016
                        "attempting to register for block epoch notification.")
×
1017
        case b.notificationRegistry <- reg:
50✔
1018
                return &chainntnfs.BlockEpochEvent{
50✔
1019
                        Epochs: reg.epochChan,
50✔
1020
                        Cancel: func() {
54✔
1021
                                cancel := &epochCancel{
4✔
1022
                                        epochID: reg.epochID,
4✔
1023
                                }
4✔
1024

4✔
1025
                                // Submit epoch cancellation to notification dispatcher.
4✔
1026
                                select {
4✔
1027
                                case b.notificationCancels <- cancel:
4✔
1028
                                        // Cancellation is being handled, drain the epoch channel until it is
4✔
1029
                                        // closed before yielding to caller.
4✔
1030
                                        for {
10✔
1031
                                                select {
6✔
1032
                                                case _, ok := <-reg.epochChan:
6✔
1033
                                                        if !ok {
10✔
1034
                                                                return
4✔
1035
                                                        }
4✔
1036
                                                case <-b.quit:
2✔
1037
                                                        return
2✔
1038
                                                }
1039
                                        }
1040
                                case <-b.quit:
2✔
1041
                                }
1042
                        },
1043
                }, nil
1044
        }
1045
}
1046

1047
// GetBlock is used to retrieve the block with the given hash. This function
1048
// wraps the blockCache's GetBlock function.
1049
func (b *BitcoindNotifier) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock,
1050
        error) {
426✔
1051

426✔
1052
        return b.blockCache.GetBlock(hash, b.chainConn.GetBlock)
426✔
1053
}
426✔
1054

1055
// SubscribeMempoolSpent allows the caller to register a subscription to watch
1056
// for a spend of an outpoint in the mempool.The event will be dispatched once
1057
// the outpoint is spent in the mempool.
1058
//
1059
// NOTE: part of the MempoolWatcher interface.
1060
func (b *BitcoindNotifier) SubscribeMempoolSpent(
1061
        outpoint wire.OutPoint) (*chainntnfs.MempoolSpendEvent, error) {
2✔
1062

2✔
1063
        event := b.memNotifier.SubscribeInput(outpoint)
2✔
1064

2✔
1065
        ops := []*wire.OutPoint{&outpoint}
2✔
1066

2✔
1067
        return event, b.chainConn.NotifySpent(ops)
2✔
1068
}
2✔
1069

1070
// CancelMempoolSpendEvent allows the caller to cancel a subscription to watch
1071
// for a spend of an outpoint in the mempool.
1072
//
1073
// NOTE: part of the MempoolWatcher interface.
1074
func (b *BitcoindNotifier) CancelMempoolSpendEvent(
1075
        sub *chainntnfs.MempoolSpendEvent) {
2✔
1076

2✔
1077
        b.memNotifier.UnsubscribeEvent(sub)
2✔
1078
}
2✔
1079

1080
// LookupInputMempoolSpend takes an outpoint and queries the mempool to find
1081
// its spending tx. Returns the tx if found, otherwise fn.None.
1082
//
1083
// NOTE: part of the MempoolWatcher interface.
1084
func (b *BitcoindNotifier) LookupInputMempoolSpend(
1085
        op wire.OutPoint) fn.Option[wire.MsgTx] {
2✔
1086

2✔
1087
        // Find the spending txid.
2✔
1088
        txid, found := b.chainConn.LookupInputMempoolSpend(op)
2✔
1089
        if !found {
4✔
1090
                return fn.None[wire.MsgTx]()
2✔
1091
        }
2✔
1092

1093
        // Query the spending tx using the id.
1094
        tx, err := b.chainConn.GetRawTransaction(&txid)
2✔
1095
        if err != nil {
2✔
UNCOV
1096
                // TODO(yy): enable logging errors in this package.
×
UNCOV
1097
                return fn.None[wire.MsgTx]()
×
UNCOV
1098
        }
×
1099

1100
        return fn.Some(*tx.MsgTx().Copy())
2✔
1101
}
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