@@ -86,12 +86,12 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
8686 return nil , fmt .Errorf ("cannot initiate swap: %v" , err )
8787 }
8888
89- err = validateLoopOutContract (cfg .lnd , currentHeight , request , swapResp )
89+ err = validateLoopOutContract (cfg .lnd , currentHeight , request , swapHash , swapResp )
9090 if err != nil {
9191 return nil , err
9292 }
9393
94- // Instantie a struct that contains all required data to start the swap.
94+ // Instantiate a struct that contains all required data to start the swap.
9595 initiationTime := time .Now ()
9696
9797 contract := loopdb.LoopOutContract {
@@ -660,21 +660,26 @@ func (s *loopOutSwap) sweep(ctx context.Context,
660660// validateLoopOutContract validates the contract parameters against our
661661// request.
662662func validateLoopOutContract (lnd * lndclient.LndServices ,
663- height int32 ,
664- request * OutRequest ,
663+ height int32 , request * OutRequest , swapHash lntypes.Hash ,
665664 response * newLoopOutResponse ) error {
666665
667666 // Check invoice amounts.
668667 chainParams := lnd .ChainParams
669668
670- swapInvoiceAmt , err := swap .GetInvoiceAmt (
669+ swapInvoiceHash , swapInvoiceAmt , err := swap .DecodeInvoice (
671670 chainParams , response .swapInvoice ,
672671 )
673672 if err != nil {
674673 return err
675674 }
676675
677- prepayInvoiceAmt , err := swap .GetInvoiceAmt (
676+ if swapInvoiceHash != swapHash {
677+ return fmt .Errorf (
678+ "cannot initiate swap, swap invoice hash %v not equal generated swap hash %v" ,
679+ swapInvoiceHash , swapHash )
680+ }
681+
682+ _ , prepayInvoiceAmt , err := swap .DecodeInvoice (
678683 chainParams , response .prepayInvoice ,
679684 )
680685 if err != nil {
0 commit comments