Skip to content

Commit ae0f1ce

Browse files
authored
Merge pull request #1058 from lightninglabs/proof-courier-null-fix
tapchannel: fix proof courier initialization
2 parents 6d018c0 + 8164782 commit ae0f1ce

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

tapchannel/aux_sweeper.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -766,14 +766,6 @@ func importOutputProofs(scid lnwire.ShortChannelID,
766766
// TODO(roasbeef): should be part of post confirmation funding validate
767767
// (chanvalidate)
768768

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-
777769
log.Infof("Importing %v proofs for ChannelPoint(%v)",
778770
len(outputProofs), outputProofs[0].OutPoint())
779771

@@ -807,10 +799,30 @@ func importOutputProofs(scid lnwire.ShortChannelID,
807799
log.Infof("Fetching funding input proof, locator=%v",
808800
spew.Sdump(inputProofLocator))
809801

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+
810816
ctxb := context.Background()
811817
prefixProof, err := proofFetcher.ReceiveProof(
812818
ctxb, inputProofLocator,
813819
)
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.
814826
if err != nil {
815827
return fmt.Errorf("unable to fetch prefix "+
816828
"proof: %w", err)

0 commit comments

Comments
 (0)