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

lightningnetwork / lnd / 16181619122

09 Jul 2025 10:33PM UTC coverage: 55.326% (-2.3%) from 57.611%
16181619122

Pull #10060

github

web-flow
Merge d15e8671f into 0e830da9d
Pull Request #10060: sweep: fix expected spending events being missed

9 of 26 new or added lines in 2 files covered. (34.62%)

23695 existing lines in 280 files now uncovered.

108518 of 196143 relevant lines covered (55.33%)

22354.81 hits per line

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

72.53
/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/v2"
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 {
12✔
95

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

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

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

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

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

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

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

12✔
115
        return notifier
12✔
116
}
12✔
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 {
6✔
121
        var startErr error
6✔
122
        b.start.Do(func() {
12✔
123
                startErr = b.startNotifier()
6✔
124
        })
6✔
125

126
        return startErr
6✔
127
}
128

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

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

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

12✔
144
        close(b.quit)
12✔
145
        b.wg.Wait()
12✔
146

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

46✔
153
                close(epochClient.epochChan)
46✔
154
        }
46✔
155

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

162
        // Stop the mempool notifier.
163
        b.memNotifier.TearDown()
12✔
164

12✔
165
        return nil
12✔
166
}
167

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

173
func (b *BitcoindNotifier) startNotifier() error {
6✔
174
        chainntnfs.Log.Infof("bitcoind notifier starting...")
6✔
175

6✔
176
        // Connect to bitcoind, and register for notifications on connected,
6✔
177
        // and disconnected blocks.
6✔
178
        if err := b.chainConn.Start(); err != nil {
6✔
179
                return err
×
180
        }
×
181
        if err := b.chainConn.NotifyBlocks(); err != nil {
6✔
182
                return err
×
183
        }
×
184

185
        currentHash, currentHeight, err := b.chainConn.GetBestBlock()
6✔
186
        if err != nil {
6✔
187
                return err
×
188
        }
×
189
        blockHeader, err := b.chainConn.GetBlockHeader(currentHash)
6✔
190
        if err != nil {
6✔
191
                return err
×
192
        }
×
193

194
        b.txNotifier = chainntnfs.NewTxNotifier(
6✔
195
                uint32(currentHeight), chainntnfs.ReorgSafetyLimit,
6✔
196
                b.confirmHintCache, b.spendHintCache,
6✔
197
        )
6✔
198

6✔
199
        b.bestBlock = chainntnfs.BlockEpoch{
6✔
200
                Height:      currentHeight,
6✔
201
                Hash:        currentHash,
6✔
202
                BlockHeader: blockHeader,
6✔
203
        }
6✔
204

6✔
205
        b.wg.Add(1)
6✔
206
        go b.notificationDispatcher()
6✔
207

6✔
208
        // Set the active flag now that we've completed the full
6✔
209
        // startup.
6✔
210
        atomic.StoreInt32(&b.active, 1)
6✔
211

6✔
212
        chainntnfs.Log.Debugf("bitcoind notifier started")
6✔
213

6✔
214
        return nil
6✔
215
}
216

217
// notificationDispatcher is the primary goroutine which handles client
218
// notification registrations, as well as notification dispatches.
219
func (b *BitcoindNotifier) notificationDispatcher() {
12✔
220
        defer b.wg.Done()
12✔
221

12✔
222
out:
12✔
223
        for {
850✔
224
                select {
838✔
225
                case cancelMsg := <-b.notificationCancels:
2✔
226
                        switch msg := cancelMsg.(type) {
2✔
227
                        case *epochCancel:
2✔
228
                                chainntnfs.Log.Infof("Cancelling epoch "+
2✔
229
                                        "notification, epoch_id=%v", msg.epochID)
2✔
230

2✔
231
                                // First, we'll lookup the original
2✔
232
                                // registration in order to stop the active
2✔
233
                                // queue goroutine.
2✔
234
                                reg := b.blockEpochClients[msg.epochID]
2✔
235
                                reg.epochQueue.Stop()
2✔
236

2✔
237
                                // Next, close the cancel channel for this
2✔
238
                                // specific client, and wait for the client to
2✔
239
                                // exit.
2✔
240
                                close(b.blockEpochClients[msg.epochID].cancelChan)
2✔
241
                                b.blockEpochClients[msg.epochID].wg.Wait()
2✔
242

2✔
243
                                // Once the client has exited, we can then
2✔
244
                                // safely close the channel used to send epoch
2✔
245
                                // notifications, in order to notify any
2✔
246
                                // listeners that the intent has been
2✔
247
                                // canceled.
2✔
248
                                close(b.blockEpochClients[msg.epochID].epochChan)
2✔
249
                                delete(b.blockEpochClients, msg.epochID)
2✔
250

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

63✔
263
                                //nolint:ll
63✔
264
                                go func(msg *chainntnfs.HistoricalConfDispatch) {
126✔
265
                                        defer b.wg.Done()
63✔
266

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

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

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

4✔
308
                                //nolint:ll
4✔
309
                                go func(msg *chainntnfs.HistoricalSpendDispatch) {
8✔
310
                                        defer b.wg.Done()
4✔
311

4✔
312
                                        spendDetails, err := b.historicalSpendDetails(
4✔
313
                                                msg.SpendRequest,
4✔
314
                                                msg.StartHeight, msg.EndHeight,
4✔
315
                                        )
4✔
316
                                        if err != nil {
4✔
317
                                                chainntnfs.Log.Errorf("Rescan to "+
×
318
                                                        "determine the spend "+
×
319
                                                        "details of %v within "+
×
320
                                                        "range %d-%d failed: %v",
×
321
                                                        msg.SpendRequest,
×
322
                                                        msg.StartHeight,
×
323
                                                        msg.EndHeight, err)
×
324
                                                return
×
325
                                        }
×
326

327
                                        chainntnfs.Log.Infof("Historical "+
4✔
328
                                                "spend dispatch finished "+
4✔
329
                                                "for request %v (start=%v "+
4✔
330
                                                "end=%v) with details: %v",
4✔
331
                                                msg.SpendRequest,
4✔
332
                                                msg.StartHeight, msg.EndHeight,
4✔
333
                                                spendDetails)
4✔
334

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

353
                        case *blockEpochRegistration:
48✔
354
                                chainntnfs.Log.Infof("New block epoch subscription")
48✔
355

48✔
356
                                b.blockEpochClients[msg.epochID] = msg
48✔
357

48✔
358
                                // If the client did not provide their best
48✔
359
                                // known block, then we'll immediately dispatch
48✔
360
                                // a notification for the current tip.
48✔
361
                                if msg.bestBlock == nil {
86✔
362
                                        b.notifyBlockEpochClient(
38✔
363
                                                msg, b.bestBlock.Height,
38✔
364
                                                b.bestBlock.Hash,
38✔
365
                                                b.bestBlock.BlockHeader,
38✔
366
                                        )
38✔
367

38✔
368
                                        msg.errorChan <- nil
38✔
369
                                        continue
38✔
370
                                }
371

372
                                // Otherwise, we'll attempt to deliver the
373
                                // backlog of notifications from their best
374
                                // known block.
375
                                missedBlocks, err := chainntnfs.GetClientMissedBlocks(
10✔
376
                                        b.chainConn, msg.bestBlock,
10✔
377
                                        b.bestBlock.Height, true,
10✔
378
                                )
10✔
379
                                if err != nil {
10✔
UNCOV
380
                                        msg.errorChan <- err
×
UNCOV
381
                                        continue
×
382
                                }
383

384
                                for _, block := range missedBlocks {
110✔
385
                                        b.notifyBlockEpochClient(
100✔
386
                                                msg, block.Height, block.Hash,
100✔
387
                                                block.BlockHeader,
100✔
388
                                        )
100✔
389
                                }
100✔
390

391
                                msg.errorChan <- nil
10✔
392
                        }
393

394
                case ntfn := <-b.chainConn.Notifications():
709✔
395
                        switch item := ntfn.(type) {
709✔
396
                        case chain.BlockConnected:
316✔
397
                                blockHeader, err :=
316✔
398
                                        b.chainConn.GetBlockHeader(&item.Hash)
316✔
399
                                if err != nil {
316✔
400
                                        chainntnfs.Log.Errorf("Unable to fetch "+
×
401
                                                "block header: %v", err)
×
402
                                        continue
×
403
                                }
404

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

4✔
419
                                        if err != nil {
4✔
420
                                                // Set the bestBlock here in case
×
421
                                                // a catch up partially completed.
×
422
                                                b.bestBlock = newBestBlock
×
423
                                                chainntnfs.Log.Error(err)
×
424
                                                continue
×
425
                                        }
426

427
                                        for _, block := range missedBlocks {
46✔
428
                                                err := b.handleBlockConnected(block)
42✔
429
                                                if err != nil {
42✔
430
                                                        chainntnfs.Log.Error(err)
×
431
                                                        continue out
×
432
                                                }
433
                                        }
434
                                }
435

436
                                newBlock := chainntnfs.BlockEpoch{
316✔
437
                                        Height:      item.Height,
316✔
438
                                        Hash:        &item.Hash,
316✔
439
                                        BlockHeader: blockHeader,
316✔
440
                                }
316✔
441
                                if err := b.handleBlockConnected(newBlock); err != nil {
316✔
442
                                        chainntnfs.Log.Error(err)
×
443
                                }
×
444

445
                                continue
316✔
446

447
                        case chain.BlockDisconnected:
9✔
448
                                if item.Height != b.bestBlock.Height {
9✔
449
                                        chainntnfs.Log.Infof("Missed disconnected" +
×
450
                                                "blocks, attempting to catch up")
×
451
                                }
×
452

453
                                newBestBlock, err := chainntnfs.RewindChain(
9✔
454
                                        b.chainConn, b.txNotifier,
9✔
455
                                        b.bestBlock, item.Height-1,
9✔
456
                                )
9✔
457
                                if err != nil {
9✔
458
                                        chainntnfs.Log.Errorf("Unable to rewind chain "+
×
459
                                                "from height %d to height %d: %v",
×
460
                                                b.bestBlock.Height, item.Height-1, err)
×
461
                                }
×
462

463
                                // Set the bestBlock here in case a chain
464
                                // rewind partially completed.
465
                                b.bestBlock = newBestBlock
9✔
466

467
                        case chain.RelevantTx:
60✔
468
                                tx := btcutil.NewTx(&item.TxRecord.MsgTx)
60✔
469

60✔
470
                                // Init values.
60✔
471
                                isMempool := false
60✔
472
                                height := uint32(0)
60✔
473

60✔
474
                                // Unwrap values.
60✔
475
                                if item.Block == nil {
94✔
476
                                        isMempool = true
34✔
477
                                } else {
60✔
478
                                        height = uint32(item.Block.Height)
26✔
479
                                }
26✔
480

481
                                // Handle the transaction.
482
                                b.handleRelevantTx(tx, isMempool, height)
60✔
483
                        }
484

485
                case <-b.quit:
12✔
486
                        break out
12✔
487
                }
488
        }
489
}
490

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

60✔
498
        // If this is a mempool spend, we'll ask the mempool notifier to handle
60✔
499
        // it.
60✔
500
        if mempool {
94✔
501
                err := b.memNotifier.ProcessRelevantSpendTx(tx)
34✔
502
                if err != nil {
34✔
503
                        chainntnfs.Log.Errorf("Unable to process transaction "+
×
504
                                "%v: %v", tx.Hash(), err)
×
505
                }
×
506

507
                return
34✔
508
        }
509

510
        // Otherwise this is a confirmed spend, and we'll ask the tx notifier
511
        // to handle it.
512
        err := b.txNotifier.ProcessRelevantSpendTx(tx, height)
26✔
513
        if err != nil {
26✔
514
                chainntnfs.Log.Errorf("Unable to process transaction %v: %v",
×
515
                        tx.Hash(), err)
×
516

×
517
                return
×
518
        }
×
519

520
        // Once the tx is processed, we will ask the memNotifier to unsubscribe
521
        // the input.
522
        //
523
        // NOTE(yy): we could build it into txNotifier.ProcessRelevantSpendTx,
524
        // but choose to implement it here so we can easily decouple the two
525
        // notifiers in the future.
526
        b.memNotifier.UnsubsribeConfirmedSpentTx(tx)
26✔
527
}
528

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

73✔
536
        // If a txid was not provided, then we should dispatch upon seeing the
73✔
537
        // script on-chain, so we'll short-circuit straight to scanning manually
73✔
538
        // as there doesn't exist a script index to query.
73✔
539
        if confRequest.TxID == chainntnfs.ZeroHash {
101✔
540
                return b.confDetailsManually(
28✔
541
                        confRequest, startHeight, endHeight,
28✔
542
                )
28✔
543
        }
28✔
544

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

45✔
555
        // We'll then check the status of the transaction lookup returned to
45✔
556
        // determine whether we should proceed with any fallback methods.
45✔
557
        switch {
45✔
558

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

566
        // The transaction was found within the node's mempool.
567
        case txStatus == chainntnfs.TxFoundMempool:
15✔
568

569
        // The transaction was found within the node's txindex.
570
        case txStatus == chainntnfs.TxFoundIndex:
8✔
571

572
        // The transaction was not found within the node's mempool or txindex.
573
        case txStatus == chainntnfs.TxNotFoundIndex:
14✔
574

575
        // Unexpected txStatus returned.
576
        default:
×
577
                return nil, txStatus,
×
578
                        fmt.Errorf("Got unexpected txConfStatus: %v", txStatus)
×
579
        }
580

581
        return txConf, txStatus, nil
37✔
582
}
583

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

36✔
592
        // Begin scanning blocks at every height to determine where the
36✔
593
        // transaction was included in.
36✔
594
        for height := currentHeight; height >= heightHint && height > 0; height-- {
96✔
595
                // Ensure we haven't been requested to shut down before
60✔
596
                // processing the next height.
60✔
597
                select {
60✔
598
                case <-b.quit:
×
599
                        return nil, chainntnfs.TxNotFoundManually,
×
600
                                chainntnfs.ErrChainNotifierShuttingDown
×
601
                default:
60✔
602
                }
603

604
                blockHash, err := b.chainConn.GetBlockHash(int64(height))
60✔
605
                if err != nil {
60✔
606
                        return nil, chainntnfs.TxNotFoundManually,
×
607
                                fmt.Errorf("unable to get hash from block "+
×
608
                                        "with height %d", height)
×
609
                }
×
610

611
                block, err := b.GetBlock(blockHash)
60✔
612
                if err != nil {
60✔
613
                        return nil, chainntnfs.TxNotFoundManually,
×
614
                                fmt.Errorf("unable to get block with hash "+
×
615
                                        "%v: %v", blockHash, err)
×
616
                }
×
617

618
                // For every transaction in the block, check which one matches
619
                // our request. If we find one that does, we can dispatch its
620
                // confirmation details.
621
                for txIndex, tx := range block.Transactions {
155✔
622
                        if !confRequest.MatchesTx(tx) {
184✔
623
                                continue
89✔
624
                        }
625

626
                        return &chainntnfs.TxConfirmation{
6✔
627
                                Tx:          tx.Copy(),
6✔
628
                                BlockHash:   blockHash,
6✔
629
                                BlockHeight: height,
6✔
630
                                TxIndex:     uint32(txIndex),
6✔
631
                                Block:       block,
6✔
632
                        }, chainntnfs.TxFoundManually, nil
6✔
633
                }
634
        }
635

636
        // If we reach here, then we were not able to find the transaction
637
        // within a block, so we avoid returning an error.
638
        return nil, chainntnfs.TxNotFoundManually, nil
30✔
639
}
640

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

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

662
        chainntnfs.Log.Infof("New block: height=%v, sha=%v", block.Height,
358✔
663
                block.Hash)
358✔
664

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

358✔
672
        err = b.txNotifier.NotifyHeight(uint32(block.Height))
358✔
673
        if err != nil {
358✔
674
                return fmt.Errorf("unable to notify height: %w", err)
×
675
        }
×
676

677
        b.notifyBlockEpochs(block.Height, block.Hash, block.BlockHeader)
358✔
678

358✔
679
        return nil
358✔
680
}
681

682
// notifyBlockEpochs notifies all registered block epoch clients of the newly
683
// connected block to the main chain.
684
func (b *BitcoindNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash.Hash,
685
        blockHeader *wire.BlockHeader) {
358✔
686

358✔
687
        for _, client := range b.blockEpochClients {
900✔
688
                b.notifyBlockEpochClient(client, newHeight, newSha, blockHeader)
542✔
689
        }
542✔
690
}
691

692
// notifyBlockEpochClient sends a registered block epoch client a notification
693
// about a specific block.
694
func (b *BitcoindNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistration,
695
        height int32, sha *chainhash.Hash, header *wire.BlockHeader) {
680✔
696

680✔
697
        epoch := &chainntnfs.BlockEpoch{
680✔
698
                Height:      height,
680✔
699
                Hash:        sha,
680✔
700
                BlockHeader: header,
680✔
701
        }
680✔
702

680✔
703
        select {
680✔
704
        case epochClient.epochQueue.ChanIn() <- epoch:
680✔
705
        case <-epochClient.cancelChan:
×
706
        case <-b.quit:
×
707
        }
708
}
709

710
// RegisterSpendNtfn registers an intent to be notified once the target
711
// outpoint/output script has been spent by a transaction on-chain. When
712
// intending to be notified of the spend of an output script, a nil outpoint
713
// must be used. The heightHint should represent the earliest height in the
714
// chain of the transaction that spent the outpoint/output script.
715
//
716
// Once a spend of has been detected, the details of the spending event will be
717
// sent across the 'Spend' channel.
718
func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
719
        pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error) {
52✔
720

52✔
721
        // Register the conf notification with the TxNotifier. A non-nil value
52✔
722
        // for `dispatch` will be returned if we are required to perform a
52✔
723
        // manual scan for the confirmation. Otherwise the notifier will begin
52✔
724
        // watching at tip for the transaction to confirm.
52✔
725
        ntfn, err := b.txNotifier.RegisterSpend(outpoint, pkScript, heightHint)
52✔
726
        if err != nil {
52✔
UNCOV
727
                return nil, err
×
UNCOV
728
        }
×
729

730
        // We'll then request the backend to notify us when it has detected the
731
        // outpoint/output script as spent.
732
        //
733
        // TODO(wilmer): use LoadFilter API instead.
734
        if outpoint == nil || *outpoint == chainntnfs.ZeroOutPoint {
78✔
735
                _, addrs, _, err := txscript.ExtractPkScriptAddrs(
26✔
736
                        pkScript, b.chainParams,
26✔
737
                )
26✔
738
                if err != nil {
26✔
739
                        return nil, fmt.Errorf("unable to parse script: %w",
×
740
                                err)
×
741
                }
×
742
                if err := b.chainConn.NotifyReceived(addrs); err != nil {
26✔
743
                        return nil, err
×
744
                }
×
745
        } else {
26✔
746
                ops := []*wire.OutPoint{outpoint}
26✔
747
                if err := b.chainConn.NotifySpent(ops); err != nil {
26✔
748
                        return nil, err
×
749
                }
×
750
        }
751

752
        // If the txNotifier didn't return any details to perform a historical
753
        // scan of the chain, then we can return early as there's nothing left
754
        // for us to do.
755
        if ntfn.HistoricalDispatch == nil {
100✔
756
                return ntfn.Event, nil
48✔
757
        }
48✔
758

759
        // Otherwise, we'll need to dispatch a historical rescan to determine if
760
        // the outpoint was already spent at a previous height.
761
        //
762
        // We'll short-circuit the path when dispatching the spend of a script,
763
        // rather than an outpoint, as there aren't any additional checks we can
764
        // make for scripts.
765
        if ntfn.HistoricalDispatch.OutPoint == chainntnfs.ZeroOutPoint {
6✔
766
                select {
2✔
767
                case b.notificationRegistry <- ntfn.HistoricalDispatch:
2✔
768
                case <-b.quit:
×
769
                        return nil, chainntnfs.ErrChainNotifierShuttingDown
×
770
                }
771

772
                return ntfn.Event, nil
2✔
773
        }
774

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

UNCOV
796
                return ntfn.Event, nil
×
797
        }
798

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

817
        // If the transaction index was enabled, we'll use the block's hash to
818
        // retrieve its height and check whether it provides a better starting
819
        // point for our rescan.
820
        if tx != nil {
4✔
821
                // If the transaction containing the outpoint hasn't confirmed
2✔
822
                // on-chain, then there's no need to perform a rescan.
2✔
823
                if tx.BlockHash == "" {
2✔
UNCOV
824
                        return ntfn.Event, nil
×
UNCOV
825
                }
×
826

827
                blockHash, err := chainhash.NewHashFromStr(tx.BlockHash)
2✔
828
                if err != nil {
2✔
829
                        return nil, err
×
830
                }
×
831
                blockHeight, err := b.chainConn.GetBlockHeight(blockHash)
2✔
832
                if err != nil {
2✔
833
                        return nil, err
×
834
                }
×
835

836
                spentHeight := uint32(blockHeight)
2✔
837
                chainntnfs.Log.Debugf("Outpoint(%v) has spent at height %v",
2✔
838
                        outpoint, spentHeight)
2✔
839

2✔
840
                // Since the tx has already been spent at spentHeight, the
2✔
841
                // heightHint specified by the caller is no longer relevant. We
2✔
842
                // now update the starting height to be the spent height to make
2✔
843
                // sure we won't miss it in the rescan.
2✔
844
                if spentHeight != ntfn.HistoricalDispatch.StartHeight {
2✔
UNCOV
845
                        ntfn.HistoricalDispatch.StartHeight = spentHeight
×
UNCOV
846
                }
×
847
        }
848

849
        // Now that we've determined the starting point of our rescan, we can
850
        // dispatch it and return.
851
        select {
2✔
852
        case b.notificationRegistry <- ntfn.HistoricalDispatch:
2✔
853
        case <-b.quit:
×
854
                return nil, chainntnfs.ErrChainNotifierShuttingDown
×
855
        }
856

857
        return ntfn.Event, nil
2✔
858
}
859

860
// historicalSpendDetails attempts to manually scan the chain within the given
861
// height range for a transaction that spends the given outpoint/output script.
862
// If one is found, the spend details are assembled and returned to the caller.
863
// If the spend is not found, a nil spend detail will be returned.
864
func (b *BitcoindNotifier) historicalSpendDetails(
865
        spendRequest chainntnfs.SpendRequest, startHeight, endHeight uint32) (
866
        *chainntnfs.SpendDetail, error) {
4✔
867

4✔
868
        // Begin scanning blocks at every height to determine if the outpoint
4✔
869
        // was spent.
4✔
870
        for height := endHeight; height >= startHeight && height > 0; height-- {
8✔
871
                // Ensure we haven't been requested to shut down before
4✔
872
                // processing the next height.
4✔
873
                select {
4✔
874
                case <-b.quit:
×
875
                        return nil, chainntnfs.ErrChainNotifierShuttingDown
×
876
                default:
4✔
877
                }
878

879
                // First, we'll fetch the block for the current height.
880
                blockHash, err := b.chainConn.GetBlockHash(int64(height))
4✔
881
                if err != nil {
4✔
882
                        return nil, fmt.Errorf("unable to retrieve hash for "+
×
883
                                "block with height %d: %v", height, err)
×
884
                }
×
885
                block, err := b.GetBlock(blockHash)
4✔
886
                if err != nil {
4✔
887
                        return nil, fmt.Errorf("unable to retrieve block "+
×
888
                                "with hash %v: %v", blockHash, err)
×
889
                }
×
890

891
                // Then, we'll manually go over every input in every transaction
892
                // in it and determine whether it spends the request in
893
                // question. If we find one, we'll dispatch the spend details.
894
                for _, tx := range block.Transactions {
12✔
895
                        matches, inputIdx, err := spendRequest.MatchesTx(tx)
8✔
896
                        if err != nil {
8✔
897
                                return nil, err
×
898
                        }
×
899
                        if !matches {
16✔
900
                                continue
8✔
901
                        }
902

UNCOV
903
                        txCopy := tx.Copy()
×
UNCOV
904
                        txHash := txCopy.TxHash()
×
UNCOV
905
                        spendOutPoint := &txCopy.TxIn[inputIdx].PreviousOutPoint
×
UNCOV
906
                        return &chainntnfs.SpendDetail{
×
UNCOV
907
                                SpentOutPoint:     spendOutPoint,
×
UNCOV
908
                                SpenderTxHash:     &txHash,
×
UNCOV
909
                                SpendingTx:        txCopy,
×
UNCOV
910
                                SpenderInputIndex: inputIdx,
×
UNCOV
911
                                SpendingHeight:    int32(height),
×
UNCOV
912
                        }, nil
×
913
                }
914
        }
915

916
        return nil, nil
4✔
917
}
918

919
// RegisterConfirmationsNtfn registers an intent to be notified once the target
920
// txid/output script has reached numConfs confirmations on-chain. When
921
// intending to be notified of the confirmation of an output script, a nil txid
922
// must be used. The heightHint should represent the earliest height at which
923
// the txid/output script could have been included in the chain.
924
//
925
// Progress on the number of confirmations left can be read from the 'Updates'
926
// channel. Once it has reached all of its confirmations, a notification will be
927
// sent across the 'Confirmed' channel.
928
func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
929
        pkScript []byte, numConfs, heightHint uint32,
930
        opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
96✔
931

96✔
932
        // Register the conf notification with the TxNotifier. A non-nil value
96✔
933
        // for `dispatch` will be returned if we are required to perform a
96✔
934
        // manual scan for the confirmation. Otherwise the notifier will begin
96✔
935
        // watching at tip for the transaction to confirm.
96✔
936
        ntfn, err := b.txNotifier.RegisterConf(
96✔
937
                txid, pkScript, numConfs, heightHint, opts...,
96✔
938
        )
96✔
939
        if err != nil {
96✔
940
                return nil, err
×
941
        }
×
942

943
        if ntfn.HistoricalDispatch == nil {
129✔
944
                return ntfn.Event, nil
33✔
945
        }
33✔
946

947
        select {
63✔
948
        case b.notificationRegistry <- ntfn.HistoricalDispatch:
63✔
949
                return ntfn.Event, nil
63✔
950
        case <-b.quit:
×
951
                return nil, chainntnfs.ErrChainNotifierShuttingDown
×
952
        }
953
}
954

955
// blockEpochRegistration represents a client's intent to receive a
956
// notification with each newly connected block.
957
type blockEpochRegistration struct {
958
        epochID uint64
959

960
        epochChan chan *chainntnfs.BlockEpoch
961

962
        epochQueue *queue.ConcurrentQueue
963

964
        bestBlock *chainntnfs.BlockEpoch
965

966
        errorChan chan error
967

968
        cancelChan chan struct{}
969

970
        wg sync.WaitGroup
971
}
972

973
// epochCancel is a message sent to the BitcoindNotifier when a client wishes
974
// to cancel an outstanding epoch notification that has yet to be dispatched.
975
type epochCancel struct {
976
        epochID uint64
977
}
978

979
// RegisterBlockEpochNtfn returns a BlockEpochEvent which subscribes the
980
// caller to receive notifications, of each new block connected to the main
981
// chain. Clients have the option of passing in their best known block, which
982
// the notifier uses to check if they are behind on blocks and catch them up. If
983
// they do not provide one, then a notification will be dispatched immediately
984
// for the current tip of the chain upon a successful registration.
985
func (b *BitcoindNotifier) RegisterBlockEpochNtfn(
986
        bestBlock *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent, error) {
48✔
987

48✔
988
        reg := &blockEpochRegistration{
48✔
989
                epochQueue: queue.NewConcurrentQueue(20),
48✔
990
                epochChan:  make(chan *chainntnfs.BlockEpoch, 20),
48✔
991
                cancelChan: make(chan struct{}),
48✔
992
                epochID:    atomic.AddUint64(&b.epochClientCounter, 1),
48✔
993
                bestBlock:  bestBlock,
48✔
994
                errorChan:  make(chan error, 1),
48✔
995
        }
48✔
996
        reg.epochQueue.Start()
48✔
997

48✔
998
        // Before we send the request to the main goroutine, we'll launch a new
48✔
999
        // goroutine to proxy items added to our queue to the client itself.
48✔
1000
        // This ensures that all notifications are received *in order*.
48✔
1001
        reg.wg.Add(1)
48✔
1002
        go func() {
96✔
1003
                defer reg.wg.Done()
48✔
1004

48✔
1005
                for {
684✔
1006
                        select {
636✔
1007
                        case ntfn := <-reg.epochQueue.ChanOut():
592✔
1008
                                blockNtfn := ntfn.(*chainntnfs.BlockEpoch)
592✔
1009
                                select {
592✔
1010
                                case reg.epochChan <- blockNtfn:
588✔
1011

UNCOV
1012
                                case <-reg.cancelChan:
×
UNCOV
1013
                                        return
×
1014

1015
                                case <-b.quit:
4✔
1016
                                        return
4✔
1017
                                }
1018

1019
                        case <-reg.cancelChan:
2✔
1020
                                return
2✔
1021

1022
                        case <-b.quit:
42✔
1023
                                return
42✔
1024
                        }
1025
                }
1026
        }()
1027

1028
        select {
48✔
1029
        case <-b.quit:
×
1030
                // As we're exiting before the registration could be sent,
×
1031
                // we'll stop the queue now ourselves.
×
1032
                reg.epochQueue.Stop()
×
1033

×
1034
                return nil, errors.New("chainntnfs: system interrupt while " +
×
1035
                        "attempting to register for block epoch notification.")
×
1036
        case b.notificationRegistry <- reg:
48✔
1037
                return &chainntnfs.BlockEpochEvent{
48✔
1038
                        Epochs: reg.epochChan,
48✔
1039
                        Cancel: func() {
50✔
1040
                                cancel := &epochCancel{
2✔
1041
                                        epochID: reg.epochID,
2✔
1042
                                }
2✔
1043

2✔
1044
                                // Submit epoch cancellation to notification dispatcher.
2✔
1045
                                select {
2✔
1046
                                case b.notificationCancels <- cancel:
2✔
1047
                                        // Cancellation is being handled, drain the epoch channel until it is
2✔
1048
                                        // closed before yielding to caller.
2✔
1049
                                        for {
6✔
1050
                                                select {
4✔
1051
                                                case _, ok := <-reg.epochChan:
4✔
1052
                                                        if !ok {
6✔
1053
                                                                return
2✔
1054
                                                        }
2✔
1055
                                                case <-b.quit:
×
1056
                                                        return
×
1057
                                                }
1058
                                        }
UNCOV
1059
                                case <-b.quit:
×
1060
                                }
1061
                        },
1062
                }, nil
1063
        }
1064
}
1065

1066
// GetBlock is used to retrieve the block with the given hash. This function
1067
// wraps the blockCache's GetBlock function.
1068
func (b *BitcoindNotifier) GetBlock(hash *chainhash.Hash) (*wire.MsgBlock,
1069
        error) {
422✔
1070

422✔
1071
        return b.blockCache.GetBlock(hash, b.chainConn.GetBlock)
422✔
1072
}
422✔
1073

1074
// SubscribeMempoolSpent allows the caller to register a subscription to watch
1075
// for a spend of an outpoint in the mempool.The event will be dispatched once
1076
// the outpoint is spent in the mempool.
1077
//
1078
// NOTE: part of the MempoolWatcher interface.
1079
func (b *BitcoindNotifier) SubscribeMempoolSpent(
UNCOV
1080
        outpoint wire.OutPoint) (*chainntnfs.MempoolSpendEvent, error) {
×
UNCOV
1081

×
UNCOV
1082
        event := b.memNotifier.SubscribeInput(outpoint)
×
UNCOV
1083

×
UNCOV
1084
        ops := []*wire.OutPoint{&outpoint}
×
UNCOV
1085

×
UNCOV
1086
        return event, b.chainConn.NotifySpent(ops)
×
UNCOV
1087
}
×
1088

1089
// CancelMempoolSpendEvent allows the caller to cancel a subscription to watch
1090
// for a spend of an outpoint in the mempool.
1091
//
1092
// NOTE: part of the MempoolWatcher interface.
1093
func (b *BitcoindNotifier) CancelMempoolSpendEvent(
UNCOV
1094
        sub *chainntnfs.MempoolSpendEvent) {
×
UNCOV
1095

×
UNCOV
1096
        b.memNotifier.UnsubscribeEvent(sub)
×
UNCOV
1097
}
×
1098

1099
// LookupInputMempoolSpend takes an outpoint and queries the mempool to find
1100
// its spending tx. Returns the tx if found, otherwise fn.None.
1101
//
1102
// NOTE: part of the MempoolWatcher interface.
1103
func (b *BitcoindNotifier) LookupInputMempoolSpend(
UNCOV
1104
        op wire.OutPoint) fn.Option[wire.MsgTx] {
×
UNCOV
1105

×
UNCOV
1106
        // Find the spending txid.
×
UNCOV
1107
        txid, found := b.chainConn.LookupInputMempoolSpend(op)
×
UNCOV
1108
        if !found {
×
UNCOV
1109
                return fn.None[wire.MsgTx]()
×
UNCOV
1110
        }
×
1111

1112
        // Query the spending tx using the id.
UNCOV
1113
        tx, err := b.chainConn.GetRawTransaction(&txid)
×
UNCOV
1114
        if err != nil {
×
1115
                // TODO(yy): enable logging errors in this package.
×
1116
                return fn.None[wire.MsgTx]()
×
1117
        }
×
1118

UNCOV
1119
        return fn.Some(*tx.MsgTx().Copy())
×
1120
}
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