@@ -766,14 +766,6 @@ func importOutputProofs(scid lnwire.ShortChannelID,
766
766
// TODO(roasbeef): should be part of post confirmation funding validate
767
767
// (chanvalidate)
768
768
769
- // First, we'll make a courier to use in fetching the proofs we need.
770
- proofFetcher , err := proofDispatch .NewCourier (
771
- courierAddr , proof.Recipient {},
772
- )
773
- if err != nil {
774
- return fmt .Errorf ("unable to create proof courier: %w" , err )
775
- }
776
-
777
769
log .Infof ("Importing %v proofs for ChannelPoint(%v)" ,
778
770
len (outputProofs ), outputProofs [0 ].OutPoint ())
779
771
@@ -807,10 +799,30 @@ func importOutputProofs(scid lnwire.ShortChannelID,
807
799
log .Infof ("Fetching funding input proof, locator=%v" ,
808
800
spew .Sdump (inputProofLocator ))
809
801
802
+ // First, we'll make a courier to use in fetching the proofs we
803
+ // need.
804
+ proofFetcher , err := proofDispatch .NewCourier (
805
+ courierAddr , proof.Recipient {
806
+ ScriptKey : scriptKey ,
807
+ AssetID : proofPrevID .ID ,
808
+ Amount : proofToImport .Asset .Amount ,
809
+ },
810
+ )
811
+ if err != nil {
812
+ return fmt .Errorf ("unable to create proof courier: %w" ,
813
+ err )
814
+ }
815
+
810
816
ctxb := context .Background ()
811
817
prefixProof , err := proofFetcher .ReceiveProof (
812
818
ctxb , inputProofLocator ,
813
819
)
820
+
821
+ // Always attempt to close the courier, even if we encounter an
822
+ // error.
823
+ _ = proofFetcher .Close ()
824
+
825
+ // Handle any error that occurred during the proof fetch.
814
826
if err != nil {
815
827
return fmt .Errorf ("unable to fetch prefix " +
816
828
"proof: %w" , err )
0 commit comments