blindedpath: log chosen blinded paths
In this commit, we log selected blinded paths.
This commit is contained in:
2 files changed
+28
-17
No files matched your search
@@ -1220,10 +1220,6 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
|
|||||||
// Assert that it contains a single blinded path and that the
|
// Assert that it contains a single blinded path and that the
|
||||||
// introduction node is Carol.
|
// introduction node is Carol.
|
||||||
payReq = dave.RPC.DecodePayReq(invoiceResp.PaymentRequest)
|
payReq = dave.RPC.DecodePayReq(invoiceResp.PaymentRequest)
|
||||||
for _, path := range payReq.BlindedPaths {
|
|
||||||
ht.Logf("intro node: %x", path.BlindedPath.IntroductionNode)
|
|
||||||
}
|
|
||||||
|
|
||||||
require.Len(ht, payReq.BlindedPaths, 1)
|
require.Len(ht, payReq.BlindedPaths, 1)
|
||||||
|
|
||||||
// The total number of hop payloads is 3: one for the introduction node
|
// The total number of hop payloads is 3: one for the introduction node
|
||||||
|
|||||||
@@ -132,9 +132,14 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
|
|||||||
// For each route returned, we will construct the associated blinded
|
// For each route returned, we will construct the associated blinded
|
||||||
// payment path.
|
// payment path.
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
path, err := buildBlindedPaymentPath(
|
// Extract the information we need from the route.
|
||||||
cfg, extractCandidatePath(route),
|
candidatePath := extractCandidatePath(route)
|
||||||
)
|
|
||||||
|
// Pad the given route with dummy hops until the minimum number
|
||||||
|
// of hops is met.
|
||||||
|
candidatePath.padWithDummyHops(cfg.MinNumHops)
|
||||||
|
|
||||||
|
path, err := buildBlindedPaymentPath(cfg, candidatePath)
|
||||||
if errors.Is(err, errInvalidBlindedPath) {
|
if errors.Is(err, errInvalidBlindedPath) {
|
||||||
log.Debugf("Not using route (%s) as a blinded path "+
|
log.Debugf("Not using route (%s) as a blinded path "+
|
||||||
"since it resulted in an invalid blinded path",
|
"since it resulted in an invalid blinded path",
|
||||||
@@ -148,6 +153,8 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Route selected for blinded path: %s", candidatePath)
|
||||||
|
|
||||||
paths = append(paths, path)
|
paths = append(paths, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,13 +170,6 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
|
|||||||
func buildBlindedPaymentPath(cfg *BuildBlindedPathCfg, path *candidatePath) (
|
func buildBlindedPaymentPath(cfg *BuildBlindedPathCfg, path *candidatePath) (
|
||||||
*zpay32.BlindedPaymentPath, error) {
|
*zpay32.BlindedPaymentPath, error) {
|
||||||
|
|
||||||
// Pad the given route with dummy hops until the minimum number of hops
|
|
||||||
// is met.
|
|
||||||
err := path.padWithDummyHops(cfg.MinNumHops)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
hops, minHTLC, maxHTLC, err := collectRelayInfo(cfg, path)
|
hops, minHTLC, maxHTLC, err := collectRelayInfo(cfg, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not collect blinded path relay "+
|
return nil, fmt.Errorf("could not collect blinded path relay "+
|
||||||
@@ -664,19 +664,34 @@ type candidatePath struct {
|
|||||||
hops []*blindedPathHop
|
hops []*blindedPathHop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a string representation of the candidatePath which can be
|
||||||
|
// useful for logging and debugging.
|
||||||
|
func (c *candidatePath) String() string {
|
||||||
|
str := fmt.Sprintf("[%s (intro node)]", c.introNode)
|
||||||
|
|
||||||
|
for _, hop := range c.hops {
|
||||||
|
if hop.isDummy {
|
||||||
|
str += "--->[dummy hop]"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
str += fmt.Sprintf("--<%d>-->[%s]", hop.channelID, hop.pubKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
// padWithDummyHops will append n dummy hops to the candidatePath hop set. The
|
// padWithDummyHops will append n dummy hops to the candidatePath hop set. The
|
||||||
// pub key for the dummy hop will be the same as the pub key for the final hop
|
// pub key for the dummy hop will be the same as the pub key for the final hop
|
||||||
// of the path. That way, the final hop will be able to decrypt the data
|
// of the path. That way, the final hop will be able to decrypt the data
|
||||||
// encrypted for each dummy hop.
|
// encrypted for each dummy hop.
|
||||||
func (c *candidatePath) padWithDummyHops(n uint8) error {
|
func (c *candidatePath) padWithDummyHops(n uint8) {
|
||||||
for len(c.hops) < int(n) {
|
for len(c.hops) < int(n) {
|
||||||
c.hops = append(c.hops, &blindedPathHop{
|
c.hops = append(c.hops, &blindedPathHop{
|
||||||
pubKey: c.finalNodeID,
|
pubKey: c.finalNodeID,
|
||||||
isDummy: true,
|
isDummy: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// blindedPathHop holds the information we need to know about a hop in a route
|
// blindedPathHop holds the information we need to know about a hop in a route
|
||||||
|
|||||||
Reference in new issue
Block a user