Skip to content

Commit 697f514

Browse files
committed
blindedpath: log chosen blinded paths
In this commit, we log selected blinded paths.
1 parent 9547739 commit 697f514

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

itest/lnd_route_blinding_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,10 +1220,6 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
12201220
// Assert that it contains a single blinded path and that the
12211221
// introduction node is Carol.
12221222
payReq = dave.RPC.DecodePayReq(invoiceResp.PaymentRequest)
1223-
for _, path := range payReq.BlindedPaths {
1224-
ht.Logf("intro node: %x", path.BlindedPath.IntroductionNode)
1225-
}
1226-
12271223
require.Len(ht, payReq.BlindedPaths, 1)
12281224

12291225
// The total number of hop payloads is 3: one for the introduction node

routing/blindedpath/blinded_path.go

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,14 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
132132
// For each route returned, we will construct the associated blinded
133133
// payment path.
134134
for _, route := range routes {
135-
path, err := buildBlindedPaymentPath(
136-
cfg, extractCandidatePath(route),
137-
)
135+
// Extract the information we need from the route.
136+
candidatePath := extractCandidatePath(route)
137+
138+
// Pad the given route with dummy hops until the minimum number
139+
// of hops is met.
140+
candidatePath.padWithDummyHops(cfg.MinNumHops)
141+
142+
path, err := buildBlindedPaymentPath(cfg, candidatePath)
138143
if errors.Is(err, errInvalidBlindedPath) {
139144
log.Debugf("Not using route (%s) as a blinded path "+
140145
"since it resulted in an invalid blinded path",
@@ -148,6 +153,8 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
148153
continue
149154
}
150155

156+
log.Debugf("Route selected for blinded path: %s", candidatePath)
157+
151158
paths = append(paths, path)
152159
}
153160

@@ -163,13 +170,6 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
163170
func buildBlindedPaymentPath(cfg *BuildBlindedPathCfg, path *candidatePath) (
164171
*zpay32.BlindedPaymentPath, error) {
165172

166-
// Pad the given route with dummy hops until the minimum number of hops
167-
// is met.
168-
err := path.padWithDummyHops(cfg.MinNumHops)
169-
if err != nil {
170-
return nil, err
171-
}
172-
173173
hops, minHTLC, maxHTLC, err := collectRelayInfo(cfg, path)
174174
if err != nil {
175175
return nil, fmt.Errorf("could not collect blinded path relay "+
@@ -664,19 +664,34 @@ type candidatePath struct {
664664
hops []*blindedPathHop
665665
}
666666

667+
// String returns a string representation of the candidatePath which can be
668+
// useful for logging and debugging.
669+
func (c *candidatePath) String() string {
670+
str := fmt.Sprintf("[%s (intro node)]", c.introNode)
671+
672+
for _, hop := range c.hops {
673+
if hop.isDummy {
674+
str += "--->[dummy hop]"
675+
continue
676+
}
677+
678+
str += fmt.Sprintf("--<%d>-->[%s]", hop.channelID, hop.pubKey)
679+
}
680+
681+
return str
682+
}
683+
667684
// padWithDummyHops will append n dummy hops to the candidatePath hop set. The
668685
// pub key for the dummy hop will be the same as the pub key for the final hop
669686
// of the path. That way, the final hop will be able to decrypt the data
670687
// encrypted for each dummy hop.
671-
func (c *candidatePath) padWithDummyHops(n uint8) error {
688+
func (c *candidatePath) padWithDummyHops(n uint8) {
672689
for len(c.hops) < int(n) {
673690
c.hops = append(c.hops, &blindedPathHop{
674691
pubKey: c.finalNodeID,
675692
isDummy: true,
676693
})
677694
}
678-
679-
return nil
680695
}
681696

682697
// blindedPathHop holds the information we need to know about a hop in a route

0 commit comments

Comments
 (0)