@@ -96,28 +96,6 @@ type AddInvoiceConfig struct {
9696 // QueryBlindedRoutes can be used to generate a few routes to this node
9797 // that can then be used in the construction of a blinded payment path.
9898 QueryBlindedRoutes func (lnwire.MilliSatoshi ) ([]* route.Route , error )
99-
100- // BlindedRoutePolicyIncrMultiplier is the amount by which policy values
101- // for hops in a blinded route will be bumped to avoid easy probing. For
102- // example, a multiplier of 1.1 will bump all appropriate the values
103- // (base fee, fee rate, CLTV delta and min HLTC) by 10%.
104- BlindedRoutePolicyIncrMultiplier float64
105-
106- // BlindedRoutePolicyDecrMultiplier is the amount by which appropriate
107- // policy values for hops in a blinded route will be decreased to avoid
108- // easy probing. For example, a multiplier of 0.9 will reduce
109- // appropriate values (like maximum HTLC) by 10%.
110- BlindedRoutePolicyDecrMultiplier float64
111-
112- // MinNumBlindedPathHops is the minimum number of hops that a blinded
113- // path should be. Dummy hops will be used to pad any route with a
114- // length less than this.
115- MinNumBlindedPathHops uint8
116-
117- // DefaultDummyHopPolicy holds the default policy values to use for
118- // dummy hops in a blinded path in the case where they cant be derived
119- // through other means.
120- DefaultDummyHopPolicy * blindedpath.BlindedHopPolicy
12199}
122100
123101// AddInvoiceData contains the required data to create a new invoice.
@@ -168,16 +146,44 @@ type AddInvoiceData struct {
168146 // NOTE: Preimage should always be set to nil when this value is true.
169147 Amp bool
170148
171- // Blind signals that this invoice should disguise the location of the
172- // recipient by adding blinded payment paths to the invoice instead of
173- // revealing the destination node's real pub key.
174- Blind bool
149+ // BlindedPathCfg holds the config values to use when constructing
150+ // blinded paths to add to the invoice. A non-nil BlindedPathCfg signals
151+ // that this invoice should disguise the location of the recipient by
152+ // adding blinded payment paths to the invoice instead of revealing the
153+ // destination node's real pub key.
154+ BlindedPathCfg * BlindedPathConfig
175155
176156 // RouteHints are optional route hints that can each be individually
177157 // used to assist in reaching the invoice's destination.
178158 RouteHints [][]zpay32.HopHint
179159}
180160
161+ // BlindedPathConfig holds the configuration values required for blinded path
162+ // generation for invoices.
163+ type BlindedPathConfig struct {
164+ // RoutePolicyIncrMultiplier is the amount by which policy values for
165+ // hops in a blinded route will be bumped to avoid easy probing. For
166+ // example, a multiplier of 1.1 will bump all appropriate the values
167+ // (base fee, fee rate, CLTV delta and min HLTC) by 10%.
168+ RoutePolicyIncrMultiplier float64
169+
170+ // RoutePolicyDecrMultiplier is the amount by which appropriate policy
171+ // values for hops in a blinded route will be decreased to avoid easy
172+ // probing. For example, a multiplier of 0.9 will reduce appropriate
173+ // values (like maximum HTLC) by 10%.
174+ RoutePolicyDecrMultiplier float64
175+
176+ // MinNumPathHops is the minimum number of hops that a blinded path
177+ // should be. Dummy hops will be used to pad any route with a length
178+ // less than this.
179+ MinNumPathHops uint8
180+
181+ // DefaultDummyHopPolicy holds the default policy values to use for
182+ // dummy hops in a blinded path in the case where they cant be derived
183+ // through other means.
184+ DefaultDummyHopPolicy * blindedpath.BlindedHopPolicy
185+ }
186+
181187// paymentHashAndPreimage returns the payment hash and preimage for this invoice
182188// depending on the configuration.
183189//
@@ -277,7 +283,9 @@ func (d *AddInvoiceData) mppPaymentHashAndPreimage() (*lntypes.Preimage,
277283func AddInvoice (ctx context.Context , cfg * AddInvoiceConfig ,
278284 invoice * AddInvoiceData ) (* lntypes.Hash , * invoices.Invoice , error ) {
279285
280- if invoice .Amp && invoice .Blind {
286+ blind := invoice .BlindedPathCfg != nil
287+
288+ if invoice .Amp && blind {
281289 return nil , nil , fmt .Errorf ("AMP invoices with blinded paths " +
282290 "are not yet supported" )
283291 }
@@ -420,7 +428,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
420428 // Only include a final CLTV expiry delta if this is not a blinded
421429 // invoice. In a blinded invoice, this value will be added to the total
422430 // blinded route CLTV delta value
423- if ! invoice . Blind {
431+ if ! blind {
424432 options = append (options , zpay32 .CLTVExpiry (cltvExpiryDelta ))
425433 }
426434
@@ -433,7 +441,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
433441
434442 // Include route hints if needed.
435443 if len (invoice .RouteHints ) > 0 || invoice .Private {
436- if invoice . Blind {
444+ if blind {
437445 return nil , nil , fmt .Errorf ("can't set both hop " +
438446 "hints and add blinded payment paths" )
439447 }
@@ -492,7 +500,9 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
492500 return nil , nil , err
493501 }
494502
495- if invoice .Blind {
503+ if blind {
504+ blindCfg := invoice .BlindedPathCfg
505+
496506 // Use the 10-min-per-block assumption to get a rough estimate
497507 // of the number of blocks until the invoice expires. We want
498508 // to make sure that the blinded path definitely does not expire
@@ -525,12 +535,12 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
525535
526536 //nolint:lll
527537 return blindedpath .AddPolicyBuffer (
528- p , cfg . BlindedRoutePolicyIncrMultiplier ,
529- cfg . BlindedRoutePolicyDecrMultiplier ,
538+ p , blindCfg . RoutePolicyIncrMultiplier ,
539+ blindCfg . RoutePolicyDecrMultiplier ,
530540 )
531541 },
532- MinNumHops : cfg . MinNumBlindedPathHops ,
533- DefaultDummyHopPolicy : cfg .DefaultDummyHopPolicy ,
542+ MinNumHops : blindCfg . MinNumPathHops ,
543+ DefaultDummyHopPolicy : blindCfg .DefaultDummyHopPolicy ,
534544 },
535545 )
536546 if err != nil {
@@ -560,7 +570,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
560570 // For an invoice without a blinded path, the main node
561571 // key is used to sign the invoice so that the sender
562572 // can derive the true pub key of the recipient.
563- if ! invoice . Blind {
573+ if ! blind {
564574 return cfg .NodeSigner .SignMessageCompact (
565575 msg , false ,
566576 )
0 commit comments