From ab4ed7a557d9ca717e981ba020077cce3fdb7c5d Mon Sep 17 00:00:00 2001 From: MPins Date: Thu, 5 Dec 2024 11:24:34 -0300 Subject: [PATCH] blindedpath: add the MaxNumPaths restriction on BuildBlindedPaymentPaths func --- routing/blindedpath/blinded_path.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/routing/blindedpath/blinded_path.go b/routing/blindedpath/blinded_path.go index 5c16751858b..660c1d652a1 100644 --- a/routing/blindedpath/blinded_path.go +++ b/routing/blindedpath/blinded_path.go @@ -100,6 +100,9 @@ type BuildBlindedPathCfg struct { // route. MinNumHops uint8 + // MaxNumPaths is the maximum number of blinded paths to select. + MaxNumPaths uint8 + // DefaultDummyHopPolicy holds the policy values that should be used for // dummy hops in the cases where it cannot be derived via other means // such as averaging the policy values of other hops on the path. This @@ -132,8 +135,11 @@ func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) ( paths := make([]*zpay32.BlindedPaymentPath, 0, len(routes)) // For each route returned, we will construct the associated blinded - // payment path. + // payment path, until the maximum number of allowed paths. for _, route := range routes { + if len(paths) >= int(cfg.MaxNumPaths) { + break + } // Extract the information we need from the route. candidatePath := extractCandidatePath(route)