mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
Merge branch '0-19-2-branch-rc1-9991' into 0-19-2-branch-rc1
This commit is contained in:
@@ -509,6 +509,10 @@ func (s *Server) probeDestination(dest []byte, amtSat int64) (*RouteFeeResponse,
|
|||||||
// node. If the route hints don't indicate an LSP, they are passed as arguments
|
// node. If the route hints don't indicate an LSP, they are passed as arguments
|
||||||
// to the SendPayment_V2 method, which enable it to send probe payments to the
|
// to the SendPayment_V2 method, which enable it to send probe payments to the
|
||||||
// payment request destination.
|
// payment request destination.
|
||||||
|
//
|
||||||
|
// NOTE: Be aware that because of the special heuristic that is applied to
|
||||||
|
// identify LSPs, the probe payment might use a different node id as the
|
||||||
|
// final destination (the assumed LSP node id).
|
||||||
func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
||||||
timeout uint32) (*RouteFeeResponse, error) {
|
timeout uint32) (*RouteFeeResponse, error) {
|
||||||
|
|
||||||
@@ -558,6 +562,9 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
|||||||
// payment won't be blocked along the route to the destination. We send
|
// payment won't be blocked along the route to the destination. We send
|
||||||
// a probe payment with unmodified route hints.
|
// a probe payment with unmodified route hints.
|
||||||
if !isLSP(hints, s.cfg.RouterBackend.FetchChannelEndpoints) {
|
if !isLSP(hints, s.cfg.RouterBackend.FetchChannelEndpoints) {
|
||||||
|
log.Infof("No LSP detected, probing destination %x",
|
||||||
|
probeRequest.Dest)
|
||||||
|
|
||||||
probeRequest.RouteHints = invoicesrpc.CreateRPCRouteHints(hints)
|
probeRequest.RouteHints = invoicesrpc.CreateRPCRouteHints(hints)
|
||||||
return s.sendProbePayment(ctx, probeRequest)
|
return s.sendProbePayment(ctx, probeRequest)
|
||||||
}
|
}
|
||||||
@@ -571,9 +578,14 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the destination to the LSP node ID.
|
||||||
|
lspDest := lspHint.NodeID.SerializeCompressed()
|
||||||
|
probeRequest.Dest = lspDest
|
||||||
|
|
||||||
|
log.Infof("LSP detected, probing LSP with destination: %x", lspDest)
|
||||||
|
|
||||||
// The adjusted route hints serve the payment probe to find the last
|
// The adjusted route hints serve the payment probe to find the last
|
||||||
// public hop to the LSP on the route.
|
// public hop to the LSP on the route.
|
||||||
probeRequest.Dest = lspHint.NodeID.SerializeCompressed()
|
|
||||||
if len(lspAdjustedRouteHints) > 0 {
|
if len(lspAdjustedRouteHints) > 0 {
|
||||||
probeRequest.RouteHints = invoicesrpc.CreateRPCRouteHints(
|
probeRequest.RouteHints = invoicesrpc.CreateRPCRouteHints(
|
||||||
lspAdjustedRouteHints,
|
lspAdjustedRouteHints,
|
||||||
@@ -609,7 +621,8 @@ func (s *Server) probePaymentRequest(ctx context.Context, paymentRequest string,
|
|||||||
// Dispatch the payment probe with adjusted fee amount.
|
// Dispatch the payment probe with adjusted fee amount.
|
||||||
resp, err := s.sendProbePayment(ctx, probeRequest)
|
resp, err := s.sendProbePayment(ctx, probeRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to send probe payment to "+
|
||||||
|
"LSP with destination %x: %w", lspDest, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the payment probe failed we only return the failure reason and
|
// If the payment probe failed we only return the failure reason and
|
||||||
@@ -667,11 +680,11 @@ func isLSP(routeHints [][]zpay32.HopHint,
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
idMatchesRefNode := bytes.Equal(
|
matchesDestNode := bytes.Equal(
|
||||||
lastHop.NodeID.SerializeCompressed(),
|
lastHop.NodeID.SerializeCompressed(),
|
||||||
destHopHint.NodeID.SerializeCompressed(),
|
destHopHint.NodeID.SerializeCompressed(),
|
||||||
)
|
)
|
||||||
if !idMatchesRefNode {
|
if !matchesDestNode {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user