mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 23:01:53 +02:00
routing: include route blinding fields in blinded portion of path
This commit updates route construction to backfill the fields required for payment to blinded paths and set amount to forward and expiry fields to zero for intermediate hops (as is instructed in the route blinding specification). We could attempt to do this in the first pass, but that loop relies on fields like amount to forward and expiry to calculate each hop backwards, so we keep it simple (stupid) and post processes the blinded portion, since it's computationally cheap and more readable.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
c9609b8214
commit
014683ee66
@@ -1991,6 +1991,16 @@ func getTargetNode(target *route.Vertex, blindedPayment *BlindedPayment) (
|
||||
}
|
||||
}
|
||||
|
||||
// blindedPath returns the request's blinded path, which is set if the payment
|
||||
// is to a blinded route.
|
||||
func (r *RouteRequest) blindedPath() *sphinx.BlindedPath {
|
||||
if r.BlindedPayment == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return r.BlindedPayment.BlindedPath
|
||||
}
|
||||
|
||||
// FindRoute attempts to query the ChannelRouter for the optimum path to a
|
||||
// particular target destination to which it is able to send `amt` after
|
||||
// factoring in channel capacities and cumulative fees along the route.
|
||||
@@ -2047,7 +2057,7 @@ func (r *ChannelRouter) FindRoute(req *RouteRequest) (*route.Route, float64,
|
||||
totalAmt: req.Amount,
|
||||
cltvDelta: req.FinalExpiry,
|
||||
records: req.CustomRecords,
|
||||
},
|
||||
}, req.blindedPath(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -3032,7 +3042,7 @@ func (r *ChannelRouter) BuildRoute(amt *lnwire.MilliSatoshi,
|
||||
cltvDelta: uint16(finalCltvDelta),
|
||||
records: nil,
|
||||
paymentAddr: payAddr,
|
||||
},
|
||||
}, nil,
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user