@@ -587,15 +587,15 @@ func (s *loopOutSwap) payInvoices(ctx context.Context) {
587587 // Use the recommended routing plugin.
588588 s .swapPaymentChan = s .payInvoice (
589589 ctx , s .SwapInvoice , s .MaxSwapRoutingFee ,
590- s .LoopOutContract .OutgoingChanSet , pluginType ,
590+ s .LoopOutContract .OutgoingChanSet , pluginType , true ,
591591 )
592592
593593 // Pay the prepay invoice. Won't use the routing plugin here as the
594594 // prepay is trivially small and shouldn't normally need any help.
595595 s .log .Infof ("Sending prepayment %v" , s .PrepayInvoice )
596596 s .prePaymentChan = s .payInvoice (
597597 ctx , s .PrepayInvoice , s .MaxPrepayRoutingFee ,
598- nil , RoutingPluginNone ,
598+ nil , RoutingPluginNone , false ,
599599 )
600600}
601601
@@ -623,7 +623,8 @@ func (p paymentResult) failure() error {
623623// payInvoice pays a single invoice.
624624func (s * loopOutSwap ) payInvoice (ctx context.Context , invoice string ,
625625 maxFee btcutil.Amount , outgoingChanIds loopdb.ChannelSet ,
626- pluginType RoutingPluginType ) chan paymentResult {
626+ pluginType RoutingPluginType ,
627+ reportPluginResult bool ) chan paymentResult {
627628
628629 resultChan := make (chan paymentResult )
629630 sendResult := func (result paymentResult ) {
@@ -638,6 +639,7 @@ func (s *loopOutSwap) payInvoice(ctx context.Context, invoice string,
638639
639640 status , err := s .payInvoiceAsync (
640641 ctx , invoice , maxFee , outgoingChanIds , pluginType ,
642+ reportPluginResult ,
641643 )
642644 if err != nil {
643645 result .err = err
@@ -665,8 +667,8 @@ func (s *loopOutSwap) payInvoice(ctx context.Context, invoice string,
665667// payInvoiceAsync is the asynchronously executed part of paying an invoice.
666668func (s * loopOutSwap ) payInvoiceAsync (ctx context.Context ,
667669 invoice string , maxFee btcutil.Amount ,
668- outgoingChanIds loopdb.ChannelSet , pluginType RoutingPluginType ) (
669- * lndclient.PaymentStatus , error ) {
670+ outgoingChanIds loopdb.ChannelSet , pluginType RoutingPluginType ,
671+ reportPluginResult bool ) ( * lndclient.PaymentStatus , error ) {
670672
671673 // Extract hash from payment request. Unfortunately the request
672674 // components aren't available directly.
@@ -719,11 +721,21 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
719721 paymentSuccess := err == nil &&
720722 paymentStatus .State == lnrpc .Payment_SUCCEEDED
721723
722- if err := s .swapKit .server .ReportRoutingResult (
723- ctx , s .swapInfo ().SwapHash , s .swapInvoicePaymentAddr , pluginType ,
724- paymentSuccess , int32 (attempts ), dt .Milliseconds (),
725- ); err != nil {
726- s .log .Warnf ("Failed to report routing result: %v" , err )
724+ if reportPluginResult {
725+ // If the plugin couldn't be acquired then override the reported
726+ // plugin type to RoutingPluginNone.
727+ reportType := pluginType
728+ if routingPlugin == nil {
729+ reportType = RoutingPluginNone
730+ }
731+
732+ if err := s .swapKit .server .ReportRoutingResult (
733+ ctx , s .swapInfo ().SwapHash , s .swapInvoicePaymentAddr ,
734+ reportType , paymentSuccess , int32 (attempts ),
735+ dt .Milliseconds (),
736+ ); err != nil {
737+ s .log .Warnf ("Failed to report routing result: %v" , err )
738+ }
727739 }
728740
729741 return paymentStatus , err
0 commit comments