@@ -553,6 +553,7 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
553553 // If the payment addresses is specified, then we'll also populate that
554554 // now as well.
555555 payReq .PaymentAddr .WhenSome (func (addr [32 ]byte ) {
556+ probeRequest .PaymentAddr = make ([]byte , lntypes .HashSize )
556557 copy (probeRequest .PaymentAddr , addr [:])
557558 })
558559
@@ -584,12 +585,112 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
584585
585586 log .Infof ("LSP detected, probing LSP with destination: %x" , lspDest )
586587
588+ << << << < HEAD
587589 // The adjusted route hints serve the payment probe to find the last
588590 // public hop to the LSP on the route.
589591 if len (lspAdjustedRouteHints ) > 0 {
590592 probeRequest .RouteHints = invoicesrpc .CreateRPCRouteHints (
591593 lspAdjustedRouteHints ,
592594 )
595+ == == == =
596+ for lspKey , group := range lspGroups {
597+ if probeCount >= MaxLspsToProbe {
598+ break
599+ }
600+ probeCount ++
601+
602+ lspHint := group .LspHopHint
603+
604+ log .Infof ("Probing LSP with destination: %v" , lspKey )
605+
606+ // Create a new probe request for this LSP.
607+ lspProbeRequest := & SendPaymentRequest {
608+ TimeoutSeconds : probeRequest .TimeoutSeconds ,
609+ Dest : lspKey [:],
610+ MaxParts : probeRequest .MaxParts ,
611+ AllowSelfPayment : probeRequest .AllowSelfPayment ,
612+ AmtMsat : amtMsat ,
613+ PaymentHash : probeRequest .PaymentHash ,
614+ FeeLimitSat : probeRequest .FeeLimitSat ,
615+ FinalCltvDelta : int32 (lspHint .CLTVExpiryDelta ),
616+ DestFeatures : probeRequest .DestFeatures ,
617+ }
618+
619+ // Copy the payment address if present.
620+ if len (probeRequest .PaymentAddr ) > 0 {
621+ lspProbeRequest .PaymentAddr = make (
622+ []byte , lntypes .HashSize ,
623+ )
624+
625+ copy (
626+ lspProbeRequest .PaymentAddr ,
627+ probeRequest .PaymentAddr ,
628+ )
629+ }
630+
631+ // Set the adjusted route hints for this LSP.
632+ if len (group .AdjustedRouteHints ) > 0 {
633+ lspProbeRequest .RouteHints = invoicesrpc .
634+ CreateRPCRouteHints (group .AdjustedRouteHints )
635+ }
636+
637+ // Calculate the hop fee for the last hop manually.
638+ hopFee := lspHint .HopFee (* payReq .MilliSat )
639+
640+ // Add the last hop's fee to the probe amount.
641+ lspProbeRequest .AmtMsat += int64 (hopFee )
642+
643+ // Dispatch the payment probe for this LSP.
644+ resp , err := s .sendProbePayment (ctx , lspProbeRequest )
645+ if err != nil {
646+ log .Warnf ("Failed to probe LSP %v: %v" , lspKey , err )
647+ continue
648+ }
649+
650+ // If the probe failed, skip this LSP.
651+ if resp .FailureReason !=
652+ lnrpc .PaymentFailureReason_FAILURE_REASON_NONE {
653+
654+ log .Debugf ("Probe to LSP %v failed with reason: %v" ,
655+ lspKey , resp .FailureReason )
656+
657+ continue
658+ }
659+
660+ // The probe succeeded, add the last hop's fee.
661+ resp .RoutingFeeMsat += int64 (hopFee )
662+
663+ // Add the final cltv delta of the invoice.
664+ resp .TimeLockDelay += int64 (payReq .MinFinalCLTVExpiry ())
665+
666+ log .Infof ("Probe to LSP %v succeeded with fee: %d msat" ,
667+ lspKey , resp .RoutingFeeMsat )
668+
669+ // Track the most expensive route for worst-case estimation.
670+ // We solely consider the routing fee for the worst-case
671+ // estimation.
672+ if worstCaseResp == nil ||
673+ resp .RoutingFeeMsat > worstCaseResp .RoutingFeeMsat {
674+
675+ if worstCaseResp != nil {
676+ log .Debugf ("LSP %v has higher fee " +
677+ "(%d msat) than current worst-case " +
678+ "%v (%d msat), updating worst-case " +
679+ "estimate" , lspKey ,
680+ resp .RoutingFeeMsat , worstCaseLspDest ,
681+ worstCaseResp .RoutingFeeMsat )
682+ }
683+
684+ worstCaseResp = resp
685+ worstCaseLspDest = lspKey
686+ } else {
687+ log .Debugf ("LSP %v fee (%d msat) is lower than " +
688+ "current worst-case %v (%d msat), keeping " +
689+ "worst-case estimate" , lspKey ,
690+ resp .RoutingFeeMsat , worstCaseLspDest ,
691+ worstCaseResp .RoutingFeeMsat )
692+ }
693+ >> >> >> > 1 c4bcc3b7 (routerrpc : fix payment address deep copy )
593694 }
594695
595696 // The payment probe will be able to calculate the fee up until the LSP
0 commit comments