mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 17:55:36 +01:00
lnd: add the option to set the incoming channel on blinded path
This commit makes sure that when an incoming channel list is supplied for the blinded route, that it changes the other blinding restrictions accordingly. Moreover it introduces a sanity check when the number of paths for the blinded route is set to 0.
This commit is contained in:
parent
a2003850e7
commit
ebb428b789
1 changed files with 37 additions and 0 deletions
37
rpcserver.go
37
rpcserver.go
|
@ -6055,6 +6055,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||||
NumHops: globalBlindCfg.NumHops,
|
NumHops: globalBlindCfg.NumHops,
|
||||||
MaxNumPaths: globalBlindCfg.MaxNumPaths,
|
MaxNumPaths: globalBlindCfg.MaxNumPaths,
|
||||||
NodeOmissionSet: fn.NewSet[route.Vertex](),
|
NodeOmissionSet: fn.NewSet[route.Vertex](),
|
||||||
|
IncomingChainedChannels: make([]uint64, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
if blindCfg != nil && !blind {
|
if blindCfg != nil && !blind {
|
||||||
|
@ -6074,6 +6075,10 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||||
blindingRestrictions.MaxNumPaths =
|
blindingRestrictions.MaxNumPaths =
|
||||||
uint8(*blindCfg.MaxNumPaths)
|
uint8(*blindCfg.MaxNumPaths)
|
||||||
}
|
}
|
||||||
|
if blindingRestrictions.MaxNumPaths == 0 {
|
||||||
|
return nil, fmt.Errorf("blinded max num paths cannot " +
|
||||||
|
"be 0")
|
||||||
|
}
|
||||||
|
|
||||||
for _, nodeIDBytes := range blindCfg.NodeOmissionList {
|
for _, nodeIDBytes := range blindCfg.NodeOmissionList {
|
||||||
vertex, err := route.NewVertexFromBytes(nodeIDBytes)
|
vertex, err := route.NewVertexFromBytes(nodeIDBytes)
|
||||||
|
@ -6083,6 +6088,38 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
||||||
|
|
||||||
blindingRestrictions.NodeOmissionSet.Add(vertex)
|
blindingRestrictions.NodeOmissionSet.Add(vertex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blindingRestrictions.IncomingChainedChannels = append(
|
||||||
|
blindingRestrictions.IncomingChainedChannels,
|
||||||
|
blindCfg.IncomingChannelList...,
|
||||||
|
)
|
||||||
|
|
||||||
|
numChainedChannels :=
|
||||||
|
uint8(len(blindingRestrictions.IncomingChainedChannels))
|
||||||
|
|
||||||
|
// When selecting the blinded incoming channel list parameter
|
||||||
|
// the maximum number of hops is implictitly set.
|
||||||
|
if numChainedChannels > blindingRestrictions.NumHops {
|
||||||
|
rpcsLog.Warnf("Changing the num_blinded_hops "+
|
||||||
|
"from (%d) to (%d)",
|
||||||
|
blindingRestrictions.NumHops,
|
||||||
|
numChainedChannels)
|
||||||
|
|
||||||
|
blindingRestrictions.NumHops =
|
||||||
|
numChainedChannels
|
||||||
|
}
|
||||||
|
|
||||||
|
// The MinDistanceFromIntroNode must be greater than or equal to
|
||||||
|
// the number of hops specified on the chained channels.
|
||||||
|
minNumHops := blindingRestrictions.MinDistanceFromIntroNode
|
||||||
|
if minNumHops < numChainedChannels {
|
||||||
|
return nil, fmt.Errorf("minimum number of blinded "+
|
||||||
|
"path hops (%d) must be greater than or equal "+
|
||||||
|
"to the number of hops specified on the "+
|
||||||
|
"chained channels (%d)", minNumHops,
|
||||||
|
numChainedChannels)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if blindingRestrictions.MinDistanceFromIntroNode >
|
if blindingRestrictions.MinDistanceFromIntroNode >
|
||||||
|
|
Loading…
Add table
Reference in a new issue