@@ -288,7 +288,14 @@ func (c *Custodian) watchInboundAssets() {
288
288
// If we didn't find a proof, we'll launch a goroutine to use
289
289
// the ProofCourier to import the proof into our local DB.
290
290
c .Wg .Add (1 )
291
- go c .receiveProof (event .Addr .Tap , event .Outpoint )
291
+ go func () {
292
+ defer c .Wg .Done ()
293
+
294
+ recErr := c .receiveProof (event .Addr .Tap , event .Outpoint )
295
+ if recErr != nil {
296
+ reportErr (recErr )
297
+ }
298
+ }()
292
299
}
293
300
294
301
// Read all on-chain transactions and make sure they are mapped to an
@@ -402,7 +409,17 @@ func (c *Custodian) inspectWalletTx(walletTx *lndclient.Transaction) error {
402
409
// ProofCourier to import the proof into our
403
410
// local DB.
404
411
c .Wg .Add (1 )
405
- go c .receiveProof (event .Addr .Tap , op )
412
+ go func () {
413
+ defer c .Wg .Done ()
414
+
415
+ recErr := c .receiveProof (
416
+ event .Addr .Tap , op ,
417
+ )
418
+ if recErr != nil {
419
+ log .Errorf ("Unable to receive " +
420
+ "proof: %v" , recErr )
421
+ }
422
+ }()
406
423
}
407
424
408
425
continue
@@ -434,19 +451,23 @@ func (c *Custodian) inspectWalletTx(walletTx *lndclient.Transaction) error {
434
451
// launch a goroutine to use the ProofCourier to import the
435
452
// proof into our local DB.
436
453
c .Wg .Add (1 )
437
- go c .receiveProof (addr , op )
454
+ go func () {
455
+ defer c .Wg .Done ()
456
+
457
+ recErr := c .receiveProof (addr , op )
458
+ if recErr != nil {
459
+ log .Errorf ("Unable to receive proof: %v" ,
460
+ recErr )
461
+ }
462
+ }()
438
463
}
439
464
440
465
return nil
441
466
}
442
467
443
468
// receiveProof attempts to receive a proof for the given address and outpoint
444
469
// via the proof courier service.
445
- //
446
- // NOTE: This must be called as a goroutine.
447
- func (c * Custodian ) receiveProof (addr * address.Tap , op wire.OutPoint ) {
448
- defer c .Wg .Done ()
449
-
470
+ func (c * Custodian ) receiveProof (addr * address.Tap , op wire.OutPoint ) error {
450
471
ctx , cancel := c .WithCtxQuitNoTimeout ()
451
472
defer cancel ()
452
473
@@ -466,9 +487,8 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
466
487
& addr .ProofCourierAddr , recipient ,
467
488
)
468
489
if err != nil {
469
- log .Errorf ("Unable to initiate proof courier service handle: " +
470
- "%v" , err )
471
- return
490
+ return fmt .Errorf ("unable to initiate proof courier service " +
491
+ "handle: %w" , err )
472
492
}
473
493
474
494
// Update courier handle events subscribers before attempting to
@@ -484,7 +504,7 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
484
504
select {
485
505
case <- time .After (c .cfg .ProofRetrievalDelay ):
486
506
case <- ctx .Done ():
487
- return
507
+ return nil
488
508
}
489
509
490
510
// Attempt to receive proof via proof courier service.
@@ -496,8 +516,8 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
496
516
}
497
517
addrProof , err := courier .ReceiveProof (ctx , loc )
498
518
if err != nil {
499
- log .Errorf ("Unable to receive proof using courier: %v" , err )
500
- return
519
+ return fmt .Errorf ("unable to receive proof using courier: %w" ,
520
+ err )
501
521
}
502
522
503
523
log .Debugf ("Received proof for: script_key=%x, asset_id=%x" ,
@@ -511,9 +531,15 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
511
531
ctx , headerVerifier , c .cfg .GroupVerifier , false , addrProof ,
512
532
)
513
533
if err != nil {
514
- log .Errorf ("Unable to import proofs: %v" , err )
515
- return
534
+ return fmt .Errorf ("unable to import proofs: %w" , err )
516
535
}
536
+
537
+ // The proof is now verified and in our local archive. We will now
538
+ // finalize handling the proof like we would with any other newly
539
+ // received proof.
540
+ c .proofSubscription .NewItemCreated .ChanIn () <- addrProof .Blob
541
+
542
+ return nil
517
543
}
518
544
519
545
// mapToTapAddr attempts to match a transaction output to a Taproot Asset
0 commit comments