@@ -288,7 +288,14 @@ func (c *Custodian) watchInboundAssets() {
288288 // If we didn't find a proof, we'll launch a goroutine to use
289289 // the ProofCourier to import the proof into our local DB.
290290 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+ }()
292299 }
293300
294301 // 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 {
402409 // ProofCourier to import the proof into our
403410 // local DB.
404411 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+ }()
406423 }
407424
408425 continue
@@ -434,19 +451,23 @@ func (c *Custodian) inspectWalletTx(walletTx *lndclient.Transaction) error {
434451 // launch a goroutine to use the ProofCourier to import the
435452 // proof into our local DB.
436453 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+ }()
438463 }
439464
440465 return nil
441466}
442467
443468// receiveProof attempts to receive a proof for the given address and outpoint
444469// 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 {
450471 ctx , cancel := c .WithCtxQuitNoTimeout ()
451472 defer cancel ()
452473
@@ -466,9 +487,8 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
466487 & addr .ProofCourierAddr , recipient ,
467488 )
468489 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 )
472492 }
473493
474494 // Update courier handle events subscribers before attempting to
@@ -484,7 +504,7 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
484504 select {
485505 case <- time .After (c .cfg .ProofRetrievalDelay ):
486506 case <- ctx .Done ():
487- return
507+ return nil
488508 }
489509
490510 // Attempt to receive proof via proof courier service.
@@ -496,8 +516,8 @@ func (c *Custodian) receiveProof(addr *address.Tap, op wire.OutPoint) {
496516 }
497517 addrProof , err := courier .ReceiveProof (ctx , loc )
498518 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 )
501521 }
502522
503523 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) {
511531 ctx , headerVerifier , c .cfg .GroupVerifier , false , addrProof ,
512532 )
513533 if err != nil {
514- log .Errorf ("Unable to import proofs: %v" , err )
515- return
534+ return fmt .Errorf ("unable to import proofs: %w" , err )
516535 }
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
517543}
518544
519545// mapToTapAddr attempts to match a transaction output to a Taproot Asset
0 commit comments