invoicesrpc: move blinded path config to AddInvoiceData

since `AddInvoiceData` is config _per invoice_ where as `AddInvoiceConfig`
is config for the invoice server itself and so pretty much should stay
the same for the lifetime of LND. This change sets us up for moving some
of the blinded path config options to be changeable per AddInvoice call
rather that having fixed config values in the config file.
This commit is contained in:
Elle Mouton
2024-08-03 14:24:23 +02:00
parent e47160d257
commit ca91e17115
2 changed files with 74 additions and 52 deletions

View File

@@ -5820,10 +5820,6 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
},
GetAlias: r.server.aliasMgr.GetPeerAlias,
BestHeight: r.server.cc.BestBlockTracker.BestHeight,
BlindedRoutePolicyIncrMultiplier: r.server.cfg.Routing.
BlindedPaths.PolicyIncreaseMultiplier,
BlindedRoutePolicyDecrMultiplier: r.server.cfg.Routing.
BlindedPaths.PolicyDecreaseMultiplier,
QueryBlindedRoutes: func(amt lnwire.MilliSatoshi) (
[]*route.Route, error) {
@@ -5833,18 +5829,6 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
blindingRestrictions,
)
},
MinNumBlindedPathHops: r.server.cfg.Routing.BlindedPaths.
NumHops,
DefaultDummyHopPolicy: &blindedpath.BlindedHopPolicy{
CLTVExpiryDelta: uint16(defaultDelta),
FeeRate: uint32(r.server.cfg.Bitcoin.FeeRate),
BaseFee: r.server.cfg.Bitcoin.BaseFee,
MinHTLCMsat: r.server.cfg.Bitcoin.MinHTLCIn,
// MaxHTLCMsat will be calculated on the fly by using
// the introduction node's channel's capacities.
MaxHTLCMsat: 0,
},
}
value, err := lnrpc.UnmarshallAmt(invoice.Value, invoice.ValueMsat)
@@ -5857,6 +5841,34 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
if err != nil {
return nil, err
}
var blindedPathCfg *invoicesrpc.BlindedPathConfig
if invoice.Blind {
bpConfig := r.server.cfg.Routing.BlindedPaths
blindedPathCfg = &invoicesrpc.BlindedPathConfig{
RoutePolicyIncrMultiplier: bpConfig.
PolicyIncreaseMultiplier,
RoutePolicyDecrMultiplier: bpConfig.
PolicyDecreaseMultiplier,
DefaultDummyHopPolicy: &blindedpath.BlindedHopPolicy{
CLTVExpiryDelta: uint16(defaultDelta),
FeeRate: uint32(
r.server.cfg.Bitcoin.FeeRate,
),
BaseFee: r.server.cfg.Bitcoin.BaseFee,
MinHTLCMsat: r.server.cfg.Bitcoin.MinHTLCIn,
// MaxHTLCMsat will be calculated on the fly by
// using the introduction node's channel's
// capacities.
MaxHTLCMsat: 0,
},
MinNumPathHops: r.server.cfg.Routing.BlindedPaths.
NumHops,
}
}
addInvoiceData := &invoicesrpc.AddInvoiceData{
Memo: invoice.Memo,
Value: value,
@@ -5867,7 +5879,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
Private: invoice.Private,
RouteHints: routeHints,
Amp: invoice.IsAmp,
Blind: invoice.Blind,
BlindedPathCfg: blindedPathCfg,
}
if invoice.RPreimage != nil {